@deepcitation/deepcitation-js 1.1.49 → 1.1.51
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/README.md +73 -157
- package/lib/chunk-2HINOG74.js +3 -0
- package/lib/chunk-2HINOG74.js.map +1 -0
- package/lib/chunk-4UWAUWYL.cjs +3 -0
- package/lib/chunk-4UWAUWYL.cjs.map +1 -0
- package/lib/chunk-5XGN7UAV.js +2 -0
- package/lib/chunk-5XGN7UAV.js.map +1 -0
- package/lib/chunk-7TORYXU4.cjs +3 -0
- package/lib/chunk-7TORYXU4.cjs.map +1 -0
- package/lib/chunk-BDSA6VGC.js +125 -0
- package/lib/chunk-BDSA6VGC.js.map +1 -0
- package/lib/chunk-BEYJEW3Y.js +2 -0
- package/lib/chunk-BEYJEW3Y.js.map +1 -0
- package/lib/chunk-BWQLFMTV.js +2 -0
- package/lib/chunk-BWQLFMTV.js.map +1 -0
- package/lib/{chunk-F2MMVEVC.cjs → chunk-BYLIBOAU.cjs} +2 -1
- package/lib/chunk-BYLIBOAU.cjs.map +1 -0
- package/lib/chunk-DS6SOU4L.cjs +2 -0
- package/lib/chunk-DS6SOU4L.cjs.map +1 -0
- package/lib/{chunk-UUR2SQKU.cjs → chunk-HL3AXCDL.cjs} +2 -1
- package/lib/chunk-HL3AXCDL.cjs.map +1 -0
- package/lib/chunk-N7FTXSGM.js +3 -0
- package/lib/chunk-N7FTXSGM.js.map +1 -0
- package/lib/chunk-WS4CQVDI.cjs +125 -0
- package/lib/chunk-WS4CQVDI.cjs.map +1 -0
- package/lib/client/index.cjs +2 -1
- package/lib/client/index.cjs.map +1 -0
- package/lib/client/index.d.cts +58 -13
- package/lib/client/index.d.ts +58 -13
- package/lib/client/index.js +2 -1
- package/lib/client/index.js.map +1 -0
- package/lib/{index-fvVBZYVK.d.ts → index-BHjI8Bh1.d.cts} +61 -22
- package/lib/{index-fvVBZYVK.d.cts → index-BHjI8Bh1.d.ts} +61 -22
- package/lib/index.cjs +2 -1
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +137 -16
- package/lib/index.d.ts +137 -16
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -0
- package/lib/prompts/index.cjs +2 -1
- package/lib/prompts/index.cjs.map +1 -0
- package/lib/prompts/index.d.cts +177 -55
- package/lib/prompts/index.d.ts +177 -55
- package/lib/prompts/index.js +2 -1
- package/lib/prompts/index.js.map +1 -0
- package/lib/react/index.cjs +8 -5
- package/lib/react/index.cjs.map +1 -0
- package/lib/react/index.d.cts +348 -21
- package/lib/react/index.d.ts +348 -21
- package/lib/react/index.js +8 -5
- package/lib/react/index.js.map +1 -0
- package/lib/styles.css +1 -1
- package/lib/types/index.cjs +2 -1
- package/lib/types/index.cjs.map +1 -0
- package/lib/types/index.d.cts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +2 -1
- package/lib/types/index.js.map +1 -0
- package/lib/{utils-q6anRKO_.d.cts → utils-CCi9_JTv.d.cts} +5 -5
- package/lib/{utils-DuacFTtu.d.ts → utils-CoSP-i76.d.ts} +5 -5
- package/package.json +165 -152
- package/src/tailwind.css +5 -5
- package/lib/chunk-2PRW5PVT.cjs +0 -2
- package/lib/chunk-3XSZLKJW.js +0 -2
- package/lib/chunk-D2TKEF6D.cjs +0 -2
- package/lib/chunk-DHVODVIA.cjs +0 -71
- package/lib/chunk-HRCAI3NV.js +0 -1
- package/lib/chunk-ND6LFDGK.js +0 -71
- package/lib/chunk-O2XFH626.js +0 -1
- package/lib/chunk-PKXMJNRX.js +0 -2
package/package.json
CHANGED
|
@@ -1,152 +1,165 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@deepcitation/deepcitation-js",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "DeepCitation JavaScript SDK for deterministic AI citation verification",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"private": false,
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"author": "DeepCitation <opensource@deepcitation.com>",
|
|
9
|
-
"homepage": "https://deepcitation.com",
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/
|
|
16
|
-
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"build
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"test
|
|
35
|
-
"test:
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"react":
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"react
|
|
53
|
-
"optional": true
|
|
54
|
-
},
|
|
55
|
-
"
|
|
56
|
-
"optional": true
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"react": "19.2.3",
|
|
78
|
-
"react
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
},
|
|
131
|
-
"./
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@deepcitation/deepcitation-js",
|
|
3
|
+
"version": "1.1.51",
|
|
4
|
+
"description": "DeepCitation JavaScript SDK for deterministic AI citation verification",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "DeepCitation <opensource@deepcitation.com>",
|
|
9
|
+
"homepage": "https://deepcitation.com",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/DeepCitation/deepcitation-js/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/DeepCitation/deepcitation-js.git"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"provenance": true
|
|
20
|
+
},
|
|
21
|
+
"main": "./lib/index.cjs",
|
|
22
|
+
"module": "./lib/index.js",
|
|
23
|
+
"types": "./lib/index.d.ts",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"files": [
|
|
26
|
+
"lib",
|
|
27
|
+
"src/tailwind.css"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup && npm run build:css",
|
|
31
|
+
"build:css": "tailwindcss -i ./src/styles.css -o ./lib/styles.css --minify",
|
|
32
|
+
"build:watch": "tsup --watch",
|
|
33
|
+
"build:tsc": "rimraf lib && tsc",
|
|
34
|
+
"test": "bun test ./src/__tests__/*.test.ts ./src/__tests__/*.test.tsx",
|
|
35
|
+
"test:jest": "jest",
|
|
36
|
+
"test:watch": "jest --watch",
|
|
37
|
+
"test:ct": "playwright test -c playwright-ct.config.ts",
|
|
38
|
+
"test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
|
|
39
|
+
"size": "size-limit",
|
|
40
|
+
"analyze": "size-limit --why",
|
|
41
|
+
"prepublishOnly": "npm run build"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=18"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@radix-ui/react-popover": "^1.0.0",
|
|
48
|
+
"react": ">=17.0.0",
|
|
49
|
+
"react-dom": ">=17.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"react": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"react-dom": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"@radix-ui/react-popover": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@happy-dom/global-registrator": "^20.4.0",
|
|
64
|
+
"@jest/globals": "^29.7.0",
|
|
65
|
+
"@playwright/experimental-ct-react": "^1.57.0",
|
|
66
|
+
"@playwright/test": "^1.57.0",
|
|
67
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
68
|
+
"@rollup/rollup-linux-x64-gnu": "^4.57.0",
|
|
69
|
+
"@size-limit/preset-small-lib": "^11.2.0",
|
|
70
|
+
"@tailwindcss/cli": "^4.1.18",
|
|
71
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
72
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
73
|
+
"@testing-library/react": "^16.3.1",
|
|
74
|
+
"@types/jest": "^29.5.14",
|
|
75
|
+
"@types/node": "^24.10.9",
|
|
76
|
+
"@types/react": "^19.2.10",
|
|
77
|
+
"@types/react-dom": "^19.2.3",
|
|
78
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
79
|
+
"bun-types": "^1.3.7",
|
|
80
|
+
"esbuild": "0.25.12",
|
|
81
|
+
"happy-dom": "^20.4.0",
|
|
82
|
+
"jest": "^29.7.0",
|
|
83
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
84
|
+
"react": "19.2.3",
|
|
85
|
+
"react-dom": "19.2.3",
|
|
86
|
+
"rimraf": "^5.0.10",
|
|
87
|
+
"size-limit": "^11.2.0",
|
|
88
|
+
"tailwindcss": "^4.1.18",
|
|
89
|
+
"ts-jest": "^29.4.6",
|
|
90
|
+
"tsup": "^8.5.1",
|
|
91
|
+
"typescript": "^5.9.3",
|
|
92
|
+
"vite": "^7.3.1"
|
|
93
|
+
},
|
|
94
|
+
"size-limit": [
|
|
95
|
+
{
|
|
96
|
+
"path": "lib/index.js",
|
|
97
|
+
"limit": "25 KB"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"path": "lib/client/index.js",
|
|
101
|
+
"limit": "10 KB"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"path": "lib/prompts/index.js",
|
|
105
|
+
"limit": "15 KB"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"path": "lib/react/index.js",
|
|
109
|
+
"limit": "15 KB"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"exports": {
|
|
113
|
+
".": {
|
|
114
|
+
"types": "./lib/index.d.ts",
|
|
115
|
+
"import": "./lib/index.js",
|
|
116
|
+
"require": "./lib/index.cjs",
|
|
117
|
+
"default": "./lib/index.js"
|
|
118
|
+
},
|
|
119
|
+
"./client": {
|
|
120
|
+
"types": "./lib/client/index.d.ts",
|
|
121
|
+
"import": "./lib/client/index.js",
|
|
122
|
+
"require": "./lib/client/index.cjs",
|
|
123
|
+
"default": "./lib/client/index.js"
|
|
124
|
+
},
|
|
125
|
+
"./prompts": {
|
|
126
|
+
"types": "./lib/prompts/index.d.ts",
|
|
127
|
+
"import": "./lib/prompts/index.js",
|
|
128
|
+
"require": "./lib/prompts/index.cjs",
|
|
129
|
+
"default": "./lib/prompts/index.js"
|
|
130
|
+
},
|
|
131
|
+
"./react": {
|
|
132
|
+
"types": "./lib/react/index.d.ts",
|
|
133
|
+
"import": "./lib/react/index.js",
|
|
134
|
+
"require": "./lib/react/index.cjs",
|
|
135
|
+
"default": "./lib/react/index.js"
|
|
136
|
+
},
|
|
137
|
+
"./types": {
|
|
138
|
+
"types": "./lib/types/index.d.ts",
|
|
139
|
+
"import": "./lib/types/index.js",
|
|
140
|
+
"require": "./lib/types/index.cjs",
|
|
141
|
+
"default": "./lib/types/index.js"
|
|
142
|
+
},
|
|
143
|
+
"./tailwind.css": "./src/tailwind.css",
|
|
144
|
+
"./styles.css": "./lib/styles.css",
|
|
145
|
+
"./package.json": "./package.json"
|
|
146
|
+
},
|
|
147
|
+
"keywords": [
|
|
148
|
+
"citation",
|
|
149
|
+
"ai",
|
|
150
|
+
"verification",
|
|
151
|
+
"llm",
|
|
152
|
+
"hallucination",
|
|
153
|
+
"react",
|
|
154
|
+
"typescript",
|
|
155
|
+
"openai",
|
|
156
|
+
"anthropic",
|
|
157
|
+
"claude",
|
|
158
|
+
"gpt",
|
|
159
|
+
"rag",
|
|
160
|
+
"reference",
|
|
161
|
+
"source-verification",
|
|
162
|
+
"fact-checking",
|
|
163
|
+
"grounding"
|
|
164
|
+
]
|
|
165
|
+
}
|
package/src/tailwind.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* DeepCitation Tailwind v4 source configuration
|
|
2
|
-
* Import this file in your main CSS to include library classes:
|
|
3
|
-
* @import "@deepcitation/deepcitation-js/tailwind.css";
|
|
4
|
-
*/
|
|
5
|
-
@source "./react";
|
|
1
|
+
/* DeepCitation Tailwind v4 source configuration
|
|
2
|
+
* Import this file in your main CSS to include library classes:
|
|
3
|
+
* @import "@deepcitation/deepcitation-js/tailwind.css";
|
|
4
|
+
*/
|
|
5
|
+
@source "./react";
|
package/lib/chunk-2PRW5PVT.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';function Z(t){return new TextEncoder().encode(t)}function W(t){let e=1732584193,s=4023233417,r=2562383102,n=271733878,a=3285377520,y=t.length,h=y*8,o=y+1+8,i=Math.ceil(o/64)*64,u=new ArrayBuffer(i),k=new Uint8Array(u),c=new DataView(u);k.set(t),k[y]=128,c.setUint32(i-8,Math.floor(h/4294967296),false),c.setUint32(i-4,h>>>0,false);let d=new Uint32Array(80);for(let f=0;f<i;f+=64){for(let m=0;m<16;m++)d[m]=c.getUint32(f+m*4,false);for(let m=16;m<80;m++){let A=d[m-3]^d[m-8]^d[m-14]^d[m-16];d[m]=A<<1|A>>>31;}let C=e,g=s,l=r,x=n,b=a;for(let m=0;m<80;m++){let A,_;m<20?(A=g&l|~g&x,_=1518500249):m<40?(A=g^l^x,_=1859775393):m<60?(A=g&l|g&x|l&x,_=2400959708):(A=g^l^x,_=3395469782);let p=(C<<5|C>>>27)+A+b+_+d[m]>>>0;b=x,x=l,l=(g<<30|g>>>2)>>>0,g=C,C=p;}e=e+C>>>0,s=s+g>>>0,r=r+l>>>0,n=n+x>>>0,a=a+b>>>0;}let I=f=>f.toString(16).padStart(8,"0");return I(e)+I(s)+I(r)+I(n)+I(a)}function R(t){try{if(!t)return "";let e=typeof t=="string"?t:JSON.stringify(t);return W(Z(e))}catch(e){console.error("Error in making the hash:",e);}return ""}var v=new Map;function U(t){let e=v.get(t);return e||(e=new RegExp(`${t}='((?:[^'\\\\]|\\\\.)*)'`),v.set(t,e)),e}function D(t){if(!t)return;let e=[],s=t.split(",");for(let r of s){let n=r.trim();if(n)if(n.includes("-")){let[a,y]=n.split("-"),h=parseInt(a,10),o=parseInt(y,10);if(!isNaN(h)&&!isNaN(o)&&h<=o)for(let i=h;i<=o;i++)e.push(i);else isNaN(h)||e.push(h);}else {let a=parseInt(n,10);isNaN(a)||e.push(a);}}if(e.length!==0)return [...new Set(e)].sort((r,n)=>r-n)}function O(t){let e=t?.status,s=["not_found"].includes(e||""),r=["found","found_key_span_only","found_phrase_missed_value"].includes(e||""),n=["partial_text_found","found_on_other_page","found_on_other_line","first_word_found"].includes(e||""),a=["pending","loading",null,void 0].includes(e);return {isVerified:r,isMiss:s,isPartialMatch:n,isPending:a}}var B=(t,e,s,r)=>{let n=_=>{if(!_)return;let p=_;return (p.startsWith("'")||p.startsWith('"'))&&(p=p.slice(1)),(p.endsWith("'")||p.endsWith('"'))&&!p.endsWith("\\'")&&!p.endsWith('\\"')&&(p=p.slice(0,-1)),p=p.replace(/\\"/g,'"'),p=p.replace(/\\'/g,"'"),p=p.replace(/\\n/g," "),p=p.replace(/\\\\/g,"\\"),p},a=s?.current?s.current++:void 0,y=t.substring(0,t.indexOf("<cite")),h=t.includes("/>")?t.slice(t.indexOf("/>")+2):"",o=t.substring(t.indexOf("<cite"),t.indexOf("/>")+2),i=(_,p)=>{for(let w of p){let P=U(w),T=_.match(P);if(T)return T[1]}},u=i(o,["attachment_id","attachmentId","file_id","fileId"]),k=u?.length===20?u:e||u,c=i(o,["start_page_key","startPageKey","start_page"]),d,I;if(c){let _=c.match(/page[\_a-zA-Z]*(\d+)_index_(\d+)/);_&&(d=parseInt(_[1]),I=parseInt(_[2]));}let f=n(i(o,["full_phrase","fullPhrase"])),C=n(i(o,["key_span","keySpan"])),g=n(i(o,["reasoning"])),l=n(i(o,["value"])),x;try{let p=i(o,["line_ids","lineIds"])?.replace(/[A-Za-z_[\](){}:]/g,"");x=p?D(p):void 0;}catch(_){r&&console.error("Error parsing lineIds",_);}let b=i(o,["timestamps"]),m;if(b){let[_,p]=b.split("-")||[];m={startTime:_,endTime:p};}let A={attachmentId:k,pageNumber:d,startPageKey:`page_number_${d||1}_index_${I||0}`,fullPhrase:f,keySpan:C||l,citationNumber:a,lineIds:x,beforeCite:y,timestamps:m,reasoning:g};return {beforeCite:y,afterCite:h,citation:A}},J=(t,e)=>{if(!t)return null;let s=t.fullPhrase??t.full_phrase,r=t.startPageKey??t.start_page_key,n=t.keySpan??t.key_span,a=t.lineIds??t.line_ids,y=t.attachmentId??t.attachment_id??t.fileId??t.file_id,h=t.reasoning,o=t.value;if(!s)return null;let i;if(r){let c=r.match(/page[_a-zA-Z]*(\d+)_index_(\d+)/i);if(c)i=parseInt(c[1],10);else {let d=r.match(/^(\d+)_(\d+)$/);d&&(i=parseInt(d[1],10));}}let u=a?.length?[...a].sort((c,d)=>c-d):void 0;return {attachmentId:y,pageNumber:i,fullPhrase:s,citationNumber:e,lineIds:u,keySpan:n||o,reasoning:h}},M=t=>typeof t=="object"&&t!==null&&("fullPhrase"in t||"full_phrase"in t||"startPageKey"in t||"start_page_key"in t||"keySpan"in t||"key_span"in t||"lineIds"in t||"line_ids"in t),$=t=>Array.isArray(t)?t.length>0&&t.some(M):typeof t=="object"&&t!==null?M(t):false,z=t=>{let e={},s=Array.isArray(t)?t:[t],r=1;for(let n of s){let a=J(n,r++);if(a&&a.fullPhrase){let y=S(a);e[y]=a;}}return e},K=(t,e)=>{if(!(!t||typeof t!="object")){if(t.citation&&$(t.citation)){let s=Array.isArray(t.citation)?t.citation:[t.citation];e.push(...s);}if(t.citations&&$(t.citations)){let s=Array.isArray(t.citations)?t.citations:[t.citations];e.push(...s);}if(Array.isArray(t))for(let s of t)K(s,e);else for(let s of Object.keys(t))s!=="citation"&&s!=="citations"&&K(t[s],e);}},V=t=>{let e=E(t),s=/<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*\/>/g,r=e.match(s);if(!r||r.length===0)return {};let n={},a={current:1};for(let y of r){let{citation:h}=B(y,void 0,a);if(h&&h.fullPhrase){let o=S(h);n[o]=h;}}return n},tt=t=>{if(!t)return {};let e={};if(typeof t=="object"){if($(t)){let n=z(t);Object.assign(e,n);}else {let n=[];if(K(t,n),n.length>0){let a=z(n);Object.assign(e,a);}}let s=JSON.stringify(t),r=V(s);Object.assign(e,r);}else if(typeof t=="string"){let s=V(t);Object.assign(e,s);}return e};function et(t){let e=new Map,s=Array.isArray(t)?t.map((r,n)=>[S(r)||String(n+1),r]):Object.entries(t);for(let[r,n]of s){let a=n.attachmentId||"";e.has(a)||e.set(a,{}),e.get(a)[r]=n;}return e}function nt(t){let e={},s=Array.isArray(t)?t.map((r,n)=>[S(r)||String(n+1),r]):Object.entries(t);for(let[r,n]of s){let a=n.attachmentId||"";e[a]||(e[a]={}),e[a][r]=n;}return e}var F=t=>{let e={},s=/([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(['"])((?:[^'"\\]|\\.)*)\2/g,r;for(;(r=s.exec(t))!==null;){let n=r[1].toLowerCase().replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase(),a=r[3],y=n==="fileid"||n==="file_id"||n==="attachmentid"?"attachment_id":n==="keyspan"?"key_span":n==="fullphrase"?"full_phrase":n==="lineids"?"line_ids":n==="startpagekey"||n==="start_pagekey"?"start_page_key":n;e[y]=a;}return e},H=t=>{let e=O(t);return e.isMiss?"\u274C":e.isVerified&&!e.isPartialMatch?"\u2611\uFE0F":e.isPartialMatch?"\u2705":e.isPending?"\u231B":"\u25CC"},q=(t,e={})=>{let{leaveKeySpanBehind:s=false,verifications:r,showVerificationStatus:n=false}=e,a=0,y=/<cite\s+[^>]*?\/>/g;return t.replace(y,h=>{a++;let o=F(h),i="";if(s&&o.key_span&&(i=o.key_span.replace(/\\'/g,"'").replace(/\\"/g,'"')),n&&r){let u,k=g=>{if(!g)return;let l=g.match(/page[_a-zA-Z]*(\d+)/);return l?parseInt(l[1],10):void 0},c=g=>{if(!g)return;let x=g.replace(/(\d+)-(\d+)/g,(b,m,A)=>{let _=parseInt(m,10),p=parseInt(A,10);if(_<=p){let w=[];for(let P=_;P<=p;P++)w.push(P);return w.join(",")}return m}).split(",").map(b=>parseInt(b.trim(),10)).filter(b=>!isNaN(b));return x.length>0?x:void 0},d=g=>g?.replace(/\\'/g,"'").replace(/\\"/g,'"'),I={attachmentId:o.attachment_id,pageNumber:k(o.start_page_key),fullPhrase:d(o.full_phrase),keySpan:d(o.key_span),lineIds:c(o.line_ids)},f=S(I);if(u=r[f],!u){let g=String(a);u=r[g];}let C=H(u);i=i?`${i}${C}`:C;}return i})},at=(t,e)=>q(t,{leaveKeySpanBehind:e}),ot=t=>t.replace(/<page_number_\d+_index_\d+>/g,"").replace(/<\/page_number_\d+_index_\d+>/g,"").trim(),ct=t=>{let e=/<line id="[^"]*">|<\/line>/g;return t.replace(e,"")},L=t=>{if(!t)return null;let e=t.match(/\d+/)?.[0];return e?parseInt(e):null},G=t=>{let e=t.match(/^(<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>)([\s\S]*?)<\/cite>$/);if(!e){let h=t.match(/^(<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>)$/);if(h){let o=h[1].replace(/>$/," />");return N(o)}return N(t)}let[,s,r]=e;if(!r||!r.trim())return N(t);let n=s.replace(/>$/," />"),a=r.trim(),y=N(n);return a+y},E=t=>{let e=t?.trim()||"";e=e.replace(/(?<![<a-zA-Z])cite\s+(attachment_id|file_id|fileId|attachmentId)\s*=/gi,"<cite $1=");let s=e.split(/(<cite[\s\S]*?(?:\/>|<\/cite>|>(?=\s*$|[\r\n])(?![\s\S]*<\/cite>)))/gm);if(s.length<=1){let r=e.match(/<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>/g);if(r&&r.length>0){let n=e.replace(/<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>/g,a=>a.replace(/>$/," />"));return N(n)}return N(e)}return e=s.map(r=>r.startsWith("<cite")?G(r):r).join(""),e},N=t=>{let e=t;e=e.replace(/\\_/g,"_"),e=e.replace(/><\/cite>/g,"/>");let s=o=>{let i=o.toLowerCase();return i==="fullphrase"||i==="full_phrase"?"full_phrase":i==="lineids"||i==="line_ids"?"line_ids":i==="startpagekey"||i==="start_pagekey"||i==="start_page_key"?"start_page_key":i==="fileid"||i==="file_id"||i==="attachmentid"||i==="attachment_id"?"attachment_id":i==="keyspan"||i==="key_span"?"key_span":i==="reasoning"||i==="value"?i:i==="timestamps"||i==="timestamp"||i==="timestamps"?"timestamps":i},r={""":'"',"'":"'","<":"<",">":">","&":"&"},n=/&(?:quot|apos|lt|gt|amp);/g,a=o=>o.replace(n,i=>r[i]||i),y=/(fullPhrase|full_phrase|keySpan|key_span|reasoning|value)\s*=\s*(['"])([\s\S]*?)(?=\s+(?:line_ids|lineIds|timestamps|fileId|file_id|attachmentId|attachment_id|start_page_key|start_pageKey|startPageKey|keySpan|key_span|reasoning|value|full_phrase)\s*=|\s*\/>|['"]>)/gm;e=e.replace(y,(o,i,u,k)=>{let c=k;return c.endsWith(u)&&(c=c.slice(0,-1)),c=c.replace(/(\r?\n)+|(\*|_){2,}|\*/g,d=>d.includes(`
|
|
2
|
-
`)||d.includes("\r")?" ":""),c=a(c),c=c.replace(/\\\\'/g,"'").replace(/\\'/g,"'").replace(/'/g,"\\'"),c=c.replace(/\\\\"/g,'"').replace(/\\"/g,'"').replace(/"/g,'\\"'),`${s(i)}='${c}'`}),e=e.replace(/(line_ids|lineIds|timestamps)=['"]?([\[\]\(\){}A-Za-z0-9_\-, ]+)['"]?(\s*\/?>|\s+)/gm,(o,i,u,k)=>{let c=u.replace(/[A-Za-z\[\]\(\){}]/g,"");return c=c.replace(/(\d+)-(\d+)/g,(d,I,f)=>{let C=parseInt(I,10),g=parseInt(f,10),l=[];if(C<=g)for(let x=C;x<=g;x++)l.push(x);else l.push(C);return l.join(",")}),c=c.replace(/,+/g,",").replace(/^,|,$/g,""),`${s(i)}='${c}'${k}`});let h=o=>{let i=/([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(['"])((?:[^'"\\\n]|\\.)*)(?:\2)/g,u={},k;for(;k=i.exec(o);){let l=k[1],x=k[3],b=s(l);u[b]=x;}let c=Object.keys(u);if(c.length===0)return o;let d=typeof u.timestamps=="string"&&u.timestamps.length>0,I=c.filter(l=>l.startsWith("start_page")),f=[];u.attachment_id&&f.push("attachment_id"),d?(u.full_phrase&&f.push("full_phrase"),u.key_span&&f.push("key_span"),f.push("timestamps")):(I.includes("start_page_key")&&f.push("start_page_key"),I.filter(l=>l!=="start_page_key").sort().forEach(l=>f.push(l)),u.full_phrase&&f.push("full_phrase"),u.key_span&&f.push("key_span"),u.line_ids&&f.push("line_ids")),u.reasoning&&f.push("reasoning"),u.value&&f.push("value");let C=new Set(f);return c.filter(l=>!C.has(l)).sort().forEach(l=>f.push(l)),`<cite ${f.map(l=>`${l}='${u[l]}'`).join(" ")} />`};return e=e.replace(/<cite\b[\s\S]*?\/>/gm,o=>h(o)),e};function ft(...t){return t.filter(Boolean).join(" ")}function X(t){return t.type==="url"||typeof t.url=="string"&&t.url.length>0}function S(t){let e=t.pageNumber||L(t.startPageKey),s=[t.attachmentId||"",e?.toString()||"",t.fullPhrase||"",t.keySpan?.toString()||"",t.lineIds?.join(",")||"",t.timestamps?.startTime||"",t.timestamps?.endTime||""];return X(t)&&s.push(t.url||"",t.title||"",t.domain||""),R(s.join("|")).slice(0,16)}function gt(t){let e=[t.attachmentId||"",t.label||"",t.verifiedFullPhrase||"",t.verifiedKeySpan||"",t.verifiedLineIds?.join(",")||"",t.verifiedPageNumber?.toString()||"",t.verifiedTimestamps?.startTime||"",t.verifiedTimestamps?.endTime||"",t.verifiedMatchSnippet||"",t.hitIndexWithinPage?.toString()||""];return R(e.join("|")).slice(0,16)}function dt(t){let e=Math.random().toString(36).slice(2,11);return `${t}-${e}`}function mt(t,e={}){let{fallbackDisplay:s}=e;return t.keySpan?.toString()||t.citationNumber?.toString()||s||"1"}function ht(t){return t.citationNumber?.toString()||"1"}function yt(t){return t.keySpan?.toString()||""}function _t(...t){return t.filter(Boolean).join(" ")}var xt=4,Ct=1;exports.a=R;exports.b=ft;exports.c=X;exports.d=S;exports.e=gt;exports.f=dt;exports.g=mt;exports.h=ht;exports.i=yt;exports.j=_t;exports.k=xt;exports.l=Ct;exports.m=H;exports.n=q;exports.o=at;exports.p=ot;exports.q=ct;exports.r=L;exports.s=E;exports.t=O;exports.u=B;exports.v=tt;exports.w=et;exports.x=nt;
|
package/lib/chunk-3XSZLKJW.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {d as d$1,v}from'./chunk-PKXMJNRX.js';import {a}from'./chunk-O2XFH626.js';var P="https://api.deepcitation.com";function F(p,t){if(typeof Buffer<"u"&&Buffer.isBuffer(p)){let e=Uint8Array.from(p);return {blob:new Blob([e]),name:t||"document"}}if(p instanceof Blob)return {blob:p,name:t||(p instanceof File?p.name:"document")};throw new Error("Invalid file type. Expected File, Blob, or Buffer.")}async function d(p,t){return (await p.json().catch(()=>({})))?.error?.message||`${t} failed with status ${p.status}`}var h=class{constructor(t){a(this,"apiKey");a(this,"apiUrl");if(!t.apiKey)throw new Error("DeepCitation API key is required. Get one at https://deepcitation.com/dashboard");this.apiKey=t.apiKey,this.apiUrl=t.apiUrl?.replace(/\/$/,"")||P;}async uploadFile(t,e){let{blob:l,name:r}=F(t,e?.filename),o=new FormData;o.append("file",l,r),e?.attachmentId&&o.append("attachmentId",e.attachmentId),e?.filename&&o.append("filename",e.filename);let i=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:o});if(!i.ok)throw new Error(await d(i,"Upload"));return await i.json()}async convertToPdf(t){let e=typeof t=="string"?{url:t}:t,{url:l,file:r,filename:o,attachmentId:i}=e;if(!l&&!r)throw new Error("Either url or file must be provided");let n;if(l)n=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({url:l,filename:o,attachmentId:i})});else {let{blob:f,name:s}=F(r,o),a=new FormData;a.append("file",f,s),i&&a.append("attachmentId",i),o&&a.append("filename",o),n=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:a});}if(!n.ok)throw new Error(await d(n,"Conversion"));return await n.json()}async prepareConvertedFile(t){let e=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({attachmentId:t.attachmentId})});if(!e.ok)throw new Error(await d(e,"Prepare"));return await e.json()}async prepareFiles(t){if(t.length===0)return {fileDataParts:[],deepTextPromptPortion:[]};let e=t.map(({file:i,filename:n,attachmentId:f})=>this.uploadFile(i,{filename:n,attachmentId:f}).then(s=>({result:s,filename:n}))),r=(await Promise.all(e)).map(({result:i,filename:n})=>({attachmentId:i.attachmentId,deepTextPromptPortion:i.deepTextPromptPortion,filename:n||i.metadata?.filename})),o=r.map(i=>i.deepTextPromptPortion);return {fileDataParts:r,deepTextPromptPortion:o}}async verifyAttachment(t,e,l){let r={};if(Array.isArray(e))for(let s of e){let a=d$1(s);r[a]=s;}else if(typeof e=="object"&&e!==null)if("fullPhrase"in e||"value"in e){let s=d$1(e);r[s]=e;}else Object.assign(r,e);else throw new Error("Invalid citations format");if(Object.keys(r).length===0)return {verifications:{}};let o=`${this.apiUrl}/verifyCitations`,i={data:{attachmentId:t,citations:r,outputImageFormat:l?.outputImageFormat||"avif"}},n=await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok)throw new Error(await d(n,"Verification"));return await n.json()}async verify(t,e){let{llmOutput:l,outputImageFormat:r="avif"}=t;if(e||(e=v(l)),Object.keys(e).length===0)return {verifications:{}};let o=new Map;for(let[a,c]of Object.entries(e)){let m=c.attachmentId||"";o.has(m)||o.set(m,{}),o.get(m)[a]=c;}let i=[],n={};for(let[a,c]of o)a?i.push(this.verifyAttachment(a,c,{outputImageFormat:r})):(Object.assign(n,c),typeof console<"u"&&console.warn&&console.warn(`[DeepCitation] ${Object.keys(c).length} citation(s) skipped: missing attachmentId`));let f=await Promise.all(i),s={};for(let a of f)Object.assign(s,a.verifications);for(let a of Object.keys(n))s[a]={status:"skipped"};return {verifications:s}}};
|
|
2
|
-
export{h as a};
|
package/lib/chunk-D2TKEF6D.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk2PRW5PVT_cjs=require('./chunk-2PRW5PVT.cjs'),chunkF2MMVEVC_cjs=require('./chunk-F2MMVEVC.cjs');var P="https://api.deepcitation.com";function F(p,t){if(typeof Buffer<"u"&&Buffer.isBuffer(p)){let e=Uint8Array.from(p);return {blob:new Blob([e]),name:t||"document"}}if(p instanceof Blob)return {blob:p,name:t||(p instanceof File?p.name:"document")};throw new Error("Invalid file type. Expected File, Blob, or Buffer.")}async function d(p,t){return (await p.json().catch(()=>({})))?.error?.message||`${t} failed with status ${p.status}`}var h=class{constructor(t){chunkF2MMVEVC_cjs.a(this,"apiKey");chunkF2MMVEVC_cjs.a(this,"apiUrl");if(!t.apiKey)throw new Error("DeepCitation API key is required. Get one at https://deepcitation.com/dashboard");this.apiKey=t.apiKey,this.apiUrl=t.apiUrl?.replace(/\/$/,"")||P;}async uploadFile(t,e){let{blob:l,name:r}=F(t,e?.filename),o=new FormData;o.append("file",l,r),e?.attachmentId&&o.append("attachmentId",e.attachmentId),e?.filename&&o.append("filename",e.filename);let i=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:o});if(!i.ok)throw new Error(await d(i,"Upload"));return await i.json()}async convertToPdf(t){let e=typeof t=="string"?{url:t}:t,{url:l,file:r,filename:o,attachmentId:i}=e;if(!l&&!r)throw new Error("Either url or file must be provided");let n;if(l)n=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({url:l,filename:o,attachmentId:i})});else {let{blob:f,name:s}=F(r,o),a=new FormData;a.append("file",f,s),i&&a.append("attachmentId",i),o&&a.append("filename",o),n=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:a});}if(!n.ok)throw new Error(await d(n,"Conversion"));return await n.json()}async prepareConvertedFile(t){let e=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({attachmentId:t.attachmentId})});if(!e.ok)throw new Error(await d(e,"Prepare"));return await e.json()}async prepareFiles(t){if(t.length===0)return {fileDataParts:[],deepTextPromptPortion:[]};let e=t.map(({file:i,filename:n,attachmentId:f})=>this.uploadFile(i,{filename:n,attachmentId:f}).then(s=>({result:s,filename:n}))),r=(await Promise.all(e)).map(({result:i,filename:n})=>({attachmentId:i.attachmentId,deepTextPromptPortion:i.deepTextPromptPortion,filename:n||i.metadata?.filename})),o=r.map(i=>i.deepTextPromptPortion);return {fileDataParts:r,deepTextPromptPortion:o}}async verifyAttachment(t,e,l){let r={};if(Array.isArray(e))for(let s of e){let a=chunk2PRW5PVT_cjs.d(s);r[a]=s;}else if(typeof e=="object"&&e!==null)if("fullPhrase"in e||"value"in e){let s=chunk2PRW5PVT_cjs.d(e);r[s]=e;}else Object.assign(r,e);else throw new Error("Invalid citations format");if(Object.keys(r).length===0)return {verifications:{}};let o=`${this.apiUrl}/verifyCitations`,i={data:{attachmentId:t,citations:r,outputImageFormat:l?.outputImageFormat||"avif"}},n=await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok)throw new Error(await d(n,"Verification"));return await n.json()}async verify(t,e){let{llmOutput:l,outputImageFormat:r="avif"}=t;if(e||(e=chunk2PRW5PVT_cjs.v(l)),Object.keys(e).length===0)return {verifications:{}};let o=new Map;for(let[a,c]of Object.entries(e)){let m=c.attachmentId||"";o.has(m)||o.set(m,{}),o.get(m)[a]=c;}let i=[],n={};for(let[a,c]of o)a?i.push(this.verifyAttachment(a,c,{outputImageFormat:r})):(Object.assign(n,c),typeof console<"u"&&console.warn&&console.warn(`[DeepCitation] ${Object.keys(c).length} citation(s) skipped: missing attachmentId`));let f=await Promise.all(i),s={};for(let a of f)Object.assign(s,a.verifications);for(let a of Object.keys(n))s[a]={status:"skipped"};return {verifications:s}}};
|
|
2
|
-
exports.a=h;
|
package/lib/chunk-DHVODVIA.cjs
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';var _=`
|
|
2
|
-
<citation-instructions priority="critical">
|
|
3
|
-
## REQUIRED: Citation Format
|
|
4
|
-
|
|
5
|
-
### Scope (Where to use)
|
|
6
|
-
For every claim, value, or fact in your chat response; you MUST cite the attachment using this exact syntax:
|
|
7
|
-
|
|
8
|
-
<cite attachment_id='ID' reasoning='why this supports the claim' full_phrase='verbatim quote' key_span='1-3 key words' start_page_key='page_number_N_index_I' line_ids='X-Y' />
|
|
9
|
-
|
|
10
|
-
### Syntax Rules (MUST follow)
|
|
11
|
-
|
|
12
|
-
1. **attachment_id**: Use the exact ID from the source document
|
|
13
|
-
2. **reasoning**: Brief explanation of why this citation supports your claim (think first!)
|
|
14
|
-
3. **full_phrase**: Copy text VERBATIM from source. Escape quotes (\\') and newlines (\\n).
|
|
15
|
-
4. **key_span**: The 1-3 most important words or value from full_phrase
|
|
16
|
-
5. **start_page_key**: ONLY use format \`page_number_N_index_I\` from page tags (e.g., \`<page_number_1_index_0>\`). Never extract page numbers from document content.
|
|
17
|
-
6. **line_ids**: Inclusive range (e.g., '2-6' or '4'). Infer intermediate lines since only every 5th line is shown.
|
|
18
|
-
|
|
19
|
-
### Placement Rules
|
|
20
|
-
|
|
21
|
-
- Place <cite /> inline, typically at the end of a claim
|
|
22
|
-
- One citation per distinct idea, concept, or value (a sentence citing 3 different values needs 3 citations)
|
|
23
|
-
- Do NOT group citations at the end of the document
|
|
24
|
-
- The <cite /> tag is self-closing - never use <cite>...</cite>
|
|
25
|
-
|
|
26
|
-
### Example Citation 1
|
|
27
|
-
|
|
28
|
-
The company reported strong growth<cite attachment_id='abc123' reasoning='directly states revenue growth percentage' full_phrase='Revenue increased 45% year-over-year to $2.3 billion' key_span='increased 45%' start_page_key='page_number_2_index_1' line_ids='12-14' />
|
|
29
|
-
|
|
30
|
-
### Example Citation 2
|
|
31
|
-
|
|
32
|
-
The total amount is $500 USD <cite attachment_id='abc123' reasoning='directly states the total amount' full_phrase='The total amount is $500 USD' key_span='$500 USD' start_page_key='page_number_2_index_1' line_ids='12-14' />
|
|
33
|
-
</citation-instructions>
|
|
34
|
-
|
|
35
|
-
`,y=`
|
|
36
|
-
<citation-instructions priority="critical">
|
|
37
|
-
## REQUIRED: Audio/Video Citation Format
|
|
38
|
-
|
|
39
|
-
For every claim, value, or fact; you MUST cite the attachment using this exact syntax:
|
|
40
|
-
|
|
41
|
-
<cite attachment_id='ID' reasoning='why this supports the claim' full_phrase='verbatim transcript quote' key_span='1-3 key words' timestamps='HH:MM:SS.SSS-HH:MM:SS.SSS' />
|
|
42
|
-
|
|
43
|
-
### Syntax Rules (MUST follow)
|
|
44
|
-
|
|
45
|
-
1. **attachment_id**: Use the exact ID from the source
|
|
46
|
-
2. **reasoning**: Brief explanation of why this citation supports your claim (think first!)
|
|
47
|
-
3. **full_phrase**: Copy transcript text VERBATIM. Escape quotes (\\') and newlines (\\n).
|
|
48
|
-
4. **key_span**: The 1-3 most important words or value from full_phrase
|
|
49
|
-
5. **timestamps**: Start and end time with milliseconds (e.g., '00:01:23.456-00:01:45.789')
|
|
50
|
-
|
|
51
|
-
### Placement Rules
|
|
52
|
-
|
|
53
|
-
- Place <cite /> inline, typically at the end of a claim
|
|
54
|
-
- One citation per distinct idea, concept, or value (a sentence citing 3 different values needs 3 citations)
|
|
55
|
-
- Do NOT group citations at the end of the document
|
|
56
|
-
- The <cite /> tag is self-closing - never use <cite>...</cite>
|
|
57
|
-
|
|
58
|
-
</citation-instructions>
|
|
59
|
-
`,d="<citation-reminder>STOP and CHECK: Did you use <cite /> tags with all required attributes for every claim, value, or fact from attachments?</citation-reminder>",T="<citation-reminder>STOP and CHECK: Did you use <cite /> tags with timestamps for every claim, value, or fact from source media?</citation-reminder>";function x(t){let{systemPrompt:n,isAudioVideo:i=false}=t,e=i?y:_,r=i?T:d;return `${e.trim()}
|
|
60
|
-
|
|
61
|
-
${n.trim()}
|
|
62
|
-
|
|
63
|
-
${r}`}function R(t){let{systemPrompt:n,userPrompt:i,deepTextPromptPortion:e,isAudioVideo:r=false}=t,s=x({systemPrompt:n,isAudioVideo:r}),c=i;if(e){let o=Array.isArray(e)?e:[e];c=`${o.map((a,l)=>o.length===1?`
|
|
64
|
-
${a}`:`
|
|
65
|
-
${a}`).join(`
|
|
66
|
-
|
|
67
|
-
`)}
|
|
68
|
-
|
|
69
|
-
${d}
|
|
70
|
-
|
|
71
|
-
${i}`;}return {enhancedSystemPrompt:s,enhancedUserPrompt:c}}var O={type:"object",properties:{attachmentId:{type:"string"},reasoning:{type:"string",description:"The logic connecting the form section requirements to the supporting source citation (think first!)"},fullPhrase:{type:"string",description:"The verbatim text of the terse phrase inside <attachment_text /> to support the citation (if there is a detected OCR correction, use the corrected text)"},keySpan:{type:"string",description:"The verbatim 1-3 words within fullPhrase that best support the citation"},startPageKey:{type:"string",description:'Only return a result like "page_number_PAGE_index_INDEX" from the provided page keys (e.g. <page_number_1_index_0>) and never from the contents inside the page.'},lineIds:{type:"array",items:{type:"number"},description:"Infer lineIds, as we only provide the first, last, and every 5th line. Provide inclusive lineIds for the fullPhrase."}},required:["attachmentId","reasoning","fullPhrase","keySpan","startPageKey","lineIds"]},v={type:"object",properties:{attachmentId:{type:"string"},startPageKey:{type:"string",description:'Only return a result like "page_number_PAGE_index_INDEX" from the provided page keys (e.g. <page_number_1_index_0>) and never from the contents inside the page.'},fullPhrase:{type:"string",description:"The exact verbatim text of the phrase or paragraph from the source document to support the citation (if there is a detected OCR correction, use the verbatim corrected text)"},keySpan:{type:"string",description:"The verbatim 1-3 words within fullPhrase that best support the citation"},timestamps:{type:"object",properties:{startTime:{type:"string"},endTime:{type:"string"}},required:["startTime","endTime"],description:"The timestamp of the audio or video frame including milliseconds formatted as: HH:MM:SS.SSS"}},required:["attachmentId","startPageKey","fullPhrase","keySpan","timestamps"]};var u=4,P=3,I=5;function S(t,n){let i={};for(let e of t){for(let r=u;r<=e.length;r++){let s=e.slice(0,r),c=(s.match(/\d/g)||[]).length,o=(s.match(/[a-zA-Z]/g)||[]).length;if(s.length<u||c>0&&o<P||c===0&&o<I||t.some(m=>m!==e&&m.startsWith(s)))continue;let p=m=>m.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a=(n.match(new RegExp(p(s),"g"))||[]).length,l=(n.match(new RegExp(p(e),"g"))||[]).length;if(a===l){i[s]=e;break}}if(!Object.values(i).includes(e))throw new Error(`Cannot find a safe unique prefix for ID "${e}" that meets the minimum requirements (length: ${u})`)}return i}function w(t,n){if(!n||n.length===0)return {compressed:t,prefixMap:{}};let i=Array.from(new Set(n)),e=JSON.stringify(t),r=S(i,e),s=Object.keys(r).sort((o,p)=>p.length-o.length),c=e;for(let o of s){let a=r[o].replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");c=c.replace(new RegExp(a,"g"),o);}return {compressed:JSON.parse(c),prefixMap:r}}function C(t,n){if(!n||Object.keys(n).length===0)return t;let i=Object.entries(n).sort((a,l)=>l[0].length-a[0].length),e,r=false;typeof t=="string"?e=t:(e=JSON.stringify(t),r=true);let s=e?.length;for(let[a,l]of i){let m=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");e=e.replace(new RegExp(m,"g"),l);}let c=["attachmentId","attachment_id","attachment_ID","attachmentID","fileId","file_id","file_ID","fileID","fileid"];for(let[a,l]of i){let m=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),h=c.join("|"),f="([\"'`])",g=new RegExp(`(${h})(\\s*=\\s*)${f}${m}\\3`,"g");e=e.replace(g,`$1$2$3${l}$3`);}let o=e?.length,p=s-o;if(p>0)throw new Error(`[decompressedPromptIds] diff ${p} originalLength ${s} newLength ${o}`);return r?JSON.parse(e):e}exports.a=_;exports.b=y;exports.c=d;exports.d=T;exports.e=x;exports.f=R;exports.g=O;exports.h=v;exports.i=w;exports.j=C;
|
package/lib/chunk-HRCAI3NV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t="avif";var e=-1,n=-2,r={attachmentId:null,verifiedPageNumber:e,verifiedMatchSnippet:null,citation:{pageNumber:e},status:"not_found"};export{t as a,e as b,n as c,r as d};
|
package/lib/chunk-ND6LFDGK.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var _=`
|
|
2
|
-
<citation-instructions priority="critical">
|
|
3
|
-
## REQUIRED: Citation Format
|
|
4
|
-
|
|
5
|
-
### Scope (Where to use)
|
|
6
|
-
For every claim, value, or fact in your chat response; you MUST cite the attachment using this exact syntax:
|
|
7
|
-
|
|
8
|
-
<cite attachment_id='ID' reasoning='why this supports the claim' full_phrase='verbatim quote' key_span='1-3 key words' start_page_key='page_number_N_index_I' line_ids='X-Y' />
|
|
9
|
-
|
|
10
|
-
### Syntax Rules (MUST follow)
|
|
11
|
-
|
|
12
|
-
1. **attachment_id**: Use the exact ID from the source document
|
|
13
|
-
2. **reasoning**: Brief explanation of why this citation supports your claim (think first!)
|
|
14
|
-
3. **full_phrase**: Copy text VERBATIM from source. Escape quotes (\\') and newlines (\\n).
|
|
15
|
-
4. **key_span**: The 1-3 most important words or value from full_phrase
|
|
16
|
-
5. **start_page_key**: ONLY use format \`page_number_N_index_I\` from page tags (e.g., \`<page_number_1_index_0>\`). Never extract page numbers from document content.
|
|
17
|
-
6. **line_ids**: Inclusive range (e.g., '2-6' or '4'). Infer intermediate lines since only every 5th line is shown.
|
|
18
|
-
|
|
19
|
-
### Placement Rules
|
|
20
|
-
|
|
21
|
-
- Place <cite /> inline, typically at the end of a claim
|
|
22
|
-
- One citation per distinct idea, concept, or value (a sentence citing 3 different values needs 3 citations)
|
|
23
|
-
- Do NOT group citations at the end of the document
|
|
24
|
-
- The <cite /> tag is self-closing - never use <cite>...</cite>
|
|
25
|
-
|
|
26
|
-
### Example Citation 1
|
|
27
|
-
|
|
28
|
-
The company reported strong growth<cite attachment_id='abc123' reasoning='directly states revenue growth percentage' full_phrase='Revenue increased 45% year-over-year to $2.3 billion' key_span='increased 45%' start_page_key='page_number_2_index_1' line_ids='12-14' />
|
|
29
|
-
|
|
30
|
-
### Example Citation 2
|
|
31
|
-
|
|
32
|
-
The total amount is $500 USD <cite attachment_id='abc123' reasoning='directly states the total amount' full_phrase='The total amount is $500 USD' key_span='$500 USD' start_page_key='page_number_2_index_1' line_ids='12-14' />
|
|
33
|
-
</citation-instructions>
|
|
34
|
-
|
|
35
|
-
`,y=`
|
|
36
|
-
<citation-instructions priority="critical">
|
|
37
|
-
## REQUIRED: Audio/Video Citation Format
|
|
38
|
-
|
|
39
|
-
For every claim, value, or fact; you MUST cite the attachment using this exact syntax:
|
|
40
|
-
|
|
41
|
-
<cite attachment_id='ID' reasoning='why this supports the claim' full_phrase='verbatim transcript quote' key_span='1-3 key words' timestamps='HH:MM:SS.SSS-HH:MM:SS.SSS' />
|
|
42
|
-
|
|
43
|
-
### Syntax Rules (MUST follow)
|
|
44
|
-
|
|
45
|
-
1. **attachment_id**: Use the exact ID from the source
|
|
46
|
-
2. **reasoning**: Brief explanation of why this citation supports your claim (think first!)
|
|
47
|
-
3. **full_phrase**: Copy transcript text VERBATIM. Escape quotes (\\') and newlines (\\n).
|
|
48
|
-
4. **key_span**: The 1-3 most important words or value from full_phrase
|
|
49
|
-
5. **timestamps**: Start and end time with milliseconds (e.g., '00:01:23.456-00:01:45.789')
|
|
50
|
-
|
|
51
|
-
### Placement Rules
|
|
52
|
-
|
|
53
|
-
- Place <cite /> inline, typically at the end of a claim
|
|
54
|
-
- One citation per distinct idea, concept, or value (a sentence citing 3 different values needs 3 citations)
|
|
55
|
-
- Do NOT group citations at the end of the document
|
|
56
|
-
- The <cite /> tag is self-closing - never use <cite>...</cite>
|
|
57
|
-
|
|
58
|
-
</citation-instructions>
|
|
59
|
-
`,d="<citation-reminder>STOP and CHECK: Did you use <cite /> tags with all required attributes for every claim, value, or fact from attachments?</citation-reminder>",T="<citation-reminder>STOP and CHECK: Did you use <cite /> tags with timestamps for every claim, value, or fact from source media?</citation-reminder>";function x(t){let{systemPrompt:n,isAudioVideo:i=false}=t,e=i?y:_,r=i?T:d;return `${e.trim()}
|
|
60
|
-
|
|
61
|
-
${n.trim()}
|
|
62
|
-
|
|
63
|
-
${r}`}function R(t){let{systemPrompt:n,userPrompt:i,deepTextPromptPortion:e,isAudioVideo:r=false}=t,s=x({systemPrompt:n,isAudioVideo:r}),c=i;if(e){let o=Array.isArray(e)?e:[e];c=`${o.map((a,l)=>o.length===1?`
|
|
64
|
-
${a}`:`
|
|
65
|
-
${a}`).join(`
|
|
66
|
-
|
|
67
|
-
`)}
|
|
68
|
-
|
|
69
|
-
${d}
|
|
70
|
-
|
|
71
|
-
${i}`;}return {enhancedSystemPrompt:s,enhancedUserPrompt:c}}var O={type:"object",properties:{attachmentId:{type:"string"},reasoning:{type:"string",description:"The logic connecting the form section requirements to the supporting source citation (think first!)"},fullPhrase:{type:"string",description:"The verbatim text of the terse phrase inside <attachment_text /> to support the citation (if there is a detected OCR correction, use the corrected text)"},keySpan:{type:"string",description:"The verbatim 1-3 words within fullPhrase that best support the citation"},startPageKey:{type:"string",description:'Only return a result like "page_number_PAGE_index_INDEX" from the provided page keys (e.g. <page_number_1_index_0>) and never from the contents inside the page.'},lineIds:{type:"array",items:{type:"number"},description:"Infer lineIds, as we only provide the first, last, and every 5th line. Provide inclusive lineIds for the fullPhrase."}},required:["attachmentId","reasoning","fullPhrase","keySpan","startPageKey","lineIds"]},v={type:"object",properties:{attachmentId:{type:"string"},startPageKey:{type:"string",description:'Only return a result like "page_number_PAGE_index_INDEX" from the provided page keys (e.g. <page_number_1_index_0>) and never from the contents inside the page.'},fullPhrase:{type:"string",description:"The exact verbatim text of the phrase or paragraph from the source document to support the citation (if there is a detected OCR correction, use the verbatim corrected text)"},keySpan:{type:"string",description:"The verbatim 1-3 words within fullPhrase that best support the citation"},timestamps:{type:"object",properties:{startTime:{type:"string"},endTime:{type:"string"}},required:["startTime","endTime"],description:"The timestamp of the audio or video frame including milliseconds formatted as: HH:MM:SS.SSS"}},required:["attachmentId","startPageKey","fullPhrase","keySpan","timestamps"]};var u=4,P=3,I=5;function S(t,n){let i={};for(let e of t){for(let r=u;r<=e.length;r++){let s=e.slice(0,r),c=(s.match(/\d/g)||[]).length,o=(s.match(/[a-zA-Z]/g)||[]).length;if(s.length<u||c>0&&o<P||c===0&&o<I||t.some(m=>m!==e&&m.startsWith(s)))continue;let p=m=>m.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a=(n.match(new RegExp(p(s),"g"))||[]).length,l=(n.match(new RegExp(p(e),"g"))||[]).length;if(a===l){i[s]=e;break}}if(!Object.values(i).includes(e))throw new Error(`Cannot find a safe unique prefix for ID "${e}" that meets the minimum requirements (length: ${u})`)}return i}function w(t,n){if(!n||n.length===0)return {compressed:t,prefixMap:{}};let i=Array.from(new Set(n)),e=JSON.stringify(t),r=S(i,e),s=Object.keys(r).sort((o,p)=>p.length-o.length),c=e;for(let o of s){let a=r[o].replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");c=c.replace(new RegExp(a,"g"),o);}return {compressed:JSON.parse(c),prefixMap:r}}function C(t,n){if(!n||Object.keys(n).length===0)return t;let i=Object.entries(n).sort((a,l)=>l[0].length-a[0].length),e,r=false;typeof t=="string"?e=t:(e=JSON.stringify(t),r=true);let s=e?.length;for(let[a,l]of i){let m=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");e=e.replace(new RegExp(m,"g"),l);}let c=["attachmentId","attachment_id","attachment_ID","attachmentID","fileId","file_id","file_ID","fileID","fileid"];for(let[a,l]of i){let m=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),h=c.join("|"),f="([\"'`])",g=new RegExp(`(${h})(\\s*=\\s*)${f}${m}\\3`,"g");e=e.replace(g,`$1$2$3${l}$3`);}let o=e?.length,p=s-o;if(p>0)throw new Error(`[decompressedPromptIds] diff ${p} originalLength ${s} newLength ${o}`);return r?JSON.parse(e):e}export{_ as a,y as b,d as c,T as d,x as e,R as f,O as g,v as h,w as i,C as j};
|
package/lib/chunk-O2XFH626.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:true,configurable:true,writable:true,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
|
package/lib/chunk-PKXMJNRX.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function Z(t){return new TextEncoder().encode(t)}function W(t){let e=1732584193,s=4023233417,r=2562383102,n=271733878,a=3285377520,y=t.length,h=y*8,o=y+1+8,i=Math.ceil(o/64)*64,u=new ArrayBuffer(i),k=new Uint8Array(u),c=new DataView(u);k.set(t),k[y]=128,c.setUint32(i-8,Math.floor(h/4294967296),false),c.setUint32(i-4,h>>>0,false);let d=new Uint32Array(80);for(let f=0;f<i;f+=64){for(let m=0;m<16;m++)d[m]=c.getUint32(f+m*4,false);for(let m=16;m<80;m++){let A=d[m-3]^d[m-8]^d[m-14]^d[m-16];d[m]=A<<1|A>>>31;}let C=e,g=s,l=r,x=n,b=a;for(let m=0;m<80;m++){let A,_;m<20?(A=g&l|~g&x,_=1518500249):m<40?(A=g^l^x,_=1859775393):m<60?(A=g&l|g&x|l&x,_=2400959708):(A=g^l^x,_=3395469782);let p=(C<<5|C>>>27)+A+b+_+d[m]>>>0;b=x,x=l,l=(g<<30|g>>>2)>>>0,g=C,C=p;}e=e+C>>>0,s=s+g>>>0,r=r+l>>>0,n=n+x>>>0,a=a+b>>>0;}let I=f=>f.toString(16).padStart(8,"0");return I(e)+I(s)+I(r)+I(n)+I(a)}function R(t){try{if(!t)return "";let e=typeof t=="string"?t:JSON.stringify(t);return W(Z(e))}catch(e){console.error("Error in making the hash:",e);}return ""}var v=new Map;function U(t){let e=v.get(t);return e||(e=new RegExp(`${t}='((?:[^'\\\\]|\\\\.)*)'`),v.set(t,e)),e}function D(t){if(!t)return;let e=[],s=t.split(",");for(let r of s){let n=r.trim();if(n)if(n.includes("-")){let[a,y]=n.split("-"),h=parseInt(a,10),o=parseInt(y,10);if(!isNaN(h)&&!isNaN(o)&&h<=o)for(let i=h;i<=o;i++)e.push(i);else isNaN(h)||e.push(h);}else {let a=parseInt(n,10);isNaN(a)||e.push(a);}}if(e.length!==0)return [...new Set(e)].sort((r,n)=>r-n)}function O(t){let e=t?.status,s=["not_found"].includes(e||""),r=["found","found_key_span_only","found_phrase_missed_value"].includes(e||""),n=["partial_text_found","found_on_other_page","found_on_other_line","first_word_found"].includes(e||""),a=["pending","loading",null,void 0].includes(e);return {isVerified:r,isMiss:s,isPartialMatch:n,isPending:a}}var B=(t,e,s,r)=>{let n=_=>{if(!_)return;let p=_;return (p.startsWith("'")||p.startsWith('"'))&&(p=p.slice(1)),(p.endsWith("'")||p.endsWith('"'))&&!p.endsWith("\\'")&&!p.endsWith('\\"')&&(p=p.slice(0,-1)),p=p.replace(/\\"/g,'"'),p=p.replace(/\\'/g,"'"),p=p.replace(/\\n/g," "),p=p.replace(/\\\\/g,"\\"),p},a=s?.current?s.current++:void 0,y=t.substring(0,t.indexOf("<cite")),h=t.includes("/>")?t.slice(t.indexOf("/>")+2):"",o=t.substring(t.indexOf("<cite"),t.indexOf("/>")+2),i=(_,p)=>{for(let w of p){let P=U(w),T=_.match(P);if(T)return T[1]}},u=i(o,["attachment_id","attachmentId","file_id","fileId"]),k=u?.length===20?u:e||u,c=i(o,["start_page_key","startPageKey","start_page"]),d,I;if(c){let _=c.match(/page[\_a-zA-Z]*(\d+)_index_(\d+)/);_&&(d=parseInt(_[1]),I=parseInt(_[2]));}let f=n(i(o,["full_phrase","fullPhrase"])),C=n(i(o,["key_span","keySpan"])),g=n(i(o,["reasoning"])),l=n(i(o,["value"])),x;try{let p=i(o,["line_ids","lineIds"])?.replace(/[A-Za-z_[\](){}:]/g,"");x=p?D(p):void 0;}catch(_){r&&console.error("Error parsing lineIds",_);}let b=i(o,["timestamps"]),m;if(b){let[_,p]=b.split("-")||[];m={startTime:_,endTime:p};}let A={attachmentId:k,pageNumber:d,startPageKey:`page_number_${d||1}_index_${I||0}`,fullPhrase:f,keySpan:C||l,citationNumber:a,lineIds:x,beforeCite:y,timestamps:m,reasoning:g};return {beforeCite:y,afterCite:h,citation:A}},J=(t,e)=>{if(!t)return null;let s=t.fullPhrase??t.full_phrase,r=t.startPageKey??t.start_page_key,n=t.keySpan??t.key_span,a=t.lineIds??t.line_ids,y=t.attachmentId??t.attachment_id??t.fileId??t.file_id,h=t.reasoning,o=t.value;if(!s)return null;let i;if(r){let c=r.match(/page[_a-zA-Z]*(\d+)_index_(\d+)/i);if(c)i=parseInt(c[1],10);else {let d=r.match(/^(\d+)_(\d+)$/);d&&(i=parseInt(d[1],10));}}let u=a?.length?[...a].sort((c,d)=>c-d):void 0;return {attachmentId:y,pageNumber:i,fullPhrase:s,citationNumber:e,lineIds:u,keySpan:n||o,reasoning:h}},M=t=>typeof t=="object"&&t!==null&&("fullPhrase"in t||"full_phrase"in t||"startPageKey"in t||"start_page_key"in t||"keySpan"in t||"key_span"in t||"lineIds"in t||"line_ids"in t),$=t=>Array.isArray(t)?t.length>0&&t.some(M):typeof t=="object"&&t!==null?M(t):false,z=t=>{let e={},s=Array.isArray(t)?t:[t],r=1;for(let n of s){let a=J(n,r++);if(a&&a.fullPhrase){let y=S(a);e[y]=a;}}return e},K=(t,e)=>{if(!(!t||typeof t!="object")){if(t.citation&&$(t.citation)){let s=Array.isArray(t.citation)?t.citation:[t.citation];e.push(...s);}if(t.citations&&$(t.citations)){let s=Array.isArray(t.citations)?t.citations:[t.citations];e.push(...s);}if(Array.isArray(t))for(let s of t)K(s,e);else for(let s of Object.keys(t))s!=="citation"&&s!=="citations"&&K(t[s],e);}},V=t=>{let e=E(t),s=/<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*\/>/g,r=e.match(s);if(!r||r.length===0)return {};let n={},a={current:1};for(let y of r){let{citation:h}=B(y,void 0,a);if(h&&h.fullPhrase){let o=S(h);n[o]=h;}}return n},tt=t=>{if(!t)return {};let e={};if(typeof t=="object"){if($(t)){let n=z(t);Object.assign(e,n);}else {let n=[];if(K(t,n),n.length>0){let a=z(n);Object.assign(e,a);}}let s=JSON.stringify(t),r=V(s);Object.assign(e,r);}else if(typeof t=="string"){let s=V(t);Object.assign(e,s);}return e};function et(t){let e=new Map,s=Array.isArray(t)?t.map((r,n)=>[S(r)||String(n+1),r]):Object.entries(t);for(let[r,n]of s){let a=n.attachmentId||"";e.has(a)||e.set(a,{}),e.get(a)[r]=n;}return e}function nt(t){let e={},s=Array.isArray(t)?t.map((r,n)=>[S(r)||String(n+1),r]):Object.entries(t);for(let[r,n]of s){let a=n.attachmentId||"";e[a]||(e[a]={}),e[a][r]=n;}return e}var F=t=>{let e={},s=/([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(['"])((?:[^'"\\]|\\.)*)\2/g,r;for(;(r=s.exec(t))!==null;){let n=r[1].toLowerCase().replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase(),a=r[3],y=n==="fileid"||n==="file_id"||n==="attachmentid"?"attachment_id":n==="keyspan"?"key_span":n==="fullphrase"?"full_phrase":n==="lineids"?"line_ids":n==="startpagekey"||n==="start_pagekey"?"start_page_key":n;e[y]=a;}return e},H=t=>{let e=O(t);return e.isMiss?"\u274C":e.isVerified&&!e.isPartialMatch?"\u2611\uFE0F":e.isPartialMatch?"\u2705":e.isPending?"\u231B":"\u25CC"},q=(t,e={})=>{let{leaveKeySpanBehind:s=false,verifications:r,showVerificationStatus:n=false}=e,a=0,y=/<cite\s+[^>]*?\/>/g;return t.replace(y,h=>{a++;let o=F(h),i="";if(s&&o.key_span&&(i=o.key_span.replace(/\\'/g,"'").replace(/\\"/g,'"')),n&&r){let u,k=g=>{if(!g)return;let l=g.match(/page[_a-zA-Z]*(\d+)/);return l?parseInt(l[1],10):void 0},c=g=>{if(!g)return;let x=g.replace(/(\d+)-(\d+)/g,(b,m,A)=>{let _=parseInt(m,10),p=parseInt(A,10);if(_<=p){let w=[];for(let P=_;P<=p;P++)w.push(P);return w.join(",")}return m}).split(",").map(b=>parseInt(b.trim(),10)).filter(b=>!isNaN(b));return x.length>0?x:void 0},d=g=>g?.replace(/\\'/g,"'").replace(/\\"/g,'"'),I={attachmentId:o.attachment_id,pageNumber:k(o.start_page_key),fullPhrase:d(o.full_phrase),keySpan:d(o.key_span),lineIds:c(o.line_ids)},f=S(I);if(u=r[f],!u){let g=String(a);u=r[g];}let C=H(u);i=i?`${i}${C}`:C;}return i})},at=(t,e)=>q(t,{leaveKeySpanBehind:e}),ot=t=>t.replace(/<page_number_\d+_index_\d+>/g,"").replace(/<\/page_number_\d+_index_\d+>/g,"").trim(),ct=t=>{let e=/<line id="[^"]*">|<\/line>/g;return t.replace(e,"")},L=t=>{if(!t)return null;let e=t.match(/\d+/)?.[0];return e?parseInt(e):null},G=t=>{let e=t.match(/^(<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>)([\s\S]*?)<\/cite>$/);if(!e){let h=t.match(/^(<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>)$/);if(h){let o=h[1].replace(/>$/," />");return N(o)}return N(t)}let[,s,r]=e;if(!r||!r.trim())return N(t);let n=s.replace(/>$/," />"),a=r.trim(),y=N(n);return a+y},E=t=>{let e=t?.trim()||"";e=e.replace(/(?<![<a-zA-Z])cite\s+(attachment_id|file_id|fileId|attachmentId)\s*=/gi,"<cite $1=");let s=e.split(/(<cite[\s\S]*?(?:\/>|<\/cite>|>(?=\s*$|[\r\n])(?![\s\S]*<\/cite>)))/gm);if(s.length<=1){let r=e.match(/<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>/g);if(r&&r.length>0){let n=e.replace(/<cite\s+(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[^'">/])*>/g,a=>a.replace(/>$/," />"));return N(n)}return N(e)}return e=s.map(r=>r.startsWith("<cite")?G(r):r).join(""),e},N=t=>{let e=t;e=e.replace(/\\_/g,"_"),e=e.replace(/><\/cite>/g,"/>");let s=o=>{let i=o.toLowerCase();return i==="fullphrase"||i==="full_phrase"?"full_phrase":i==="lineids"||i==="line_ids"?"line_ids":i==="startpagekey"||i==="start_pagekey"||i==="start_page_key"?"start_page_key":i==="fileid"||i==="file_id"||i==="attachmentid"||i==="attachment_id"?"attachment_id":i==="keyspan"||i==="key_span"?"key_span":i==="reasoning"||i==="value"?i:i==="timestamps"||i==="timestamp"||i==="timestamps"?"timestamps":i},r={""":'"',"'":"'","<":"<",">":">","&":"&"},n=/&(?:quot|apos|lt|gt|amp);/g,a=o=>o.replace(n,i=>r[i]||i),y=/(fullPhrase|full_phrase|keySpan|key_span|reasoning|value)\s*=\s*(['"])([\s\S]*?)(?=\s+(?:line_ids|lineIds|timestamps|fileId|file_id|attachmentId|attachment_id|start_page_key|start_pageKey|startPageKey|keySpan|key_span|reasoning|value|full_phrase)\s*=|\s*\/>|['"]>)/gm;e=e.replace(y,(o,i,u,k)=>{let c=k;return c.endsWith(u)&&(c=c.slice(0,-1)),c=c.replace(/(\r?\n)+|(\*|_){2,}|\*/g,d=>d.includes(`
|
|
2
|
-
`)||d.includes("\r")?" ":""),c=a(c),c=c.replace(/\\\\'/g,"'").replace(/\\'/g,"'").replace(/'/g,"\\'"),c=c.replace(/\\\\"/g,'"').replace(/\\"/g,'"').replace(/"/g,'\\"'),`${s(i)}='${c}'`}),e=e.replace(/(line_ids|lineIds|timestamps)=['"]?([\[\]\(\){}A-Za-z0-9_\-, ]+)['"]?(\s*\/?>|\s+)/gm,(o,i,u,k)=>{let c=u.replace(/[A-Za-z\[\]\(\){}]/g,"");return c=c.replace(/(\d+)-(\d+)/g,(d,I,f)=>{let C=parseInt(I,10),g=parseInt(f,10),l=[];if(C<=g)for(let x=C;x<=g;x++)l.push(x);else l.push(C);return l.join(",")}),c=c.replace(/,+/g,",").replace(/^,|,$/g,""),`${s(i)}='${c}'${k}`});let h=o=>{let i=/([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(['"])((?:[^'"\\\n]|\\.)*)(?:\2)/g,u={},k;for(;k=i.exec(o);){let l=k[1],x=k[3],b=s(l);u[b]=x;}let c=Object.keys(u);if(c.length===0)return o;let d=typeof u.timestamps=="string"&&u.timestamps.length>0,I=c.filter(l=>l.startsWith("start_page")),f=[];u.attachment_id&&f.push("attachment_id"),d?(u.full_phrase&&f.push("full_phrase"),u.key_span&&f.push("key_span"),f.push("timestamps")):(I.includes("start_page_key")&&f.push("start_page_key"),I.filter(l=>l!=="start_page_key").sort().forEach(l=>f.push(l)),u.full_phrase&&f.push("full_phrase"),u.key_span&&f.push("key_span"),u.line_ids&&f.push("line_ids")),u.reasoning&&f.push("reasoning"),u.value&&f.push("value");let C=new Set(f);return c.filter(l=>!C.has(l)).sort().forEach(l=>f.push(l)),`<cite ${f.map(l=>`${l}='${u[l]}'`).join(" ")} />`};return e=e.replace(/<cite\b[\s\S]*?\/>/gm,o=>h(o)),e};function ft(...t){return t.filter(Boolean).join(" ")}function X(t){return t.type==="url"||typeof t.url=="string"&&t.url.length>0}function S(t){let e=t.pageNumber||L(t.startPageKey),s=[t.attachmentId||"",e?.toString()||"",t.fullPhrase||"",t.keySpan?.toString()||"",t.lineIds?.join(",")||"",t.timestamps?.startTime||"",t.timestamps?.endTime||""];return X(t)&&s.push(t.url||"",t.title||"",t.domain||""),R(s.join("|")).slice(0,16)}function gt(t){let e=[t.attachmentId||"",t.label||"",t.verifiedFullPhrase||"",t.verifiedKeySpan||"",t.verifiedLineIds?.join(",")||"",t.verifiedPageNumber?.toString()||"",t.verifiedTimestamps?.startTime||"",t.verifiedTimestamps?.endTime||"",t.verifiedMatchSnippet||"",t.hitIndexWithinPage?.toString()||""];return R(e.join("|")).slice(0,16)}function dt(t){let e=Math.random().toString(36).slice(2,11);return `${t}-${e}`}function mt(t,e={}){let{fallbackDisplay:s}=e;return t.keySpan?.toString()||t.citationNumber?.toString()||s||"1"}function ht(t){return t.citationNumber?.toString()||"1"}function yt(t){return t.keySpan?.toString()||""}function _t(...t){return t.filter(Boolean).join(" ")}var xt=4,Ct=1;export{R as a,ft as b,X as c,S as d,gt as e,dt as f,mt as g,ht as h,yt as i,_t as j,xt as k,Ct as l,H as m,q as n,at as o,ot as p,ct as q,L as r,E as s,O as t,B as u,tt as v,et as w,nt as x};
|