opencode-annotate-it 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 opencode-annotate-it contributors
4
+ Fork of dsh-annotate-it (https://github.com/walorne/dsh-annotate-it),
5
+ itself a fork of dsh-quote-reply (MIT, github.com/gf691271/dsh-quote-reply).
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,81 @@
1
- # Temporary Holding Version
1
+ # Annotate it (OpenCode)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Плагин для OpenCode Desktop: **разметка и ревью** прямо в чате и в документах из правой панели.
4
+ Порт [dsh-annotate-it](https://github.com/walorne/dsh-annotate-it) (MIT) для DeepSeek Harness.
5
+
6
+ Выделил фрагмент → быстрый ответ (Да / Нет / Докажи / Что-то ещё? / Подумать) или свой комментарий
7
+ (текстом или диктовкой) → цитата встаёт в очередь композера → `Enter` отправляет всё ревью одним сообщением.
8
+
9
+ ## Что умеет
10
+
11
+ - Два режима на каждую сессию: **ожидание** (кнопка «Рецензировать» над композером, встроенное
12
+ цитирование OpenCode не трогается) и **рецензирование** (быстрая панель на выделении, подсветка,
13
+ карточки заметок). Переключение: кнопка, `⌘⇧A` / `Ctrl+Shift+A`, команда `/annotate`.
14
+ - Аннотирование текста в **чате**, в **документах** правой панели (markdown, код, CSV, mermaid,
15
+ diff-просмотр), в **терминале** (выделил → `⌘C` → панель) и в **браузер-панели** (выделение
16
+ подхватывается автоматически).
17
+ - Быстрые ответы + свой комментарий; словарь редактируется прямо из панели
18
+ (правый клик по чипу → изменить/удалить, «+» — добавить).
19
+ - Оранжевая подсветка отмеченных фрагментов: ярче — неотправленные, бледнее — отправленные.
20
+ Карточка с историей комментариев при наведении, добавление комментариев и удаление заметки.
21
+ - Очередь цитат — нативные чипы композера OpenCode; отправка одним сообщением — нативная.
22
+ - Диктовка (Web Speech API) в поле комментария; где распознавания нет — подсказка про системную
23
+ диктовку (macOS: 2×Fn).
24
+ - Заметки, режим и словарь хранятся локально (сторы плагина), никуда не отправляются.
25
+
26
+ ## Отличия от версии для DeepSeek Harness
27
+
28
+ - PDF и Office в правой панели OpenCode рендерятся в изолированном фрейме — выделить текст там
29
+ нельзя; аннотируются markdown/код/таблицы/diff.
30
+ - Терминал — canvas (ghostty): выделение не видно из DOM, поэтому триггером служит копирование
31
+ (`⌘C`): скопированный текст сразу предлагается для аннотации.
32
+ - Браузер-панель опрашивается main-процессом раз в 400мс; подсветка заметок внутри страницы
33
+ невозможна (изолированный webview), но цитата с URL источника сохраняется.
34
+ - Лента ревью — нативные чипы композера (с именем источника у каждой цитаты), а не отдельная
35
+ лента над полем ввода.
36
+ - Если удалить чип цитаты вручную (крестиком на чипе), заметка в подсветке остаётся, пока её не
37
+ удалить через карточку или «Очистить всё».
38
+
39
+ ## Установка
40
+
41
+ Из npm (рекомендуется):
42
+
43
+ ```sh
44
+ opencode plugin add opencode-annotate-it
45
+ ```
46
+
47
+ Или в `~/.config/opencode/opencode.jsonc`:
48
+
49
+ ```jsonc
50
+ {
51
+ "plugins": ["opencode-annotate-it@^0.1.0"]
52
+ }
53
+ ```
54
+
55
+ Исходники: https://github.com/walorne/opencode-annotate-it
56
+
57
+ ## Настройки
58
+
59
+ Settings → Annotate it: карандашик при выделении, подсветка, словарь быстрых
60
+ ответов, горячие клавиши (`⌘⇧A` — режим рецензирования; переназначается в
61
+ Settings → Shortcuts).
62
+
63
+ ## Разработка
64
+
65
+ ```sh
66
+ npm install
67
+ npm run build # или npm run watch — пересборка перезагружает GUI во всех окнах
68
+ npx tsc --noEmit
69
+ ```
70
+
71
+ GUI-часть (`./gui-experimental`) собирается Vite-пресетом `@opencode/plugin/gui/vite` в один
72
+ CommonJS-файл. Целевая версия SDK — 2.3.x (OpenCode Desktop 2.3.0).
73
+
74
+ ## Публикация новой версии
75
+
76
+ 1. `npm version patch` (или minor/major).
77
+ 2. `zsh scripts/publish.sh` — скрипт публикует с токеном из `~/.npm-publish-token`,
78
+ сам открывает браузер для подтверждения passkey и ждёт его.
79
+ 3. `git push origin main --tags`.
80
+
81
+ Пользователи с `opencode-annotate-it@^0.1.0` получат обновление автоматически.
@@ -0,0 +1,33 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("solid-js/web"),C=require("solid-js"),P=require("@opencode/plugin/gui"),g=require("effect"),$t=P.Ipc.define({id:"opencode-annotate-it.browserSelection",methods:{},events:{selection:g.Schema.Struct({text:g.Schema.String,url:g.Schema.String,title:g.Schema.String,pressing:g.Schema.Boolean,rect:g.Schema.Struct({top:g.Schema.Number,left:g.Schema.Number,right:g.Schema.Number,bottom:g.Schema.Number})}),clear:g.Schema.Struct({})}}),oe=g.Schema.Struct({id:g.Schema.String,label:g.Schema.String,text:g.Schema.String}),ae=g.Schema.Struct({partID:g.Schema.String,revealID:g.Schema.String,body:g.Schema.optional(g.Schema.String),start:g.Schema.Number,end:g.Schema.Number,text:g.Schema.String}),Et=g.Schema.Struct({path:g.Schema.String,text:g.Schema.String,prefix:g.Schema.String,suffix:g.Schema.String}),se=g.Schema.Union([g.Schema.Struct({kind:g.Schema.Literal("chat")}),g.Schema.Struct({kind:g.Schema.Literal("document"),path:g.Schema.String}),g.Schema.Struct({kind:g.Schema.Literal("terminal")}),g.Schema.Struct({kind:g.Schema.Literal("browser"),url:g.Schema.String,title:g.Schema.optional(g.Schema.String)})]),ce=g.Schema.Struct({text:g.Schema.String,sent:g.Schema.Boolean}),le=g.Schema.Struct({id:g.Schema.String,quote:g.Schema.String,source:se,chat:g.Schema.optional(g.Schema.Array(ae)),doc:g.Schema.optional(Et),textAnchor:g.Schema.optional(Et),comments:g.Schema.Array(ce),created:g.Schema.Number}),de=P.Plugin.define({stores:{prefs:P.Store.global(g.Schema.Struct({actions:g.Schema.NullOr(g.Schema.Array(oe)),pencil:g.Schema.optional(g.Schema.Boolean),highlights:g.Schema.optional(g.Schema.Boolean),accent:g.Schema.optional(g.Schema.String)}),{actions:null}),mode:P.Store.session(g.Schema.Struct({reviewing:g.Schema.Boolean}),{reviewing:!1}),notes:P.Store.session(g.Schema.Struct({list:g.Schema.Array(le)}),{list:[]})},i18n:{en:{title:"Annotate it","panel.title":"Review","command.toggle":"Toggle annotation review","command.clear":"Clear all annotations","settings.description":"Review passages in the chat and in right-panel documents: quick replies, notes, highlights.","settings.behavior":"Behavior","settings.pencil":"Pencil button on selection","settings.pencil.description":"Show the small review button when text is selected in standby mode.","settings.highlights":"Highlight annotations","settings.highlights.description":"Mark annotated passages in the text; brighter while not sent.","settings.accent":"Highlight color","settings.accent.description":"The accent for highlights, the send button and marks. The panel itself follows the app theme.","settings.actions":"Quick replies","settings.actions.description":"The chips offered on a selection. Right-click a chip in the panel to edit it there too.","settings.action.add":"Add reply","settings.action.new":"New reply","settings.action.reset":"Reset to defaults","settings.action.delete":"Delete reply","settings.keys":"Shortcuts","settings.keys.description":"Rebind them in Settings → Shortcuts.","settings.keys.toggle":"Toggle review mode","settings.keys.clear":"Clear all annotations","pill.enter":"Review","pill.exit":"Exit review","pill.clear":"Clear all","pill.clearTitle":"Delete all notes and comments","pill.count":"{count} notes","source.chat":"Chat","source.document":"Document: {path}","source.terminal":"Terminal","source.browser":"Browser: {host}","subject.chat":"the session timeline","subject.document":"the file {path}","subject.terminal":"the terminal","subject.browser":"the page {url}","bar.custom":"Custom reply","bar.quote":"Quote","bar.addAction":"Add action","card.placeholder":"Comment on this passage…","card.hint":"Enter to add · Shift+Enter for newline · Esc to cancel","card.add":"Add","card.cancel":"Cancel","field.clear":"Clear field","hover.comments":"Comments","hover.empty":"No comments yet","hover.addPlaceholder":"Another comment…","hover.delete":"Delete note","hover.sent":"sent","hover.pending":"not sent","menu.edit":"Edit","menu.delete":"Delete","menu.deleteConfirm":"Delete this action?","menu.deleteSure":"Sure?","editor.title":"Quick action","editor.label":"Button label","editor.phrase":"Inserted phrase","editor.save":"Save","editor.cancel":"Cancel","clear.title":"Delete all notes and comments?","clear.confirm":"Delete all","clear.cancel":"Cancel",dictate:"Dictate (microphone)",dictateUnavailable:"Speech input unavailable here — use the system dictation (macOS: 2×Fn)","toast.unquotable":"The composer cannot take quotes right now","toast.noSession":"Open a session to annotate","action.yes.label":"Yes","action.yes.text":"Yes","action.no.label":"No","action.no.text":"No","action.prove.label":"Prove it","action.prove.text":"Prove it","action.more.label":"What else?","action.more.text":"What else?","action.think.label":"Think it over","action.think.text":"Need to think about the task."},ru:{title:"Annotate it","panel.title":"Рецензирование","command.toggle":"Режим рецензирования аннотаций","command.clear":"Очистить все аннотации","settings.description":"Ревью фрагментов в чате и документах правой панели: быстрые ответы, заметки, подсветка.","settings.behavior":"Поведение","settings.pencil":"Карандашик при выделении","settings.pencil.description":"Показывать маленькую кнопку рецензирования при выделении текста в режиме ожидания.","settings.highlights":"Подсветка аннотаций","settings.highlights.description":"Отмечать аннотированные фрагменты в тексте; ярче — пока не отправлено.","settings.accent":"Цвет выделения","settings.accent.description":"Акцент подсветки, кнопки отправки и меток. Сама панель следует теме приложения.","settings.actions":"Быстрые ответы","settings.actions.description":"Чипы, предлагаемые при выделении. В панели их тоже можно менять правым кликом.","settings.action.add":"Добавить ответ","settings.action.new":"Новый ответ","settings.action.reset":"Сбросить к стандартным","settings.action.delete":"Удалить ответ","settings.keys":"Горячие клавиши","settings.keys.description":"Переназначаются в Settings → Shortcuts.","settings.keys.toggle":"Переключить режим рецензирования","settings.keys.clear":"Очистить все аннотации","pill.enter":"Рецензировать","pill.exit":"Выйти из рецензирования","pill.clear":"Очистить всё","pill.clearTitle":"Удалить все заметки и комментарии","pill.count":"заметок: {count}","source.chat":"Чат","source.document":"Документ: {path}","source.terminal":"Терминал","source.browser":"Браузер: {host}","subject.chat":"the session timeline","subject.document":"the file {path}","subject.terminal":"the terminal","subject.browser":"the page {url}","bar.custom":"Свой ответ","bar.quote":"Цитата","bar.addAction":"Добавить действие","card.placeholder":"Комментарий к фрагменту…","card.hint":"Enter — добавить · Shift+Enter — новая строка · Esc — отмена","card.add":"Добавить","card.cancel":"Отмена","field.clear":"Очистить поле","hover.comments":"Комментарии","hover.empty":"Комментариев пока нет","hover.addPlaceholder":"Ещё один комментарий…","hover.delete":"Удалить заметку","hover.sent":"отправлено","hover.pending":"не отправлено","menu.edit":"Изменить","menu.delete":"Удалить","menu.deleteConfirm":"Удалить это действие?","menu.deleteSure":"Точно?","editor.title":"Быстрое действие","editor.label":"Надпись на кнопке","editor.phrase":"Фраза для вставки","editor.save":"Сохранить","editor.cancel":"Отмена","clear.title":"Удалить все заметки и комментарии?","clear.confirm":"Удалить всё","clear.cancel":"Отмена",dictate:"Диктовка (микрофон)",dictateUnavailable:"Здесь нет распознавания речи — используйте системную диктовку (macOS: 2×Fn)","toast.unquotable":"Композер сейчас не принимает цитаты","toast.noSession":"Откройте сессию, чтобы аннотировать","action.yes.label":"Да","action.yes.text":"Да","action.no.label":"Нет","action.no.text":"Нет","action.prove.label":"Докажи","action.prove.text":"Докажи","action.more.label":"Что-то ещё?","action.more.text":"Что-то ещё?","action.think.label":"Подумать","action.think.text":"Надо подумать над задачей."},zh:{title:"Annotate it","panel.title":"批注","command.toggle":"切换批注模式","command.clear":"清除所有批注","settings.description":"在聊天和右侧文档中审阅片段:快速回复、笔记、高亮。","settings.behavior":"行为","settings.pencil":"选中时显示铅笔按钮","settings.pencil.description":"待机模式下选中文本时显示小审阅按钮。","settings.highlights":"高亮批注","settings.highlights.description":"在文本中标记已批注片段;未发送时更亮。","settings.accent":"高亮颜色","settings.accent.description":"高亮、发送按钮和标记的强调色。面板本身跟随应用主题。","settings.actions":"快速回复","settings.actions.description":"选中时提供的快捷 chips。也可在面板中右键编辑。","settings.action.add":"添加回复","settings.action.new":"新回复","settings.action.reset":"恢复默认","settings.action.delete":"删除回复","settings.keys":"快捷键","settings.keys.description":"在 Settings → Shortcuts 中重新绑定。","settings.keys.toggle":"切换批注模式","settings.keys.clear":"清除所有批注","pill.enter":"批注","pill.exit":"退出批注","pill.clear":"全部清除","pill.clearTitle":"删除所有批注和评论","pill.count":"{count} 条批注","source.chat":"聊天","source.document":"文档:{path}","source.terminal":"终端","source.browser":"浏览器:{host}","subject.chat":"the session timeline","subject.document":"the file {path}","subject.terminal":"the terminal","subject.browser":"the page {url}","bar.custom":"自定义回复","bar.quote":"引用","bar.addAction":"添加动作","card.placeholder":"对此段落写下批注…","card.hint":"Enter 添加 · Shift+Enter 换行 · Esc 取消","card.add":"加入","card.cancel":"取消","field.clear":"清空输入框","hover.comments":"批注","hover.empty":"还没有批注","hover.addPlaceholder":"再写一条批注…","hover.delete":"删除批注","hover.sent":"已发送","hover.pending":"未发送","menu.edit":"编辑","menu.delete":"删除","menu.deleteConfirm":"删除这个动作?","menu.deleteSure":"确定删除?","editor.title":"快速动作","editor.label":"按钮文字","editor.phrase":"插入的短语","editor.save":"保存","editor.cancel":"取消","clear.title":"删除所有批注和评论?","clear.confirm":"全部删除","clear.cancel":"取消",dictate:"语音输入",dictateUnavailable:"此客户端不支持语音输入 — 请使用系统听写","toast.unquotable":"输入框当前无法接受引用","toast.noSession":"请先打开一个会话","action.yes.label":"是","action.yes.text":"是","action.no.label":"不是","action.no.text":"不是","action.prove.label":"证明一下","action.prove.text":"证明一下","action.more.label":"还有别的吗?","action.more.text":"还有别的吗?","action.think.label":"再想想","action.think.text":"需要再想想这个任务。"}}}),ue='[data-timeline="next"]',it='[data-slot="session-timeline-scroll"]',B="[data-annotate-it]",Pt='textarea, input, select, [contenteditable="true"], [contenteditable=""], [role="textbox"]';function ut(t){return String(t).replace(/\r\n?/g,`
2
+ `).replace(/^[ \t]*[│▌>][ \t]*/gm,"").replace(/[ \t]+\n/g,`
3
+ `).replace(/\n{3,}/g,`
4
+
5
+ `).trim()}function he(t){const e=Array.from(t.getClientRects()).filter(c=>c.width>0&&c.height>0);if(e.length===0){const c=t.getBoundingClientRect();c.width>0&&c.height>0&&e.push(c)}return e}function pe(t){const e=he(t);if(e.length===0)return null;let c=1/0,p=1/0,l=-1/0,a=-1/0,s=1/0;for(const i of e)c=Math.min(c,i.top),p=Math.min(p,i.left),l=Math.max(l,i.right),a=Math.max(a,i.bottom),s=Math.min(s,i.top);const r=e.filter(i=>Math.abs(i.top-s)<=4);return{rect:{top:c,left:p,right:l,bottom:a},line:{top:s,left:Math.min(...r.map(i=>i.left)),right:Math.max(...r.map(i=>i.right)),bottom:Math.max(...r.map(i=>i.bottom))}}}function Dt(t){const e=t.closest("[data-pane-content]");if(!e)return null;const c=e.getAttribute("data-pane-content"),a=(c?e.querySelector(`[data-pane-strip="${CSS.escape(c)}"]`):e.querySelector("[data-pane-strip]"))?.querySelector('[role="tab"][aria-selected="true"]')?.closest("[data-pane-tab]")?.getAttribute("data-pane-tab")??"";if(!a.startsWith("file://"))return null;const r=a.slice(7).split("/").filter(i=>i!=="");if(r.length===0)return null;try{return"/"+r.map(decodeURIComponent).join("/")}catch{return null}}function Tt(t){let e=t&&t.nodeType===1?t:t?.parentElement??null;for(;e;){const c=e.getRootNode();if(c instanceof ShadowRoot){e=c.host instanceof Element?c.host:null;continue}return e}return null}function me(){let t;try{t=window.getSelection()}catch{return null}if(!t||t.rangeCount===0||t.isCollapsed)return null;let e=t.getRangeAt(0),c=t.toString();if(!c.trim()&&"getComposedRanges"in Selection.prototype){const i=[];for(const v of[t.anchorNode,t.focusNode]){const S=v?.getRootNode();S instanceof ShadowRoot&&i.push(S)}const h=Tt(e.commonAncestorContainer)?.querySelectorAll("diffs-container")??[];for(const v of Array.from(h))v.shadowRoot&&i.push(v.shadowRoot);const d=t.getComposedRanges({shadowRoots:i})[0];if(d&&!d.collapsed)try{const v=document.createRange();v.setStart(d.startContainer,d.startOffset),v.setEnd(d.endContainer,d.endOffset);const S=v.toString();S.trim()&&(e=v,c=S)}catch{}}const p=Tt(e.commonAncestorContainer);if(!p||!p.closest||p.closest(B)||p.closest(Pt)&&!p.closest('[aria-label="Terminal input"]'))return null;const l=(()=>{if(p.closest(ue))return!0;const i=document.querySelector(it);return!!i&&(i.contains(p)||e.intersectsNode(i))})();let a;if(l)a={kind:"chat"};else{const h=p.closest("[data-pane-content]")?Dt(p):null;if(!h)return null;a={kind:"document",path:h}}const s=ut(c);if(!s)return null;const r=pe(e);return r?{text:s,rect:r.rect,line:r.line,range:e.cloneRange(),source:a}:null}function ge(t,e){const c=rt(e);if(!c)return null;const p=t.toString();if(!p.trim())return null;const l=t.getBoundingClientRect();let a=-1,s=c.text.indexOf(p);for(;s>=0;){const r=ot(c,s,s+p.length);if(a<0&&(a=s),r){const i=r.getBoundingClientRect();if(Math.abs(i.top-l.top)<2&&Math.abs(i.left-l.left)<2){a=s;break}}s=c.text.indexOf(p,s+1)}return a<0?null:{path:"",text:p,prefix:c.text.slice(Math.max(0,a-40),a),suffix:c.text.slice(a+p.length,a+p.length+40)}}function fe(t,e){const c=rt(t);if(!c)return null;const p=[];let l=c.text.indexOf(e.text);for(;l>=0&&p.length<30;)p.push(l),l=c.text.indexOf(e.text,l+1);if(p.length===0)return null;let a=p[0];for(const s of p){const r=c.text.slice(Math.max(0,s-40),s),i=c.text.slice(s+e.text.length,s+e.text.length+40);if((!e.prefix||r.endsWith(e.prefix))&&(!e.suffix||i.startsWith(e.suffix))){a=s;break}}return ot(c,a,a+e.text.length)}function rt(t){let e="";const c=[],p=l=>{const a=document.createTreeWalker(l,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode(r){if(r instanceof Element)return r.parentElement?.closest(B)||r instanceof HTMLElement&&/^(TEXTAREA|INPUT|SELECT)$/.test(r.tagName)?NodeFilter.FILTER_REJECT:r.shadowRoot?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const i=r.parentElement;return!i||i.closest(`${B}, ${Pt}`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let s;for(;s=a.nextNode();)if(s instanceof Text){const r=s.nodeValue??"";r!==""&&(c.push({node:s,start:e.length,end:e.length+r.length}),e+=r)}else s instanceof Element&&s.shadowRoot&&p(s.shadowRoot)};return p(t),e===""?null:{root:t,text:e,segments:c}}function ot(t,e,c){const p=s=>{for(const r of t.segments)if(s>=r.start&&s<=r.end)return{node:r.node,offset:Math.max(0,Math.min(s-r.start,r.node.nodeValue?.length??0))};return null},l=p(e),a=p(c);if(!l||!a)return null;try{const s=document.createRange();return s.setStart(l.node,l.offset),s.setEnd(a.node,a.offset),s}catch{return null}}function ve(t){const e=[],c=new Map,p=t.commonAncestorContainer,l=document.createTreeWalker(p,NodeFilter.SHOW_TEXT,{acceptNode(s){return t.intersectsNode(s)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let a;for(;a=l.nextNode();){if(!(a instanceof Text))continue;const s=a.parentElement;if(!s||s.closest(B))continue;const r=s.closest("[data-timeline-part-id]"),i=r?.getAttribute("data-timeline-part-id"),h=r?.closest("[data-message-id]")?.getAttribute("data-message-id");if(!r||!i||!h)continue;const d=s.closest('[data-slot="text-part-body"], [data-slot="user-message-text"]'),v=d??r;let S=c.get(v);if(!S){S=new Map;let $=0;const A=document.createTreeWalker(v,NodeFilter.SHOW_TEXT);let b;for(;b=A.nextNode();){const _=b;S.set(_,$),$+=_.nodeValue?.length??0}c.set(v,S)}const E=S.get(a);if(E===void 0)continue;const T=a===t.startContainer?t.startOffset:0,x=a===t.endContainer?t.endOffset:a.nodeValue?.length??0;if(x<=T)continue;const L={partID:i,revealID:h,body:d?`[data-slot="${d.getAttribute("data-slot")}"]`:void 0,start:E+T,end:E+x,text:(a.nodeValue??"").slice(T,x)},u=e.at(-1);if(u&&u.partID===L.partID&&u.body===L.body&&u.end===L.start){u.end=L.end,u.text+=L.text;continue}e.push(L)}return e}function be(t,e){const c=t.querySelector(`[data-timeline-part-id="${CSS.escape(e.partID)}"]`);if(!c)return null;const p=e.body?c.querySelector(e.body):c;if(!p)return null;const l=[];let a=0;const s=document.createTreeWalker(p,NodeFilter.SHOW_TEXT);let r;for(;r=s.nextNode();){const d=r;l.push({node:d,start:a,end:a+(d.nodeValue?.length??0)}),a+=d.nodeValue?.length??0}const i=l.find(d=>d.start<=e.start&&d.end>e.start),h=l.find(d=>d.start<e.end&&d.end>=e.end);if(!i||!h)return null;try{const d=document.createRange();return d.setStart(i.node,e.start-i.start),d.setEnd(h.node,e.end-h.start),d.toString()===e.text?d:null}catch{return null}}function xe(t){return t.closest("[data-pane-content]")}function we(t,e){const c=t.commonAncestorContainer.nodeType===1?t.commonAncestorContainer:t.commonAncestorContainer.parentElement,p=c?xe(c):null;if(!p)return null;const l=rt(p);if(!l)return null;const a=t.toString();if(!a)return null;const s=t.getBoundingClientRect();let r=-1,i=l.text.indexOf(a);for(;i>=0;){const h=ot(l,i,i+a.length);if(r<0&&(r=i),h){const d=h.getBoundingClientRect();if(Math.abs(d.top-s.top)<2&&Math.abs(d.left-s.left)<2){r=i;break}}i=l.text.indexOf(a,i+1)}return r<0?null:{path:e,text:a,prefix:l.text.slice(Math.max(0,r-40),r),suffix:l.text.slice(r+a.length,r+a.length+40)}}function Se(t){const e=document.querySelectorAll("[data-pane-content]");for(const c of Array.from(e)){if(!(c.querySelector('[role="tab"][aria-selected="true"]')?.closest("[data-pane-tab]")?.getAttribute("data-pane-tab")??"").startsWith("file://")||Dt(c)!==t.path)continue;const s=rt(c);if(!s)continue;const r=[];let i=s.text.indexOf(t.text);for(;i>=0&&r.length<30;)r.push(i),i=s.text.indexOf(t.text,i+1);if(r.length===0)continue;let h=r[0];for(const d of r){const v=s.text.slice(Math.max(0,d-40),d),S=s.text.slice(d+t.text.length,d+t.text.length+40);if((!t.prefix||v.endsWith(t.prefix))&&(!t.suffix||S.startsWith(t.suffix))){h=d;break}}return ot(s,h,h+t.text.length)}return null}const st="annotate-it-pending",ct="annotate-it-sent",lt="annotate-it-hover",dt="annotate-it-selection";function At(){return typeof Highlight=="function"&&typeof CSS<"u"&&!!CSS.highlights}function ye(t){const[e,c]=C.createSignal(null),[p,l]=C.createSignal(!1),[a,s]=C.createSignal(null),[r,i]=C.createSignal(null),[h,d]=C.createSignal(null),[v,S]=C.createSignal(""),[E,T]=C.createSignal(""),[x,L]=C.createSignal(0),u=new Map;let $=0,A,b,_,M=!1,X=0,O;const N=()=>t.sessions.current(),j=()=>{const o=N();return o?t.stores.mode(o)?.value?.reviewing??!1:!1},q=()=>{const o=N();return o?t.stores.notes(o)?.value?.list??[]:[]},F=o=>{const m=N();if(!m)return;const f=t.stores.notes(m);f&&(f.update(y=>{y.list=o(y.list)}),U())},Q=o=>{const m=N();m&&(t.stores.mode(m)?.update(f=>{f.reviewing=o}),o||(c(null),l(!1),s(null),i(null),Y()),V())},V=()=>{document.documentElement.classList.toggle("annotate-it-review",j())},W=()=>["yes","no","prove","more","think"].map(o=>({id:`default-${o}`,label:t.t(`action.${o}.label`),text:t.t(`action.${o}.text`)})),Ht=()=>{const o=t.stores.prefs.value.actions;if(o!==null)return o;const m=W();return t.stores.prefs.update(f=>{f.actions=m}),m},zt=(o,m,f)=>{const y=f.trim();if(!y)return;const k=m.trim()||y;t.stores.prefs.update(w=>{const R=w.actions??W();w.actions=o?R.map(D=>D.id===o?{...D,label:k,text:y}:D):[...R,{id:`user-${Date.now()}`,label:k,text:y}]}),i(null),s(null)},Ot=o=>{t.stores.prefs.update(m=>{m.actions=(m.actions??W()).filter(f=>f.id!==o)}),s(null),i(null)},Ft=()=>{t.stores.prefs.update(o=>{o.actions=W()})},Bt=()=>t.stores.prefs.value.pencil??!0,pt=()=>t.stores.prefs.value.highlights??!0,jt=()=>t.stores.prefs.value.accent??"#d97757",Wt=(o,m)=>{t.stores.prefs.update(f=>{f[o]=m}),o==="highlights"&&U()},Ut=o=>{t.stores.prefs.update(m=>{m.accent=o}),U()},Z=()=>t.screen.current()?.composer,mt=o=>{switch(o.kind){case"document":return t.t("source.document",{path:o.path});case"terminal":return t.t("source.terminal");case"browser":{let m=o.url;try{m=new URL(o.url).host}catch{}return t.t("source.browser",{host:m})}default:return t.t("source.chat")}},Gt=o=>{switch(o.kind){case"document":return t.t("subject.document",{path:o.path});case"terminal":return t.t("subject.terminal");case"browser":return t.t("subject.browser",{url:o.url});default:return t.t("subject.chat")}},Vt=o=>o.kind==="browser"?"globe":o.kind==="terminal"?"terminal":"outline-quote",J=(o,m,f,y,k)=>{const w=Z();if(!w||!w.quotable())return t.toast.show({variant:"error",title:t.t("toast.unquotable")}),!1;const R=crypto.randomUUID(),D=f.kind==="chat"&&y?ve(y):void 0,H=f.kind==="document"&&y?we(y,f.path):void 0,et=f.kind==="chat"&&y&&(!D||D.length===0)?(()=>{const nt=document.querySelector(it);return nt?ge(y,nt):null})():void 0;w.attach({type:"quote",commentID:R,text:o,...m?{comment:m}:{},source:{label:mt(f),icon:Vt(f),subject:Gt(f)}}),F(nt=>[...nt,{id:R,quote:o,source:f,...D&&D.length?{chat:D}:{},...H?{doc:H}:{},...et?{textAnchor:et}:{},comments:m?[{text:m,sent:!1}]:[],created:Date.now()}]),$=Date.now()+450,Y();try{window.getSelection()?.removeAllRanges()}catch{}return c(null),l(!1),T(""),k||w.focus(),!0},Xt=o=>{const m=e();m&&J(m.text,o.text,m.source,m.range,!1)},Zt=()=>{const o=e();if(!o)return;const m=o.line,f=Z();if(!J(o.text,"",o.source,o.range,!0)||!f)return;const k=q().at(-1);k&&f.focus(k.id,{anchor:w=>{const R=w.width,D=Math.min(Math.max(m.left+(m.right-m.left)/2-R/2,8),window.innerWidth-R-8);return{top:Math.max(m.top-w.height-8,8),left:D}}})},at=o=>{const m=e(),f=o.trim();return!m||!f?!1:J(m.text,f,m.source,m.range,!1)},Yt=(o,m)=>{const f=m.trim();if(!f)return;const y=q().find(w=>w.id===o);if(!y)return;if(y.comments.some(w=>!w.sent))Z()?.update(o,{comment:[...y.comments.filter(w=>!w.sent).map(w=>w.text),f].join(`
6
+
7
+ `)}),F(w=>w.map(R=>R.id===o?{...R,comments:[...R.comments,{text:f,sent:!1}]}:R));else{const w=u.get(o)?.[0]??null;J(y.quote,f,y.source,w,!1)}S(""),$=Date.now()+450},Qt=o=>{const m=q().find(f=>f.id===o);m&&(m.comments.some(f=>!f.sent)&&Z()?.detach(o),F(f=>f.filter(y=>y.id!==o)),u.delete(o),Y())},Jt=async()=>{if(await t.dialogs.confirm({title:t.t("clear.title"),confirm:t.t("clear.confirm"),cancel:t.t("clear.cancel"),danger:!0})){for(const m of q())m.comments.some(f=>!f.sent)&&Z()?.detach(m.id);F(()=>[]),u.clear(),Y()}},Kt=()=>q().filter(o=>o.comments.some(m=>!m.sent)).length,te=(o,m)=>{const f=N();if(!f||f.id!==o)return;const y=q().filter(w=>w.comments.some(R=>!R.sent));if(y.length===0)return;const k=[];for(const w of y){const R=w.quote.split(`
8
+ `).map(D=>D.trim()===""?">":`> ${D}`).join(`
9
+ `);(m.includes(R)||m.includes(w.quote))&&k.push(w.id)}k.length!==0&&F(w=>w.map(R=>k.includes(R.id)?{...R,comments:R.comments.map(D=>({...D,sent:!0}))}:R))},U=()=>{L(o=>o+1)},ee=o=>{if(o.source.kind==="browser"||o.source.kind==="terminal")return[];if(o.source.kind==="document"){const y=o.doc?Se(o.doc):null;return y?[y]:[]}const m=document.querySelector(it);if(!m)return[];if(o.textAnchor){const y=fe(m,o.textAnchor);return y?[y]:[]}if(!o.chat)return[];const f=[];for(const y of o.chat){const k=be(m,y);k&&f.push(k)}return f},gt=()=>{if(!At())return;if(!pt()){try{CSS.highlights.delete(st),CSS.highlights.delete(ct),CSS.highlights.delete(lt),CSS.highlights.delete(dt)}catch{}return}const o=[],m=[],f=[],y=h()?.noteId;u.clear();for(const k of q()){const w=ee(k);if(w.length===0)continue;u.set(k.id,w);const R=k.comments.some(D=>!D.sent);k.id===y&&f.push(...w),R?o.push(...w):k.comments.length>0&&m.push(...w)}try{CSS.highlights.set(st,new Highlight(...o)),CSS.highlights.set(ct,new Highlight(...m)),CSS.highlights.set(lt,new Highlight(...f));const k=e(),w=k?.range&&k.range.startContainer.isConnected?[k.range]:[];CSS.highlights.set(dt,new Highlight(...w))}catch{}},K=()=>{O===void 0&&(O=requestAnimationFrame(()=>{O=void 0,gt()}))},Y=()=>{A&&clearTimeout(A),b&&clearTimeout(b),A=void 0,b=void 0,d(null),S("")},ft=(o,m)=>{for(const[f,y]of u)for(const k of y)if(k.startContainer.isConnected){for(const w of k.getClientRects())if(!(w.width===0||w.height===0)&&o>=w.left&&o<=w.right&&m>=w.top&&m<=w.bottom)return f}return null},vt=o=>{if(!j()||Date.now()<$)return;const m=o.target instanceof Element?o.target:null;if(m?.closest(B)){if(h()&&m?.closest('[data-annotate-it="hover-card"]')){b&&clearTimeout(b),b=void 0;return}return}const f=ft(o.clientX,o.clientY);if(!f){h()&&!b&&(b=setTimeout(()=>{b=void 0,d(null),S(""),U()},260));return}b&&(clearTimeout(b),b=void 0),h()?.noteId!==f&&(A&&clearTimeout(A),A=setTimeout(()=>{A=void 0,d({noteId:f,x:o.clientX,y:o.clientY}),S(""),U()},300))},tt=o=>!!o&&(o.source.kind==="browser"||o.source.kind==="terminal"),ne=o=>c(o),ie=()=>{tt(e())&&c(null)},re=()=>M,bt=o=>{const f=(o.target instanceof Element?o.target:null)?.closest('[id^="terminal-wrapper"]');if(!f)return;const y=ut(o.clipboardData?.getData("text/plain")??"");if(!y)return;const k=f.getBoundingClientRect();c({text:y,rect:{top:k.top,left:k.left,right:k.right,bottom:k.bottom},line:{top:k.top+6,left:k.left+6,right:k.left+220,bottom:k.top+24},range:null,source:{kind:"terminal"}})},xt=o=>{if(!j()||o.defaultPrevented||(o.target instanceof Element?o.target:null)?.closest(B)||!(window.getSelection()?.isCollapsed??!0))return;const f=ft(o.clientX,o.clientY);f&&(A&&clearTimeout(A),b&&clearTimeout(b),A=void 0,b=void 0,$=Date.now()+450,d({noteId:f,x:o.clientX,y:o.clientY}),S(""),U())},wt=()=>{if(M){c(null);return}const o=me();!o&&tt(e())||c(o)},St=()=>{if(window.getSelection()?.isCollapsed??!0){const m=document.activeElement;if(m instanceof Element&&m.closest(B)||Date.now()<X||tt(e()))return;if(e()&&E().trim()){at(E());return}c(null);return}_&&clearTimeout(_),_=setTimeout(()=>{_=void 0,wt()},150)},yt=o=>{if(o.button!==0)return;if((o.target instanceof Element?o.target:null)?.closest(B)){X=Date.now()+500,o.stopPropagation();return}e()&&E().trim()&&at(E()),tt(e())&&c(null),M=!0},I=()=>{M&&(M=!1,_&&clearTimeout(_),_=setTimeout(()=>{_=void 0,wt()},10))},kt=o=>{M&&(o.buttons&1)===0&&I()},Ct=()=>I();return{target:e,clearTarget:()=>c(null),setExternalTarget:ne,clearExternalTarget:ie,isPressing:re,cancelTarget:()=>{c(null),T("")},customOpen:p,setCustomOpen:l,customDraft:E,setCustomDraft:T,chipMenu:a,setChipMenu:s,editor:r,setEditor:i,hover:h,hoverDraft:v,setHoverDraft:S,paintTick:x,session:N,reviewing:j,setReviewing:Q,syncReviewClass:V,notes:q,actions:Ht,saveAction:zt,removeAction:Ot,resetActions:Ft,pencilEnabled:Bt,highlightsEnabled:pt,setPref:Wt,accent:jt,setAccent:Ut,quickReply:Xt,plainQuote:Zt,addCustom:at,addComment:Yt,removeNote:Qt,clearAll:Jt,pendingCount:Kt,trackSent:te,repaint:U,schedulePaint:K,closeHover:Y,start:()=>{document.addEventListener("selectionchange",St),document.addEventListener("pointerdown",yt,!0),document.addEventListener("pointerup",I,!0),document.addEventListener("pointercancel",I,!0),document.addEventListener("pointermove",kt,{capture:!0,passive:!0}),document.addEventListener("dragend",I,!0),document.addEventListener("contextmenu",I,!0),window.addEventListener("blur",Ct),document.addEventListener("mousemove",vt,{passive:!0}),document.addEventListener("click",xt),document.addEventListener("copy",bt);const o=new MutationObserver(()=>K());let m=[];const f=()=>{const w=[],R=document.querySelector(it);R&&w.push(R);for(const H of Array.from(document.querySelectorAll("[data-pane-content]")))w.push(H);if(!(w.length===m.length&&w.every((H,et)=>H===m[et]))){o.disconnect(),m=w;for(const H of w)o.observe(H,{childList:!0,subtree:!0,characterData:!0})}};f();const y=new MutationObserver(()=>{f(),K()});y.observe(document.body,{childList:!0,subtree:!0});const k=()=>K();return window.addEventListener("resize",k),document.addEventListener("scroll",k,{capture:!0,passive:!0}),V(),gt(),()=>{document.removeEventListener("selectionchange",St),document.removeEventListener("pointerdown",yt,!0),document.removeEventListener("pointerup",I,!0),document.removeEventListener("pointercancel",I,!0),document.removeEventListener("pointermove",kt,!0),document.removeEventListener("dragend",I,!0),document.removeEventListener("contextmenu",I,!0),window.removeEventListener("blur",Ct),document.removeEventListener("mousemove",vt),document.removeEventListener("click",xt),document.removeEventListener("copy",bt),o.disconnect(),y.disconnect(),window.removeEventListener("resize",k),document.removeEventListener("scroll",k,!0),_&&clearTimeout(_),A&&clearTimeout(A),b&&clearTimeout(b),O!==void 0&&cancelAnimationFrame(O),At()&&(CSS.highlights.delete(st),CSS.highlights.delete(ct),CSS.highlights.delete(lt),CSS.highlights.delete(dt)),document.documentElement.classList.remove("annotate-it-review")}},sourceLabel:mt}}var ke=n.template('<svg><path fill=currentColor d="M8.6 3.1v8.4H7.4V3.1L4.2 6.3 3.4 5.5 8 0.9l4.6 4.6-.8.8-3.2-3.2Z">'),Ce=n.template('<svg><path fill=currentColor d="M4.6 3.2C3 4 2.2 5.4 2.2 7c0 1.1.8 1.9 1.8 1.9.9 0 1.6-.6 1.6-1.5 0-.8-.6-1.4-1.4-1.4h-.2c.2-.7.8-1.3 1.6-1.8l-1-1Zm6.2 0C9.2 4 8.4 5.4 8.4 7c0 1.1.8 1.9 1.8 1.9.9 0 1.6-.6 1.6-1.5 0-.8-.6-1.4-1.4-1.4h-.2c.2-.7.8-1.3 1.6-1.8l-1-1Z">'),$e=n.template('<svg width=13 height=13 viewBox="0 0 16 16"aria-hidden=true fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round style=display:block><path d="M11.6 2.4a1.8 1.8 0 0 1 2.5 2.5l-8.3 8.3-3.5.9.9-3.5 8.4-8.2Z"></path><path d="m10.2 3.8 2 2">'),Ee=n.template('<svg width=12 height=12 viewBox="0 0 16 16"aria-hidden=true style=display:block><path fill=currentColor d="M8 6.9 4.9 3.8 3.8 4.9 6.9 8l-3.1 3.1 1.1 1.1L8 9.1l3.1 3.1 1.1-1.1L9.1 8l3.1-3.1-1.1-1.1L8 6.9Z">'),Te=n.template('<svg width=12 height=12 viewBox="0 0 16 16"aria-hidden=true style=display:block><path fill=currentColor d="M8 1a2.6 2.6 0 0 1 2.6 2.6v3.2A2.6 2.6 0 0 1 8 9.4 2.6 2.6 0 0 1 5.4 6.8V3.6A2.6 2.6 0 0 1 8 1Zm-1 2.6v3.2a1 1 0 0 0 2 0V3.6a1 1 0 0 0-2 0ZM3.5 7a.75.75 0 0 1 .75.75A3.75 3.75 0 0 0 8 11.5a3.75 3.75 0 0 0 3.75-3.75A.75.75 0 0 1 13.25 7 5.25 5.25 0 0 1 8.75 12.2V14h1.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5h1.5v-1.8A5.25 5.25 0 0 1 2.75 7 .75.75 0 0 1 3.5 7Z">'),Ae=n.template('<svg><path fill=currentColor d="M8 1a.85.85 0 0 1 .85.85v5.3a.85.85 0 0 1-1.7 0V1.85A.85.85 0 0 1 8 1Zm3.4 3.1a.85.85 0 0 1 1.05.4 6 6 0 1 1-8.9 0 .85.85 0 1 1 1.05.4 4.3 4.3 0 1 0 6.8 0 .85.85 0 0 1 0-.8Z">'),Mt=n.template("<button type=button>"),Re=n.template("<button type=button data-annotate-it=pencil class=ait-pencil>"),Le=n.template("<button type=button class=ait-tool>"),_e=n.template('<div data-annotate-it=review-panel class=ait-mini role=toolbar><div class=ait-mini-row><button type=button class="ait-qchip ait-qchip-add">+</button><button type=button class="ait-qchip ait-qchip-icon"></button><button type=button class="ait-qchip ait-qchip-icon ait-exit"></button></div><div class="ait-mini-row ait-mini-field"><input class=ait-mini-input><button type=button class=ait-sendicon>'),Pe=n.template("<button type=button class=ait-qchip><span class=ait-qchip-label>"),Rt=n.template("<button type=button class=ait-menu-item>"),Lt=n.template('<button type=button class="ait-menu-item ait-danger">'),De=n.template("<div data-annotate-it=chip-menu class=ait-menu>"),Me=n.template("<div class=ait-menu-label>"),qe=n.template('<div data-annotate-it=action-editor class="ait-card ait-editor"><div class=ait-card-title></div><label class=ait-field><span></span><input class=ait-input></label><label class=ait-field><span></span><input class=ait-input></label><div class=ait-card-footer><button type=button class="ait-btn ait-btn-ghost"></button><button type=button class=ait-btn>'),Ie=n.template("<div class=ait-comments>"),Ne=n.template('<div data-annotate-it=hover-card class="ait-card ait-hover"><div class=ait-quote-preview></div><div class=ait-source></div><div class=ait-card-title></div><div class=ait-card-row><input class="ait-mini-input ait-hover-input"><button type=button class=ait-sendicon></button></div><div class=ait-card-footer><button type=button class="ait-btn ait-btn-ghost ait-danger">'),He=n.template("<div class=ait-hint>"),ze=n.template("<div class=ait-comment><span class=ait-comment-text></span><span>"),Oe=n.template("<div class=ait-accent-picker><input type=color class=ait-color-input>"),Fe=n.template("<div class=ait-settings-actions>"),_t=n.template('<input class="ait-input ait-settings-input">');let qt;function Be(t){qt=t}const G=()=>qt,z=(t,e,c)=>Math.min(Math.max(t,e),Math.max(e,c));function je(t){const e=t.length;return e<=4?"12.5px":e<=7?"12px":e<=10?"11px":e<=14?"10.25px":"9.5px"}const ht={width:14,height:14,viewBox:"0 0 16 16","aria-hidden":"true"};function It(){return(()=>{var t=ke();return n.spread(t,n.mergeProps(ht,{style:{display:"block"}}),!0,!0),t})()}function We(){return(()=>{var t=Ce();return n.spread(t,n.mergeProps(ht,{style:{display:"block"}}),!0,!0),t})()}function Ue(){return $e()}function Ge(){return Ee()}function Ve(){return Te()}function Xe(){return(()=>{var t=Ae();return n.spread(t,n.mergeProps(ht,{style:{display:"block"}}),!0,!0),t})()}function Ze(t,e){const[c,p]=C.createSignal({width:0,height:0});return{ref:s=>{const r=new ResizeObserver(()=>p({width:s.offsetWidth,height:s.offsetHeight}));r.observe(s),C.onCleanup(()=>r.disconnect())},place:()=>{const s=t();if(!s)return;const r=c(),i=r.width||e.width,h=r.height||e.height,d=8,v=s.left+(s.right-s.left)/2,S=z(v-i/2,d,window.innerWidth-i-d);return{top:s.top-h-d>=d?s.top-h-d:Math.min(s.bottom+d,window.innerHeight-h-d),left:S,ready:r.width>0}}}}function Nt(t){const e=P.usePlugin(),[c,p]=C.createSignal(!1);let l;const a=window.SpeechRecognition||window.webkitSpeechRecognition,s=typeof a=="function";C.onCleanup(()=>{try{l?.stop()}catch{}});const r=()=>{if(!s)return;if(c()){try{l?.stop()}catch{}return}const i=new a;i.lang=document.documentElement.lang||"ru-RU",i.interimResults=!0,i.continuous=!1,i.onresult=h=>{let d="",v="";for(let T=h.resultIndex;T<h.results.length;T+=1){const x=h.results[T],L=x[0]?.transcript??"";x.isFinal?d+=L:v+=L}const S=t.value().trim(),E=(d||v).trim();E&&t.onText(S?`${S} ${E}`:E)},i.onend=()=>p(!1),i.onerror=()=>p(!1),l=i;try{i.start(),p(!0)}catch{p(!1)}};return(()=>{var i=Mt();return i.$$click=r,i.$$mousedown=h=>h.preventDefault(),n.insert(i,n.createComponent(Ve,{})),n.effect(h=>{var d=`ait-tool ait-mic${c()?" ait-mic-live":""}`,v=s?e.t("dictate"):e.t("dictateUnavailable"),S=e.t("dictate");return d!==h.e&&n.className(i,h.e=d),v!==h.t&&n.setAttribute(i,"title",h.t=v),S!==h.a&&n.setAttribute(i,"aria-label",h.a=S),h},{e:void 0,t:void 0,a:void 0}),i})()}function Ye(){const t=P.usePlugin(),e=G(),c=()=>{const p=e.target();if(!p||e.reviewing()||!e.pencilEnabled())return;const l=24;return{top:z(p.line.top-l-8,8,window.innerHeight-l-8),left:z(p.line.left-l-8,8,window.innerWidth-l-8)}};return n.createComponent(C.Show,{get when(){return c()},children:p=>(()=>{var l=Re();return l.$$click=()=>e.setReviewing(!0),l.$$mousedown=a=>a.preventDefault(),n.insert(l,n.createComponent(Ue,{})),n.effect(a=>{var s=t.t("pill.enter"),r=t.t("pill.enter"),i=`${p().top}px`,h=`${p().left}px`;return s!==a.e&&n.setAttribute(l,"title",a.e=s),r!==a.t&&n.setAttribute(l,"aria-label",a.t=r),i!==a.a&&n.setStyleProperty(l,"top",a.a=i),h!==a.o&&n.setStyleProperty(l,"left",a.o=h),a},{e:void 0,t:void 0,a:void 0,o:void 0}),l})()})}function Qe(){const t=P.usePlugin(),e=G();let c;const p=()=>{const r=e.target();return e.reviewing()&&r?r.line:void 0},{ref:l,place:a}=Ze(p,{width:320,height:64});C.createEffect(()=>{if(e.target()&&e.reviewing()&&!e.isPressing()){let r=0,i;const h=()=>{if(i=void 0,!c||!e.target()||!e.reviewing()||e.isPressing())return;c.focus({preventScroll:!0});const d=c.value.length;try{c.setSelectionRange(d,d)}catch{}document.activeElement!==c&&r++<8&&(i=setTimeout(h,40))};queueMicrotask(h),C.onCleanup(()=>{i&&clearTimeout(i)})}});const s=()=>{e.addCustom(e.customDraft())&&e.setCustomDraft("")};return n.createComponent(C.Show,{get when(){return n.memo(()=>!!p())()&&a()},children:r=>(()=>{var i=_e(),h=i.firstChild,d=h.firstChild,v=d.nextSibling,S=v.nextSibling,E=h.nextSibling,T=E.firstChild,x=T.nextSibling;i.$$mousedown=u=>u.stopPropagation(),n.use(l,i),n.insert(h,n.createComponent(C.For,{get each(){return e.actions()},children:u=>(()=>{var $=Pe(),A=$.firstChild;return $.$$contextmenu=b=>{b.preventDefault(),e.setChipMenu({actionId:u.id,x:b.clientX,y:b.clientY,confirming:!1})},$.$$click=()=>e.quickReply(u),$.$$mousedown=b=>b.preventDefault(),n.insert(A,()=>u.label),n.effect(b=>{var _=je(u.label),M=u.text;return _!==b.e&&n.setStyleProperty($,"font-size",b.e=_),M!==b.t&&n.setAttribute($,"title",b.t=M),b},{e:void 0,t:void 0}),$})()}),d),d.$$click=u=>e.setEditor({id:null,label:"",text:"",x:u.clientX,y:u.clientY}),d.$$mousedown=u=>u.preventDefault(),v.$$click=()=>e.plainQuote(),v.$$mousedown=u=>u.preventDefault(),n.insert(v,n.createComponent(We,{})),S.$$click=()=>e.setReviewing(!1),S.$$mousedown=u=>u.preventDefault(),n.insert(S,n.createComponent(Xe,{})),T.$$keydown=u=>{u.key==="Enter"&&!u.shiftKey&&!u.isComposing?(u.preventDefault(),s()):u.key==="Escape"&&(u.preventDefault(),e.cancelTarget())},T.$$input=u=>e.setCustomDraft(u.currentTarget.value);var L=c;return typeof L=="function"?n.use(L,T):c=T,n.setAttribute(T,"spellcheck",!1),n.insert(E,n.createComponent(Nt,{value:()=>e.customDraft(),onText:u=>e.setCustomDraft(u)}),x),n.insert(E,n.createComponent(C.Show,{get when(){return e.customDraft().trim()!==""},get children(){var u=Le();return u.$$click=()=>e.setCustomDraft(""),u.$$mousedown=$=>$.preventDefault(),n.insert(u,n.createComponent(Ge,{})),n.effect($=>{var A=t.t("field.clear"),b=t.t("field.clear");return A!==$.e&&n.setAttribute(u,"title",$.e=A),b!==$.t&&n.setAttribute(u,"aria-label",$.t=b),$},{e:void 0,t:void 0}),u}}),x),x.$$click=s,x.$$mousedown=u=>u.preventDefault(),n.insert(x,n.createComponent(It,{})),n.effect(u=>{var $=t.t("title"),A=`${r().top}px`,b=`${r().left}px`,_=r().ready?void 0:"hidden",M=t.t("bar.addAction"),X=t.t("bar.addAction"),O=t.t("bar.quote"),N=t.t("bar.quote"),j=t.t("pill.exit"),q=t.t("pill.exit"),F=t.t("card.placeholder"),Q=e.customDraft().trim()==="",V=t.t("card.add"),W=t.t("card.add");return $!==u.e&&n.setAttribute(i,"aria-label",u.e=$),A!==u.t&&n.setStyleProperty(i,"top",u.t=A),b!==u.a&&n.setStyleProperty(i,"left",u.a=b),_!==u.o&&n.setStyleProperty(i,"visibility",u.o=_),M!==u.i&&n.setAttribute(d,"title",u.i=M),X!==u.n&&n.setAttribute(d,"aria-label",u.n=X),O!==u.s&&n.setAttribute(v,"title",u.s=O),N!==u.h&&n.setAttribute(v,"aria-label",u.h=N),j!==u.r&&n.setAttribute(S,"title",u.r=j),q!==u.d&&n.setAttribute(S,"aria-label",u.d=q),F!==u.l&&n.setAttribute(T,"placeholder",u.l=F),Q!==u.u&&(x.disabled=u.u=Q),V!==u.c&&n.setAttribute(x,"title",u.c=V),W!==u.w&&n.setAttribute(x,"aria-label",u.w=W),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0}),n.effect(()=>T.value=e.customDraft()),i})()})}function Je(){const t=P.usePlugin(),e=G(),[c,p]=C.createSignal(!1);C.createEffect(()=>{const a=e.chipMenu();if(p(!1),a){const s=i=>{(i.target instanceof Element?i.target:null)?.closest('[data-annotate-it="chip-menu"]')||e.setChipMenu(null)},r=setTimeout(()=>document.addEventListener("pointerdown",s,!0),0);C.onCleanup(()=>{clearTimeout(r),document.removeEventListener("pointerdown",s,!0)})}});const l=()=>{const a=e.chipMenu();if(a)return{top:z(a.y+6,8,window.innerHeight-120),left:z(a.x-60,8,window.innerWidth-180)}};return n.createComponent(C.Show,{get when(){return n.memo(()=>!!e.chipMenu())()&&l()},children:a=>(()=>{var s=De();return s.$$mousedown=r=>r.preventDefault(),n.insert(s,n.createComponent(C.Show,{get when(){return!c()},get fallback(){return[(()=>{var r=Me();return n.insert(r,()=>t.t("menu.deleteConfirm")),r})(),(()=>{var r=Lt();return r.$$click=()=>{const i=e.chipMenu();i&&e.removeAction(i.actionId)},n.insert(r,()=>t.t("menu.deleteSure")),r})(),(()=>{var r=Rt();return r.$$click=()=>p(!1),n.insert(r,()=>t.t("card.cancel")),r})()]},get children(){return[(()=>{var r=Rt();return r.$$click=()=>{const i=e.chipMenu();if(!i)return;const h=e.actions().find(d=>d.id===i.actionId);e.setEditor({id:i.actionId,label:h?.label??"",text:h?.text??"",x:i.x,y:i.y}),e.setChipMenu(null)},n.insert(r,()=>t.t("menu.edit")),r})(),(()=>{var r=Lt();return r.$$click=()=>p(!0),n.insert(r,()=>t.t("menu.delete")),r})()]}})),n.effect(r=>{var i=`${a().top}px`,h=`${a().left}px`;return i!==r.e&&n.setStyleProperty(s,"top",r.e=i),h!==r.t&&n.setStyleProperty(s,"left",r.t=h),r},{e:void 0,t:void 0}),s})()})}function Ke(){const t=P.usePlugin(),e=G(),[c,p]=C.createSignal(""),[l,a]=C.createSignal("");C.createEffect(()=>{const i=e.editor();if(i){p(i.label),a(i.text);const h=v=>{(v.target instanceof Element?v.target:null)?.closest('[data-annotate-it="action-editor"]')||e.setEditor(null)},d=setTimeout(()=>document.addEventListener("pointerdown",h,!0),0);C.onCleanup(()=>{clearTimeout(d),document.removeEventListener("pointerdown",h,!0)})}});const s=()=>{const i=e.editor();if(i)return{top:z(i.y-100,8,window.innerHeight-240),left:z(i.x-140,8,window.innerWidth-320)}},r=()=>{const i=e.editor();i&&e.saveAction(i.id,c(),l())};return n.createComponent(C.Show,{get when(){return n.memo(()=>!!e.editor())()&&s()},children:i=>(()=>{var h=qe(),d=h.firstChild,v=d.nextSibling,S=v.firstChild,E=S.nextSibling,T=v.nextSibling,x=T.firstChild,L=x.nextSibling,u=T.nextSibling,$=u.firstChild,A=$.nextSibling;return h.$$mousedown=b=>b.stopPropagation(),n.insert(d,()=>t.t("editor.title")),n.insert(S,()=>t.t("editor.label")),E.$$keydown=b=>b.key==="Enter"&&r(),E.$$input=b=>p(b.currentTarget.value),n.insert(x,()=>t.t("editor.phrase")),L.$$keydown=b=>b.key==="Enter"&&r(),L.$$input=b=>a(b.currentTarget.value),$.$$click=()=>e.setEditor(null),n.insert($,()=>t.t("editor.cancel")),A.$$click=r,n.insert(A,()=>t.t("editor.save")),n.effect(b=>{var _=`${i().top}px`,M=`${i().left}px`;return _!==b.e&&n.setStyleProperty(h,"top",b.e=_),M!==b.t&&n.setStyleProperty(h,"left",b.t=M),b},{e:void 0,t:void 0}),n.effect(()=>E.value=c()),n.effect(()=>L.value=l()),h})()})}function tn(){const t=P.usePlugin(),e=G(),c=()=>{const a=e.hover();if(a)return e.notes().find(s=>s.id===a.noteId)},p=()=>{const a=e.hover();if(!a||!c())return;const s=320;return{top:z(a.y+14,8,window.innerHeight-280),left:z(a.x-s/2,8,window.innerWidth-s-8)}},l=()=>{const a=e.hover();a&&e.addComment(a.noteId,e.hoverDraft())};return n.createComponent(C.Show,{get when(){return n.memo(()=>!!(e.reviewing()&&e.hover()&&c()))()&&p()},children:a=>(()=>{var s=Ne(),r=s.firstChild,i=r.nextSibling,h=i.nextSibling,d=h.nextSibling,v=d.firstChild,S=v.nextSibling,E=d.nextSibling,T=E.firstChild;return s.$$mousedown=x=>x.stopPropagation(),n.insert(r,()=>c().quote),n.insert(i,()=>e.sourceLabel(c().source)),n.insert(h,()=>t.t("hover.comments")),n.insert(s,n.createComponent(C.Show,{get when(){return c().comments.length>0},get fallback(){return(()=>{var x=He();return n.insert(x,()=>t.t("hover.empty")),x})()},get children(){var x=Ie();return n.insert(x,n.createComponent(C.For,{get each(){return c().comments},children:L=>(()=>{var u=ze(),$=u.firstChild,A=$.nextSibling;return n.insert($,()=>L.text),n.insert(A,(()=>{var b=n.memo(()=>!!L.sent);return()=>b()?t.t("hover.sent"):t.t("hover.pending")})()),n.effect(()=>n.className(A,`ait-badge${L.sent?" ait-badge-sent":""}`)),u})()})),x}}),d),v.$$keydown=x=>{x.key==="Enter"&&!x.shiftKey&&!x.isComposing?(x.preventDefault(),l()):x.key==="Escape"&&(x.preventDefault(),e.closeHover())},v.$$input=x=>e.setHoverDraft(x.currentTarget.value),n.insert(d,n.createComponent(Nt,{value:()=>e.hoverDraft(),onText:x=>e.setHoverDraft(x)}),S),S.$$click=l,S.$$mousedown=x=>x.preventDefault(),n.insert(S,n.createComponent(It,{})),T.$$click=()=>e.removeNote(c().id),n.insert(T,()=>t.t("hover.delete")),n.effect(x=>{var L=`${a().top}px`,u=`${a().left}px`,$=t.t("hover.addPlaceholder"),A=e.hoverDraft().trim()==="",b=t.t("card.add"),_=t.t("card.add");return L!==x.e&&n.setStyleProperty(s,"top",x.e=L),u!==x.t&&n.setStyleProperty(s,"left",x.t=u),$!==x.a&&n.setAttribute(v,"placeholder",x.a=$),A!==x.o&&(S.disabled=x.o=A),b!==x.i&&n.setAttribute(S,"title",x.i=b),_!==x.n&&n.setAttribute(S,"aria-label",x.n=_),x},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),n.effect(()=>v.value=e.hoverDraft()),s})()})}function en(){const t=P.usePlugin(),e=G(),c=t.ui,p=l=>{const a=t.keybinds.keybind(`${t.id}.${l}`);return a.length>0?a:["—"]};return n.createComponent(c.SettingsLayout,{get title(){return t.t("title")},get description(){return t.t("settings.description")},get children(){return[n.createComponent(c.SettingsSection,{get title(){return t.t("settings.behavior")},get children(){return[n.createComponent(c.SettingsRow,{id:"pencil",get title(){return t.t("settings.pencil")},get description(){return t.t("settings.pencil.description")},get children(){return n.createComponent(c.Switch,{get label(){return t.t("settings.pencil")},hideLabel:!0,get checked(){return e.pencilEnabled()},onChange:l=>e.setPref("pencil",l)})}}),n.createComponent(c.SettingsRow,{id:"highlights",get title(){return t.t("settings.highlights")},get description(){return t.t("settings.highlights.description")},get children(){return n.createComponent(c.Switch,{get label(){return t.t("settings.highlights")},hideLabel:!0,get checked(){return e.highlightsEnabled()},onChange:l=>e.setPref("highlights",l)})}}),n.createComponent(c.SettingsRow,{id:"accent",get title(){return t.t("settings.accent")},get description(){return t.t("settings.accent.description")},get children(){var l=Oe(),a=l.firstChild;return n.insert(l,n.createComponent(C.For,{each:["#d97757","#f59e0b","#22c55e","#3b82f6","#a855f7","#ec4899"],children:s=>(()=>{var r=Mt();return r.$$click=()=>e.setAccent(s),n.setStyleProperty(r,"background",s),n.setAttribute(r,"aria-label",s),n.effect(()=>n.className(r,`ait-swatch${e.accent()===s?" ait-swatch-active":""}`)),r})()}),a),a.$$input=s=>e.setAccent(s.currentTarget.value),n.effect(()=>n.setAttribute(a,"aria-label",t.t("settings.accent"))),n.effect(()=>a.value=e.accent()),l}})]}}),n.createComponent(c.SettingsSection,{get title(){return t.t("settings.actions")},get footer(){return(()=>{var l=Fe();return n.insert(l,n.createComponent(c.Button,{size:"small",variant:"ghost",icon:"plus",onClick:()=>e.saveAction(null,t.t("settings.action.new"),t.t("settings.action.new")),get children(){return t.t("settings.action.add")}}),null),n.insert(l,n.createComponent(c.Button,{size:"small",variant:"ghost",icon:"reset",onClick:()=>e.resetActions(),get children(){return t.t("settings.action.reset")}}),null),l})()},get children(){return n.createComponent(C.For,{get each(){return e.actions()},children:l=>n.createComponent(c.SettingsRow,{get id(){return l.id},get title(){return(()=>{var a=_t();return a.$$input=s=>e.saveAction(l.id,s.currentTarget.value,l.text),n.effect(()=>n.setAttribute(a,"aria-label",t.t("editor.label"))),n.effect(()=>a.value=l.label),a})()},get description(){return(()=>{var a=_t();return a.$$input=s=>e.saveAction(l.id,l.label,s.currentTarget.value),n.effect(()=>n.setAttribute(a,"aria-label",t.t("editor.phrase"))),n.effect(()=>a.value=l.text),a})()},get children(){return n.createComponent(c.IconButton,{icon:"trash",variant:"ghost-muted",size:"small",get label(){return t.t("settings.action.delete")},onClick:()=>e.removeAction(l.id)})}})})}}),n.createComponent(c.SettingsSection,{get title(){return t.t("settings.keys")},get children(){return[n.createComponent(c.SettingsRow,{id:"key-toggle",get title(){return t.t("settings.keys.toggle")},get description(){return t.t("settings.keys.description")},get children(){return n.createComponent(c.Keybind,{get keys(){return p("toggle")}})}}),n.createComponent(c.SettingsRow,{id:"key-clear",get title(){return t.t("settings.keys.clear")},get children(){return n.createComponent(c.Keybind,{get keys(){return p("clear")}})}})]}})]}})}function nn(){const t=G();return C.createEffect(()=>{t.paintTick(),t.hover(),t.target(),t.schedulePaint()}),n.createComponent(n.Portal,{get children(){return[n.createComponent(Ye,{}),n.createComponent(Qe,{}),n.createComponent(Je,{}),n.createComponent(Ke,{}),n.createComponent(tn,{})]}})}n.delegateEvents(["mousedown","click","input","keydown","contextmenu"]);const rn='::highlight(annotate-it-pending){background-color:color-mix(in srgb,var(--ait-accent, #d97757) 35%,transparent);color:inherit}::highlight(annotate-it-sent){background-color:color-mix(in srgb,var(--ait-accent, #d97757) 16%,transparent);color:inherit}::highlight(annotate-it-hover){background-color:color-mix(in srgb,var(--ait-accent, #d97757) 50%,transparent);color:inherit}::highlight(annotate-it-selection){background-color:color-mix(in srgb,var(--ait-accent, #d97757) 30%,transparent);color:inherit}[data-component=timeline-quote],[data-component=terminal-quote]{display:none!important}[data-annotate-it]{--ait-bg: var(--v2-background-bg-base, #14171b);--ait-ink: var(--v2-text-text-base, #f4f5f7);--ait-muted: var(--v2-text-text-muted, rgba(255, 255, 255, .55));--ait-border: var(--v2-border-border-strong, rgba(255, 255, 255, .22));--ait-line: color-mix(in srgb, var(--ait-ink) 12%, transparent);--ait-chip: color-mix(in srgb, var(--ait-ink) 8%, transparent);--ait-chip-hover: color-mix(in srgb, var(--ait-ink) 14%, transparent);--ait-shadow: var(--v2-elevation-overlay, 0 24px 60px rgba(0, 0, 0, .5), 0 3px 10px rgba(0, 0, 0, .2));--ait-danger: var(--v2-state-fg-danger, #f87171)}@keyframes ait-fade{0%{opacity:0;transform:translateY(3px)}to{opacity:1;transform:translateY(0)}}.ait-pencil{position:fixed;z-index:2147482000;display:grid;place-items:center;width:24px;height:24px;padding:0;box-sizing:border-box;border-radius:50%;background:var(--ait-bg);border:1px solid var(--ait-border);color:var(--ait-ink);cursor:pointer;opacity:.9;box-shadow:var(--ait-shadow);transition:opacity .12s ease,border-color .12s ease,transform .12s ease;-webkit-user-select:none;user-select:none;animation:ait-fade .13s cubic-bezier(.2,.8,.3,1) both}.ait-pencil:hover{opacity:1;border-color:var(--ait-accent, #d97757)}.ait-pencil:active{transform:scale(.94)}.ait-mini{position:fixed;z-index:2147482000;display:flex;flex-direction:column;gap:3px;box-sizing:border-box;width:max-content;min-width:280px;max-width:min(420px,calc(100vw - 16px));padding:5px;border:1px solid var(--ait-border);border-radius:14px;background:var(--ait-bg);color:var(--ait-ink);font-family:inherit;font-size:12.5px;font-weight:500;line-height:1;-webkit-user-select:none;user-select:none;box-shadow:var(--ait-shadow);animation:ait-fade .13s cubic-bezier(.2,.8,.3,1) both}.ait-mini-row{display:flex;align-items:center;gap:2px;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}.ait-qchip{display:inline-flex;align-items:center;flex:0 0 auto;height:26px;padding:0 8px;box-sizing:border-box;border:0;border-radius:7px;background:var(--ait-chip);color:var(--ait-ink);font:inherit;cursor:pointer;white-space:nowrap}.ait-qchip:hover{background:var(--ait-chip-hover)}.ait-qchip-label{display:block;max-width:132px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ait-qchip-add{background:transparent;color:var(--ait-accent, #d97757);font-size:14px;font-weight:600}.ait-qchip-icon{width:26px;justify-content:center;padding:0;background:transparent}.ait-exit{color:var(--ait-muted)}.ait-exit:hover{color:var(--ait-ink)}.ait-mini-field{padding-top:4px;border-top:1px solid var(--ait-line);overflow:visible}.ait-mini-input{flex:1 1 auto;min-width:0;height:26px;padding:0 6px;border:0;outline:0;background:transparent;color:var(--ait-ink);font:inherit;font-size:12.5px;font-weight:400;caret-color:var(--ait-accent, #d97757)}.ait-mini-input::placeholder{color:var(--ait-muted);opacity:1}.ait-tool{width:22px;height:22px;flex:0 0 auto;display:grid;place-items:center;padding:0;border:0;border-radius:6px;background:transparent;color:var(--ait-muted);cursor:pointer}.ait-tool:hover{background:var(--ait-chip-hover);color:var(--ait-ink)}.ait-mic-live{color:var(--ait-danger);animation:ait-pulse 1.2s ease-in-out infinite}@keyframes ait-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--ait-danger) 35%,transparent)}50%{box-shadow:0 0 0 5px transparent}}.ait-sendicon{flex:0 0 auto;box-sizing:border-box;width:24px;height:24px;padding:0;border:0;border-radius:50%;display:grid;place-items:center;background:var(--ait-accent, #d97757);color:#fff;cursor:pointer;box-shadow:0 1px 2px #0000002e;transition:filter .12s ease,background .12s ease}.ait-sendicon:disabled{background:transparent;color:var(--ait-muted);box-shadow:none;cursor:default}.ait-sendicon:not(:disabled):hover{filter:brightness(1.07)}.ait-card,.ait-menu{position:fixed;z-index:2147482001;box-sizing:border-box;border:1px solid var(--ait-border);border-radius:14px;background:var(--ait-bg);color:var(--ait-ink);font-family:inherit;box-shadow:var(--ait-shadow);animation:ait-fade .12s ease-out both}.ait-card{width:320px;max-width:calc(100vw - 24px);padding:12px 13px 11px;display:flex;flex-direction:column;gap:9px}.ait-editor{width:300px}.ait-card-title{font-size:12px;font-weight:600}.ait-quote-preview{position:relative;max-height:66px;overflow:hidden;padding-left:11px;color:var(--ait-muted);font-size:12.5px;line-height:1.6;white-space:pre-wrap;word-break:break-word;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.ait-quote-preview:before{content:"";position:absolute;left:0;top:2px;bottom:2px;width:2px;border-radius:2px;background:var(--ait-accent, #d97757);opacity:.85}.ait-card-row{display:flex;align-items:center;gap:6px;padding-top:8px;border-top:1px solid var(--ait-line)}.ait-hover-input{border-bottom:1px solid var(--ait-line);border-radius:0;padding:0 2px}.ait-card-footer{display:flex;align-items:center;justify-content:flex-end;gap:6px}.ait-hint{font-size:11px;color:var(--ait-muted);margin-right:auto}.ait-field{display:flex;flex-direction:column;gap:3px;font-size:10.5px;color:var(--ait-muted)}.ait-input{box-sizing:border-box;width:100%;height:28px;padding:0 8px;border:1px solid var(--ait-border);border-radius:7px;background:var(--ait-chip);color:var(--ait-ink);font:inherit;font-size:12.5px;outline:0}.ait-input:focus{border-color:var(--ait-accent, #d97757)}.ait-btn{height:26px;padding:0 11px;border:0;border-radius:7px;background:var(--ait-accent, #d97757);color:#fff;font:inherit;font-size:12px;cursor:pointer}.ait-btn:hover{filter:brightness(1.07)}.ait-btn-ghost{background:transparent;color:var(--ait-muted)}.ait-btn-ghost:hover{background:var(--ait-chip);color:var(--ait-ink);filter:none}.ait-danger{color:var(--ait-danger)}.ait-comments{display:flex;flex-direction:column;gap:5px;max-height:140px;overflow-y:auto;scrollbar-width:thin}.ait-comment{display:flex;align-items:baseline;gap:6px;font-size:12.5px;line-height:1.35}.ait-comment-text{white-space:pre-wrap}.ait-badge{flex-shrink:0;font-size:10px;border-radius:5px;padding:1px 5px;background:color-mix(in srgb,var(--ait-accent, #d97757) 20%,transparent);color:var(--ait-muted)}.ait-badge-sent{background:var(--v2-state-bg-success, rgba(34, 197, 94, .18))}.ait-menu{display:flex;flex-direction:column;min-width:160px;padding:5px;gap:2px}.ait-menu-label{font-size:11px;line-height:1.4;color:var(--ait-muted);padding:3px 7px 5px}.ait-menu-item{display:flex;align-items:center;width:100%;height:28px;padding:0 8px;border:0;border-radius:7px;background:transparent;color:var(--ait-ink);font:inherit;font-size:12.5px;text-align:left;cursor:pointer}.ait-menu-item:hover{background:var(--ait-chip-hover)}.ait-menu-item.ait-danger{color:var(--ait-danger)}.ait-source{font-size:10.5px;color:var(--ait-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:-4px}.ait-settings-actions{display:flex;gap:6px;justify-content:flex-end}.ait-settings-input{height:26px;font-size:12px}.ait-accent-picker{display:flex;align-items:center;gap:6px}.ait-swatch{width:20px;height:20px;padding:0;border:2px solid transparent;border-radius:50%;cursor:pointer}.ait-swatch-active{border-color:var(--v2-text-text-base, currentColor)}.ait-color-input{width:28px;height:24px;padding:0;border:1px solid var(--v2-border-border-strong, rgba(127, 127, 127, .3));border-radius:6px;background:transparent;cursor:pointer}',on=P.Plugin.define({...de,setup(t){const e=ye(t);Be(e);const c=e.start();t.add(P.Style,rn),C.createEffect(()=>{document.documentElement.style.setProperty("--ait-accent",e.accent())}),C.createEffect(()=>{e.reviewing(),e.syncReviewClass()}),C.createEffect(()=>{const l=t.sessions.current();l&&(t.stores.notes(l)?.value,t.stores.mode(l)?.value),e.schedulePaint()}),t.add(P.Command,()=>({id:"toggle",title:t.t("command.toggle"),keywords:"annotate review quote аннотация рецензия",bind:"mod+shift+a",slash:{name:"annotate"},enabled:!!t.sessions.current(),run:()=>{if(!t.sessions.current()){t.toast.show({title:t.t("toast.noSession")});return}e.setReviewing(!e.reviewing())}})),t.add(P.Command,()=>({id:"clear",title:t.t("command.clear"),enabled:!!t.sessions.current()&&e.reviewing()&&e.pendingCount()>0,run:()=>{e.clearAll()}})),t.add(P.SettingsPage,{id:"annotate-it",icon:"outline-browser-annotate",get title(){return t.t("title")},get entries(){return[{id:"pencil",title:t.t("settings.pencil"),keywords:"pencil selection кнопка выделение"},{id:"highlights",title:t.t("settings.highlights"),keywords:"highlight подсветка"},{id:"actions",title:t.t("settings.actions"),keywords:"quick replies быстрые ответы"},{id:"keys",title:t.t("settings.keys"),keywords:"keybind shortcuts клавиши"}]},render:()=>n.createComponent(en,{})}),t.add(P.ComposerPill,{id:"clear",show:l=>{const a=t.stores.mode(l.session)?.value?.reviewing??!1,r=(t.stores.notes(l.session)?.value?.list??[]).filter(i=>i.comments.some(h=>!h.sent)).length;if(!(!a||r===0))return{label:`${t.t("pill.clear")} · ${r}`,icon:"close",title:t.t("pill.clearTitle"),run:()=>{e.clearAll()}}}}),t.add(P.Slot,{at:"window.bottom",render:()=>n.createComponent(nn,{})});const p=t.main($t);return p.on("selection",l=>{if(l.pressing)return;const a=ut(l.text);a&&e.setExternalTarget({text:a,rect:l.rect,line:l.rect,range:null,source:{kind:"browser",url:l.url,title:l.title}})}),p.on("clear",()=>e.clearExternalTarget()),P.createKeyed(()=>t.servers.get("sidecar")?.data,l=>{const a=d=>{const S=l.session.message.list(d).filter(E=>E.type==="user").slice(-10);for(const E of S)E.type==="user"&&e.trackSent(d,E.text)},s=[],r=d=>{a(d),s.push(setTimeout(()=>a(d),400)),s.push(setTimeout(()=>a(d),1500))},i=l.on("session.execution.started",d=>r(d.data.sessionID)),h=l.on("session.inbox.delivered",d=>r(d.data.sessionID));C.onCleanup(()=>{i(),h();for(const d of s)clearTimeout(d)})}),c},main(t){const e=t.provide($t,{}),c=new Map,p=`(() => {
10
+ if (!window.__annotateItWatch) {
11
+ window.__annotateItWatch = true;
12
+ window.__annotateItPressing = false;
13
+ const down = (e) => { if (e.button === 0) window.__annotateItPressing = true; };
14
+ const up = () => { window.__annotateItPressing = false; };
15
+ window.addEventListener('pointerdown', down, true);
16
+ window.addEventListener('pointerup', up, true);
17
+ window.addEventListener('pointercancel', up, true);
18
+ window.addEventListener('blur', up);
19
+ document.addEventListener('dragend', up, true);
20
+ }
21
+ const s = window.getSelection();
22
+ if (!s || s.isCollapsed || s.rangeCount === 0) return null;
23
+ const text = s.toString().trim();
24
+ if (!text) return null;
25
+ const r = s.getRangeAt(0).getBoundingClientRect();
26
+ return {
27
+ text: text.slice(0, 20000),
28
+ url: location.href,
29
+ title: document.title || "",
30
+ pressing: !!window.__annotateItPressing,
31
+ rect: { top: r.top, left: r.left, right: r.right, bottom: r.bottom }
32
+ };
33
+ })()`,l=setInterval(async()=>{for(const a of t.windows.list()){const s=a.contentView.children??[];for(const r of s){const i=r,h=i.webContents;if(!h||h.isDestroyed()||!i.getBounds)continue;const d=h.getURL();if(!/^(https?|file):/.test(d))continue;let v=null;try{v=await h.executeJavaScript(p,!0)}catch{continue}const S=v?`${v.text}\0${v.url}\0${v.pressing}`:"";if(c.get(h.id)===S)continue;if(c.set(h.id,S),!v){e.emit("clear",{});continue}const E=i.getBounds(),T=h.getZoomFactor()||1;e.emit("selection",{text:v.text,url:v.url,title:v.title,pressing:v.pressing,rect:{top:E.y+v.rect.top*T,left:E.x+v.rect.left*T,right:E.x+v.rect.right*T,bottom:E.y+v.rect.bottom*T}})}}},400);t.onCleanup(()=>clearInterval(l))}});exports.default=on;
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
2
  "name": "opencode-annotate-it",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Annotate chats and documents in OpenCode Desktop: select a passage, add a note or quick reply, highlight the text, and send the whole review as one message. Port of dsh-annotate-it.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ "./gui-experimental": "./dist/gui-experimental.cjs"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "vite build",
15
+ "watch": "vite build --watch",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "dependencies": {
19
+ "@opencode/plugin": "2.3.2"
20
+ },
21
+ "devDependencies": {
22
+ "solid-js": "^1.9.0",
23
+ "vite": "^7.0.0",
24
+ "vite-plugin-solid": "^2.11.0",
25
+ "typescript": "^5.6.0"
26
+ }
27
+ }