diff --git a/argus_skill/adapters/agent_cli_backend/_exec_finalize.py b/argus_skill/adapters/agent_cli_backend/_exec_finalize.py index 77ed9c9f4..1f61e16a3 100644 --- a/argus_skill/adapters/agent_cli_backend/_exec_finalize.py +++ b/argus_skill/adapters/agent_cli_backend/_exec_finalize.py @@ -39,6 +39,7 @@ def finalize_result( token_usage: TokenUsage | None = None, premium_requests: float | None = None, error: str = "", + startup_receipt: dict | None = None, ) -> RunnerResult: backend = ctx.backend persisted_error = redact_secrets_text( @@ -161,6 +162,7 @@ def finalize_result( thread_id=result.thread_id, model_usage=result.model_usage, error=persisted_error, + startup_receipt=startup_receipt, ) appended = UsageLedger( ctx.usage_project_root, diff --git a/argus_skill/adapters/agent_cli_backend/_exec_spawn.py b/argus_skill/adapters/agent_cli_backend/_exec_spawn.py index 6d9430232..8327eb75c 100644 --- a/argus_skill/adapters/agent_cli_backend/_exec_spawn.py +++ b/argus_skill/adapters/agent_cli_backend/_exec_spawn.py @@ -414,4 +414,5 @@ def spawn_and_finish(ctx: "_ExecContext", cli_options: Any) -> RunnerResult: else "completed" ), error=safe_failure_text, + startup_receipt=complete_row, ) diff --git a/argus_skill/core/runner_errors.py b/argus_skill/core/runner_errors.py index 02583f3f3..f34dcfa4a 100644 --- a/argus_skill/core/runner_errors.py +++ b/argus_skill/core/runner_errors.py @@ -126,3 +126,51 @@ def result_has_pre_provider_refusal(result: Any) -> bool: "result_has_pre_provider_refusal", "result_has_unrecoverable_resume_state", ] + + +def is_copilot_context_parser_error(value: object) -> bool: + """Exact runner-wrapped parser diagnostic; text alone is not authority.""" + prefix = ( + "Process exited with code 1 before turn completion.\n" + "error: unknown option '--context'\n" + ) + suffix = "Try 'copilot --help' for more information." + return str(value or "").strip() in ( + prefix + "(Did you mean --connect?)\n\n" + suffix, + prefix + "\n" + suffix, + ) + + +def is_copilot_context_parser_refusal( + error: object, *, provider: str, call_id: str, run_label: str, + status: str, thread_id: object, source: str, + receipt: dict[str, Any] | None, +) -> bool: + """Use only host-generated agent.io.complete, never model/tool JSON. + + A parser diagnostic is positive startup evidence only when the matching + process receipt confirms an unsuccessful, silent pre-turn CLI invocation. + Usage accounting must independently reject every observed usage field. + """ + if not is_copilot_context_parser_error(error) or not receipt: + return False + command = receipt.get("command") + return bool( + provider == "copilot" and status == "error" and source == "run_exec" + and not thread_id and call_id + and receipt.get("type") == "agent.io.complete" + and receipt.get("backend") == provider + and receipt.get("call_id") == call_id + and receipt.get("run_label") == run_label + and receipt.get("exit_code") == 1 + and receipt.get("turn_failed") is True + and receipt.get("turn_completed") is False + and receipt.get("thread_id") is None + and receipt.get("fatal_error") == "Process exited with code 1 before turn completion." + and receipt.get("tool_activity_observed") is False + and all(receipt.get(key) == 0 for key in ( + "agent_message_count", "stdout_line_count", "json_event_count")) + and isinstance(command, list) + and any(command[i:i+2] == ["--context", "default"] + for i in range(1, len(command)-1)) + ) diff --git a/argus_skill/core/usage.py b/argus_skill/core/usage.py index c8836b6da..2e226702f 100644 --- a/argus_skill/core/usage.py +++ b/argus_skill/core/usage.py @@ -26,7 +26,11 @@ ) from .event_catalog import CALL_SCOPED_EVENT_TYPES, EventType, canonical_event_type from .pricing import PricingQuote, PricingStatus, quote_copilot_usage, quote_token_usage -from .runner_errors import is_pre_provider_refusal_error +from .runner_errors import ( + is_copilot_context_parser_error, + is_copilot_context_parser_refusal, + is_pre_provider_refusal_error, +) from .token_usage import TokenUsage, extract_token_usage try: # pragma: no cover - Windows usage mutations use portalocker below @@ -90,13 +94,26 @@ def to_jsonable(self) -> dict[str, Any]: return row @classmethod - def from_jsonable(cls, row: dict[str, Any]) -> "UsageRecord": + def from_jsonable( + cls, row: dict[str, Any], *, startup_receipt: dict[str, Any] | None = None, + ) -> "UsageRecord": cost = _optional_float(row.get("cost_usd")) pricing_status = _pricing_status(row.get("pricing_status")) pricing_tier = str(row.get("pricing_tier") or "unknown") error = str(row.get("error") or "") if ( - is_pre_provider_refusal_error(error) + (is_pre_provider_refusal_error(error) or ( + is_copilot_context_parser_refusal( + error, provider=str(row.get("provider") or ""), + call_id=str(row.get("call_id") or ""), + run_label=str(row.get("run_label") or ""), + status=str(row.get("status") or ""), + thread_id=row.get("thread_id"), + source=str(row.get("source") or ""), receipt=startup_receipt, + ) + and row.get("premium_requests") is None + and row.get("premium_request_cost_usd") is None + )) and cost is None and row.get("total_nano_aiu") is None and not row.get("model_usage") @@ -272,13 +289,20 @@ def build_usage_record( model_usage: Iterable[dict[str, Any]] | None = None, error: str = "", source: UsageSource = "run_exec", + startup_receipt: dict[str, Any] | None = None, ) -> UsageRecord: usage = token_usage or TokenUsage() normalized_model_usage = _normalize_model_usage(model_usage) normalized_provider = str(provider or "").strip().lower() premium_quote = quote_copilot_usage(premium_requests) missing_resume_target = ( - is_pre_provider_refusal_error(error) + (is_pre_provider_refusal_error(error) or ( + is_copilot_context_parser_refusal( + error, provider=normalized_provider, call_id=call_id, + run_label=run_label, status=status, thread_id=thread_id, + source=source, receipt=startup_receipt, + ) and premium_requests is None + )) and total_nano_aiu is None and provider_cost_usd is None and not normalized_model_usage @@ -495,6 +519,7 @@ def records( handle = self.path.open("r", encoding="utf-8") except OSError: return out + startup_receipts = None with handle: for raw in handle: try: @@ -503,7 +528,12 @@ def records( continue if not isinstance(row, dict): continue - record = UsageRecord.from_jsonable(row) + receipt = None + if is_copilot_context_parser_error(row.get("error")): + if startup_receipts is None: + startup_receipts = _startup_completion_receipts(self.project_root) + receipt = startup_receipts.get(str(row.get("call_id") or "")) + record = UsageRecord.from_jsonable(row, startup_receipt=receipt) if not record.call_id or record.call_id in seen: continue seen.add(record.call_id) @@ -1689,3 +1719,31 @@ def _call_status(value: Any) -> CallStatus: "summarize_usage", "usage_recorded_event", ] + + +def _startup_completion_receipts(project_root: Path) -> dict[str, dict[str, Any]]: + """Read host lifecycle summaries, not raw provider/tool stream frames. + + Ambiguous duplicate completion receipts fail closed. Only consulted when + an exact historical parser diagnostic needs the missing runner context. + """ + receipts: dict[str, dict[str, Any]] = {} + seen: set[str] = set() + try: + with (project_root / "events.jsonl").open(encoding="utf-8") as handle: + for raw in handle: + try: + event = json.loads(raw) + except (ValueError, TypeError): + continue + if not isinstance(event, dict) or event.get("type") != "agent.io.complete": + continue + call_id = str(event.get("call_id") or "") + if call_id in seen: + receipts.pop(call_id, None) + else: + receipts[call_id] = event + seen.add(call_id) + except OSError: + return {} + return receipts diff --git a/argus_skill/release_manifest.json b/argus_skill/release_manifest.json index 84696f6b5..864783856 100644 --- a/argus_skill/release_manifest.json +++ b/argus_skill/release_manifest.json @@ -1,6 +1,6 @@ { "package_version": "0.1.1", - "release_id": "0.1.1+b9d192ba6b186634", + "release_id": "0.1.1+f2f2ab05a41299fc", "schema_version": 1, - "source_digest": "b9d192ba6b1866346496b561464a2052d261b03b2eab1424d2299f676eb9ba13" + "source_digest": "f2f2ab05a41299fc21fbb430c0bc5de704d2c01259d39ae5bfac6a98489bf776" } diff --git a/frontend/core/src/release.generated.ts b/frontend/core/src/release.generated.ts index 72a2f25cd..c698d8a4f 100644 --- a/frontend/core/src/release.generated.ts +++ b/frontend/core/src/release.generated.ts @@ -1,3 +1,3 @@ // Generated by argus_skill.release_tools.generate_manifest. Do not edit. -export const RELEASE_ID = "0.1.1+b9d192ba6b186634"; -export const RELEASE_SOURCE_DIGEST = "b9d192ba6b1866346496b561464a2052d261b03b2eab1424d2299f676eb9ba13"; +export const RELEASE_ID = "0.1.1+f2f2ab05a41299fc"; +export const RELEASE_SOURCE_DIGEST = "f2f2ab05a41299fc21fbb430c0bc5de704d2c01259d39ae5bfac6a98489bf776"; diff --git a/frontend/tui/bundle/argus.mjs b/frontend/tui/bundle/argus.mjs index 0e47e7b1e..aceeb157f 100644 --- a/frontend/tui/bundle/argus.mjs +++ b/frontend/tui/bundle/argus.mjs @@ -121,7 +121,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(r.setEncoding("utf8"),t){this.rawModeEnabledCount===0&&(r.ref(),r.setRawMode(!0),r.addListener("readable",this.handleReadable)),this.rawModeEnabledCount++;return}--this.rawModeEnabledCount===0&&(r.setRawMode(!1),r.removeListener("readable",this.handleReadable),r.unref())};handleReadable=()=>{let t;for(;(t=this.props.stdin.read())!==null;)this.handleInput(t),this.internal_eventEmitter.emit("input",t)};handleInput=t=>{t===""&&this.props.exitOnCtrlC&&this.handleExit(),t===ab&&this.state.activeFocusId&&this.setState({activeFocusId:void 0}),this.state.isFocusEnabled&&this.state.focusables.length>0&&(t===ib&&this.focusNext(),t===sb&&this.focusPrevious())};handleExit=t=>{this.isRawModeSupported()&&this.handleSetRawMode(!1),this.props.onExit(t)};enableFocus=()=>{this.setState({isFocusEnabled:!0})};disableFocus=()=>{this.setState({isFocusEnabled:!1})};focus=t=>{this.setState(r=>r.focusables.some(s=>s?.id===t)?{activeFocusId:t}:r)};focusNext=()=>{this.setState(t=>{let r=t.focusables.find(s=>s.isActive)?.id;return{activeFocusId:this.findNextFocusable(t)??r}})};focusPrevious=()=>{this.setState(t=>{let r=t.focusables.findLast(s=>s.isActive)?.id;return{activeFocusId:this.findPreviousFocusable(t)??r}})};addFocusable=(t,{autoFocus:r})=>{this.setState(i=>{let s=i.activeFocusId;return!s&&r&&(s=t),{activeFocusId:s,focusables:[...i.focusables,{id:t,isActive:!0}]}})};removeFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.filter(i=>i.id!==t)}))};activateFocusable=t=>{this.setState(r=>({focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!0})}))};deactivateFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!1})}))};findNextFocusable=t=>{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r+1;i{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r-1;i>=0;i--){let s=t.focusables[i];if(s?.isActive)return s.id}}};var hy=()=>{},xf=class{options;log;throttledLog;isUnmounted;lastOutput;container;rootNode;fullStaticOutput;exitPromise;restoreConsole;unsubscribeResize;constructor(t){FE(this),this.options=t,this.rootNode=Id("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.rootNode.onRender=t.debug?this.onRender:Zg(this.onRender,32,{leading:!0,trailing:!0}),this.rootNode.onImmediateRender=this.onRender,this.log=zD.create(t.stdout),this.throttledLog=t.debug?this.log:Zg(this.log,void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.lastOutput="",this.fullStaticOutput="",this.container=ZA.createContainer(this.rootNode,0,null,!1,null,"id",()=>{},null),this.unsubscribeExit=(0,By.default)(this.unmount,{alwaysLast:!1}),Ab.env.DEV==="true"&&ZA.injectIntoDevTools({bundleType:0,version:"16.13.1",rendererPackageName:"ink"}),t.patchConsole&&this.patchConsole(),HA||(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)})}resized=()=>{this.calculateLayout(),this.onRender()};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};calculateLayout=()=>{let t=this.options.stdout.columns||80;this.rootNode.yogaNode.setWidth(t),this.rootNode.yogaNode.calculateLayout(void 0,void 0,it.DIRECTION_LTR)};onRender=()=>{if(this.isUnmounted)return;let{output:t,outputHeight:r,staticOutput:i}=GD(this.rootNode),s=i&&i!==` `;if(this.options.debug){s&&(this.fullStaticOutput+=i),this.options.stdout.write(this.fullStaticOutput+t);return}if(HA){s&&this.options.stdout.write(i),this.lastOutput=t;return}if(s&&(this.fullStaticOutput+=i),r>=this.options.stdout.rows){this.options.stdout.write(Mo.clearTerminal+this.fullStaticOutput+t),this.lastOutput=t;return}s&&(this.log.clear(),this.options.stdout.write(i),this.log(t)),!s&&t!==this.lastOutput&&this.throttledLog(t),this.lastOutput=t};render(t){let r=Cy.default.createElement(kf,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},t);ZA.updateContainer(r,this.container,null,hy)}writeToStdout(t){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stdout.write(t);return}this.log.clear(),this.options.stdout.write(t),this.log(this.lastOutput)}}writeToStderr(t){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stderr.write(t);return}this.log.clear(),this.options.stderr.write(t),this.log(this.lastOutput)}}unmount(t){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),HA?this.options.stdout.write(this.lastOutput+` `):this.options.debug||this.log.done(),this.isUnmounted=!0,ZA.updateContainer(null,this.container,null,hy),Tu.delete(this.options.stdout),t instanceof Error?this.rejectExitPromise(t):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((t,r)=>{this.resolveExitPromise=t,this.rejectExitPromise=r}),this.exitPromise}clear(){!HA&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=aC((t,r)=>{t==="stdout"&&this.writeToStdout(r),t==="stderr"&&(r.startsWith("The above error occurred")||this.writeToStderr(r))}))}};var ub=(e,t)=>{let r={stdout:Zd.stdout,stdin:Zd.stdin,stderr:Zd.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,...cb(t)},i=fb(r.stdout,()=>new xf(r));return i.render(e),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,cleanup:()=>Tu.delete(r.stdout),clear:i.clear}},Zm=ub,cb=(e={})=>e instanceof lb?{stdout:e,stdin:Zd.stdin}:e,fb=(e,t)=>{let r=Tu.get(e);return r||(r=t(),Tu.set(e,r)),r};var fa=Le($t(),1);function Nf(e){let{items:t,children:r,style:i}=e,[s,a]=(0,fa.useState)(0),u=(0,fa.useMemo)(()=>t.slice(s),[t,s]);(0,fa.useLayoutEffect)(()=>{a(t.length)},[t.length]);let E=u.map((h,y)=>r(h,s+y)),m=(0,fa.useMemo)(()=>({position:"absolute",flexDirection:"column",...i}),[i]);return fa.default.createElement("ink-box",{internal_static:!0,style:m},E)}var gb=Le($t(),1);var db=Le($t(),1);var pb=Le($t(),1);var eI=Le($t(),1);import{Buffer as Eb}from"node:buffer";var mb=/^(?:\x1b)([a-zA-Z0-9])$/,Ib=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Dy={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},yy=[...Object.values(Dy),"backspace"],hb=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),Cb=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e),Bb=(e="")=>{let t;Eb.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");let r={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e};if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===` -`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,te)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),te(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` +`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,te)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),te(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` `))>=0;){let i=e.slice(0,r);e=e.slice(r+2);for(let s of i.split(` `)){let a=s.trim();if(a.startsWith("data:"))try{t.push(JSON.parse(a.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var us=class{httpBase;wsBase;project;token;onCompatibilityWarning;metaTimeoutMs;readTimeoutMs;metaPromise;constructor(t){this.httpBase=`http://${t.host}:${t.port}`,this.wsBase=`ws://${t.host}:${t.port}`,this.project=t.project,this.token=t.token,this.onCompatibilityWarning=t.onCompatibilityWarning,this.metaTimeoutMs=t.metaTimeoutMs??8e3,this.readTimeoutMs=t.readTimeoutMs??12e3}authHeaders(){return this.token?{Authorization:`Bearer ${this.token}`}:{}}p(t){return`${this.httpBase}/api/projects/${encodeURIComponent(this.project)}${t}`}meta(){if(!this.metaPromise){let t="/api/meta",r=pa(`${this.httpBase}${t}`,{headers:this.authHeaders()},this.metaTimeoutMs,async i=>{if(i.status===404)throw new Error("incompatible Argus API: service does not expose /api/meta");return await io(i,"GET",t),Ry(await i.json(),this.onCompatibilityWarning)});this.metaPromise=r,r.catch(()=>{this.metaPromise===r&&(this.metaPromise=void 0)})}return this.metaPromise}async listProjects(){return await this.meta(),pa(`${this.httpBase}/api/projects`,{headers:this.authHeaders()},this.readTimeoutMs,async t=>(await io(t,"GET","/api/projects"),(await t.json()).projects))}async createDaemon(t="",r="",i=process.cwd(),s,a=np()){let u="/api/daemons",E=Pb(i),m={objective:t,name:r,launch_cwd:i,command_id:a,expected_revision:s};E&&(m.workdir=E);let h=JSON.stringify(m),y=()=>fetch(`${this.httpBase}${u}`,{method:"POST",headers:{"Content-Type":"application/json",Connection:"close",...this.authHeaders()},body:h}),D=await y();return D.status===400&&/Invalid HTTP request received/i.test(await D.clone().text())&&(D=await y()),await io(D,"POST",u),await D.json()}async replaceDaemon(t,r=!1,i,s=np()){return await this.post("/daemon/replace",{victim_sid:t,resume_continuous:r,command_id:s,expected_revision:i})}async scheduleDaemonUpgrade(t,r,i=np()){let s=`/api/projects/${encodeURIComponent(t)}/daemon/upgrade-schedule`,a=await fetch(`${this.httpBase}${s}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({command_id:i,expected_revision:r})});return await io(a,"POST",s),await a.json()}stopDaemon(t=np()){let r="/daemon/stop";return pa(this.p(r),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({force:!1,drain:!1,command_id:t})},this.readTimeoutMs,async i=>{await io(i,"POST",r);let s=await i.json(),a=Number(s.rc??0);if(!Number.isFinite(a)||![0,1].includes(a)){let u=String(s.error??s.message??`rc=${String(s.rc??"unknown")}`);throw new Error(`executor did not stop cleanly: ${u}`)}return s})}async setProjectLaunchCwd(t,r){let i=`/api/projects/${encodeURIComponent(t)}/launch-cwd`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({launch_cwd:r})});await io(s,"POST",i)}async setProjectWorkdir(t,r){let i=`/api/projects/${encodeURIComponent(t)}/workdir`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({workdir:r})});await io(s,"POST",i)}async renameProject(t){let r=this.p(""),i=await fetch(r,{method:"PATCH",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({name:t})});return await io(i,"PATCH",r),await i.json()}async snapshot(t=1,r,i=!1){return await this.meta(),pa(this.p(`/snapshot?compact=true&events_limit=${t}`+(i?"&prewarm=true":"")),{headers:this.authHeaders(),signal:r},this.readTimeoutMs,async s=>(await io(s,"GET","/snapshot"),by(await s.json())))}async postTask(t){let r=await fetch(this.p("/tasks"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});return await io(r,"POST","/tasks"),(await r.json()).item}async postNudge(t){let r=await fetch(this.p("/nudge"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});await io(r,"POST","/nudge")}async message(t,r){let i=await fetch(this.p("/message"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:r});return await io(i,"POST","/message"),await i.json()}async messageStream(t,r,i){let s=await fetch(this.p("/message/stream"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:i});if(await io(s,"POST","/message/stream"),!s.body)throw new Error("Manager stream returned no response body");let a=h=>{if(!i?.aborted)if(h.type==="phase"){let y=Number(h.quiet_s??0);r.onPhase?.(String(h.label??""),String(h.role??"manager"),{heartbeat:h.heartbeat===!0,quietS:Number.isFinite(y)?y:0,kind:String(h.kind??""),detail:String(h.detail??"")})}else h.type==="delta"?r.onDelta?.(String(h.text??""),String(h.message_id??""),String(h.fragment_mode??"auto")):h.type==="done"?r.onDone?.(h.result??{}):h.type==="error"&&r.onError?.(new Error(String(h.error??"stream error")))},u=s.body.getReader(),E=new TextDecoder,m="";for(;;){let{done:h,value:y}=await u.read();if(h)break;m+=E.decode(y,{stream:!0});let D=ky(m);m=D.rest,D.frames.forEach(a)}i?.aborted||ky(m+` diff --git a/frontend/web/dist/assets/MapPanel-aVcW4FvE.js b/frontend/web/dist/assets/MapPanel-psIb5IiP.js similarity index 99% rename from frontend/web/dist/assets/MapPanel-aVcW4FvE.js rename to frontend/web/dist/assets/MapPanel-psIb5IiP.js index 4a7a56e72..030273500 100644 --- a/frontend/web/dist/assets/MapPanel-aVcW4FvE.js +++ b/frontend/web/dist/assets/MapPanel-psIb5IiP.js @@ -1,4 +1,4 @@ -import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,k as r}from"./icons-2gFhc0pq.js";import{g as i,i as a,n as o}from"./query-CGMsBv4s.js";import{i as s,r as c}from"./markdown-BtnlLdzu.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./square-xdbdHi0S.js";import{A as _,C as v,D as y,E as b,I as x,S,T as C,_ as w,b as T,c as E,d as D,g as O,j as k,k as A,l as j,m as M,n as N,o as P,p as F,r as I,s as L,t as R,u as z,v as B,w as V,x as H,y as U}from"./index-TnyRuCvG.js";var ee=O(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),W=O(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),te=O(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ne=O(`CornerDownLeft`,[[`polyline`,{points:`9 10 4 15 9 20`,key:`r3jprv`}],[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}]]),re=O(`LocateFixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),G=O(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),ie=O(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),K=r();function ae({events:e,connected:t,pending:n,artifacts:r,zh:i,onClose:a,onOpenArtifact:o,onOpenDelivery:s}){let c=e.filter(e=>e.type===`ui.operator`||e.type===`ui.argus`);return(0,K.jsxs)(`aside`,{className:`map-conversation nowheel nodrag nopan`,"aria-label":i?`地图对话`:`Map conversation`,children:[(0,K.jsxs)(`header`,{children:[(0,K.jsx)(G,{size:16}),(0,K.jsx)(`strong`,{children:i?`与 Argus 对话`:`Talk to Argus`}),(0,K.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i?`关闭对话`:`Close conversation`,children:(0,K.jsx)(P,{size:18})})]}),c.length?(0,K.jsx)(V,{events:c,connected:t,showReasoning:!1,onToggleReasoning:()=>{},embedded:!0,showHeader:!1,artifacts:r,onOpenArtifact:o,onOpenDelivery:s}):(0,K.jsx)(`p`,{className:`map-conversation-empty`,children:i?`在下方发送目标或问题,回复会保留在这里。`:`Send a goal or question below. Your conversation stays here.`}),n&&(0,K.jsx)(`p`,{className:`map-conversation-pending`,role:`status`,children:i?`Argus 正在回复…`:`Argus is replying…`})]})}var q=e(n(),1),J=x(),oe=(e,t,n)=>e+(t-e)*n,se=e=>e*e*(3-2*e),ce=(e,t,n)=>Math.max(t,Math.min(n,e));function le(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y),i=Math.min(140,Math.max(54,r*.22))*(t.x>=e.x?-1:1),a=Math.min(120,r*.3),o={x:ce(e.x+i,28,n-28),y:e.y-a},s={x:ce(t.x+i*.6,28,n-28),y:t.y+a};return n=>{let r=1-n;return{x:r**3*e.x+3*r**2*n*o.x+3*r*n**2*s.x+n**3*t.x,y:r**3*e.y+3*r**2*n*o.y+3*r*n**2*s.y+n**3*t.y}}}function ue({flight:e,canvas:t,zh:n,historical:r=!1,onReveal:i,onLand:a,onFinish:o}){let s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=`dispatch-wake-${(0,q.useId)().replace(/:/g,``)}`,f=(0,q.useRef)({onReveal:i,onLand:a,onFinish:o});f.current={onReveal:i,onLand:a,onFinish:o};let p=e.result?.type===`task`&&!r;return(0,q.useEffect)(()=>{if(!e.result)return;let n=0,i,a,o=()=>f.current.onFinish(e.id);if(e.result.type!==`task`||r)return i=setTimeout(o,2200),()=>clearTimeout(i);let d=s.current;if(!d)return;let p=e.result.taskId,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=t.current,g=()=>{cancelAnimationFrame(n),clearTimeout(i),f.current.onLand(e.id),o()};h?.addEventListener(`pointerdown`,g,{once:!0}),h?.addEventListener(`wheel`,g,{once:!0,passive:!0});let _=performance.now(),v=0,y=!1,b=0,x,S=r=>{if(r-_>6e3){o();return}let s=t.current?.querySelector(`.map-macro[data-task-id="${CSS.escape(p)}"]`);if(!s||s.getBoundingClientRect().width<8){r-v>600&&(f.current.onReveal(p),v=r),n=requestAnimationFrame(S);return}if(m){f.current.onLand(e.id),i=setTimeout(o,1200);return}y||(f.current.onReveal(p),y=!0,v=r);let h=s.getBoundingClientRect();if((!x||Math.abs(x.x-h.x)+Math.abs(x.y-h.y)+Math.abs(x.width-h.width)>.7)&&(b=r),x=h,r-v<360||r-b<100){n=requestAnimationFrame(S);return}let g=t.current?.querySelector(`.map-composer`)?.getBoundingClientRect(),C=g?{x:g.left,y:g.top,width:g.width,height:g.height}:e.origin,w={x:C.x+C.width/2,y:C.y+C.height/2},T={x:w.x,y:w.y-26},E={x:h.left+h.width/2,y:h.top+h.height/2},D=le(T,E,innerWidth),O=Math.min(320,C.width),k=Math.min(68,C.height),A=performance.now(),j=!1,M=t=>{if(!s.isConnected){o();return}let r=Math.min(1,(t-A)/1050),p=se(Math.min(1,r/.22)),m=se(ce((r-.22)/.6,0,1)),h=se(ce((r-.82)/.18,0,1)),g=r<.22?{x:w.x,y:oe(w.y,T.y,p)}:D(m),_=oe(52,22,h),v=oe(O,_,p),y=oe(k,_,p);if(d.style.width=`${v}px`,d.style.height=`${y}px`,d.style.transform=`translate3d(${g.x-v/2}px,${g.y-y/2}px,0)`,d.style.opacity=String(Math.min(1,r/.045)*(1-h)),d.style.setProperty(`--dispatch-copy`,String(1-se(Math.min(1,r/.12)))),d.style.setProperty(`--dispatch-mark`,String(oe(1,.7,h))),d.dataset.phase=r<.22?`compress`:r<.82?`travel`:`arrive`,c.current&&l.current&&r>.22){let e=Math.max(0,m-.16),t=Array.from({length:13},(t,n)=>D(oe(e,m,n/12)));c.current.setAttribute(`d`,t.map((e,t)=>`${t?`L`:`M`} ${e.x} ${e.y}`).join(` `)),c.current.style.opacity=String(.7*(1-h)),l.current.setAttribute(`x1`,String(t[0].x)),l.current.setAttribute(`y1`,String(t[0].y)),l.current.setAttribute(`x2`,String(g.x)),l.current.setAttribute(`y2`,String(g.y))}r>=.82&&!j&&(j=!0,f.current.onLand(e.id),u.current&&(u.current.style.left=`${E.x}px`,u.current.style.top=`${E.y}px`,a=u.current.animate([{transform:`translate(-50%,-50%) scale(.65)`,opacity:.65},{transform:`translate(-50%,-50%) scale(2.8)`,opacity:0}],{duration:650,easing:`cubic-bezier(.16,1,.3,1)`,fill:`both`}))),r<1?n=requestAnimationFrame(M):i=setTimeout(o,550)};n=requestAnimationFrame(M)};return n=requestAnimationFrame(S),()=>{cancelAnimationFrame(n),clearTimeout(i),a?.cancel(),h?.removeEventListener(`pointerdown`,g),h?.removeEventListener(`wheel`,g)}},[e.id,e.result,t,r]),p?(0,J.createPortal)((0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`svg`,{className:`map-dispatch-trail`,"aria-hidden":`true`,children:[(0,K.jsx)(`defs`,{children:(0,K.jsxs)(`linearGradient`,{ref:l,id:d,gradientUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`stop`,{stopColor:`#6fbcce`,stopOpacity:`0`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`#87d9cf`})]})}),(0,K.jsx)(`path`,{ref:c,fill:`none`,stroke:`url(#${d})`,strokeWidth:`2.5`,strokeLinecap:`round`})]}),(0,K.jsxs)(`div`,{ref:s,className:`map-dispatch-flight`,"data-testid":`map-dispatch-flight`,"data-state":`task`,"data-task-id":e.result?.type===`task`?e.result.taskId:void 0,"aria-hidden":`true`,children:[(0,K.jsx)(`div`,{className:`map-dispatch-symbol`,children:(0,K.jsx)(C,{size:25})}),(0,K.jsxs)(`div`,{className:`map-dispatch-copy`,children:[(0,K.jsx)(`strong`,{children:e.text}),(0,K.jsx)(`span`,{children:n?`进入任务地图`:`Into your task map`})]})]}),(0,K.jsx)(`div`,{ref:u,className:`map-dispatch-halo`,"aria-hidden":`true`})]}),document.body):null}function de(e,t,n){let r=e?.model_revision&&e.model_revision!==n,i={...e?.cards};for(let[n,a]of Object.entries(t.cards)){if(r&&i[n]?.model_revision===e.model_revision)continue;let t=i[n];(!t||(a.copy_revision??0)>(t.copy_revision??0)||(a.copy_revision??0)===(t.copy_revision??0)&&(a.generated_at>t.generated_at||a.generated_at===t.generated_at&&!t.input_revision))&&(i[n]=a)}let a=(t.cache_revision??0)<(e?.cache_revision??0);return{...e,...t,cards:i,cache_revision:Math.max(t.cache_revision??0,e?.cache_revision??0),relations:(r||a)&&e?e.relations:t.relations,available:t.available??!0,...r?{model_revision:e.model_revision,available:e.available}:{}}}function fe(e,t,n){let r=n?.cards[e.key],i=t.tasks.find(t=>t.id===e.task_id);if(!r||!i)return!0;let a=[i.id,i.id+`:active`,i.id+`:outcome`].includes(e.key);if(a||!r.task_content_revision||!i.content_revision){if(i.revision&&r.task_revision!==i.revision||a&&r.task_status!==i.status)return!0}else if(r.task_content_revision!==i.content_revision)return!0;let o=r.event_ids||[];return e.event_ids.some(e=>{let n=o.indexOf(e),i=t.events.find(t=>t.id===e);return n<0||r.event_revisions&&i?.revision&&r.event_revisions[n]!==i.revision})||!a&&JSON.stringify(e.event_ids)!==JSON.stringify(o)}var pe=e=>`[[Argus引用 ${JSON.stringify(e)}]]\n`;function me(e){let t=[];return{refs:t,text:e.split(` +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,k as r}from"./icons-2gFhc0pq.js";import{g as i,i as a,n as o}from"./query-CGMsBv4s.js";import{i as s,r as c}from"./markdown-BtnlLdzu.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./square-BJgTpitL.js";import{A as _,C as v,D as y,E as b,I as x,S,T as C,_ as w,b as T,c as E,d as D,g as O,j as k,k as A,l as j,m as M,n as N,o as P,p as F,r as I,s as L,t as R,u as z,v as B,w as V,x as H,y as U}from"./index-DgpjrkHx.js";var ee=O(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),W=O(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),te=O(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ne=O(`CornerDownLeft`,[[`polyline`,{points:`9 10 4 15 9 20`,key:`r3jprv`}],[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}]]),re=O(`LocateFixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),G=O(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),ie=O(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),K=r();function ae({events:e,connected:t,pending:n,artifacts:r,zh:i,onClose:a,onOpenArtifact:o,onOpenDelivery:s}){let c=e.filter(e=>e.type===`ui.operator`||e.type===`ui.argus`);return(0,K.jsxs)(`aside`,{className:`map-conversation nowheel nodrag nopan`,"aria-label":i?`地图对话`:`Map conversation`,children:[(0,K.jsxs)(`header`,{children:[(0,K.jsx)(G,{size:16}),(0,K.jsx)(`strong`,{children:i?`与 Argus 对话`:`Talk to Argus`}),(0,K.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i?`关闭对话`:`Close conversation`,children:(0,K.jsx)(P,{size:18})})]}),c.length?(0,K.jsx)(V,{events:c,connected:t,showReasoning:!1,onToggleReasoning:()=>{},embedded:!0,showHeader:!1,artifacts:r,onOpenArtifact:o,onOpenDelivery:s}):(0,K.jsx)(`p`,{className:`map-conversation-empty`,children:i?`在下方发送目标或问题,回复会保留在这里。`:`Send a goal or question below. Your conversation stays here.`}),n&&(0,K.jsx)(`p`,{className:`map-conversation-pending`,role:`status`,children:i?`Argus 正在回复…`:`Argus is replying…`})]})}var q=e(n(),1),J=x(),oe=(e,t,n)=>e+(t-e)*n,se=e=>e*e*(3-2*e),ce=(e,t,n)=>Math.max(t,Math.min(n,e));function le(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y),i=Math.min(140,Math.max(54,r*.22))*(t.x>=e.x?-1:1),a=Math.min(120,r*.3),o={x:ce(e.x+i,28,n-28),y:e.y-a},s={x:ce(t.x+i*.6,28,n-28),y:t.y+a};return n=>{let r=1-n;return{x:r**3*e.x+3*r**2*n*o.x+3*r*n**2*s.x+n**3*t.x,y:r**3*e.y+3*r**2*n*o.y+3*r*n**2*s.y+n**3*t.y}}}function ue({flight:e,canvas:t,zh:n,historical:r=!1,onReveal:i,onLand:a,onFinish:o}){let s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=`dispatch-wake-${(0,q.useId)().replace(/:/g,``)}`,f=(0,q.useRef)({onReveal:i,onLand:a,onFinish:o});f.current={onReveal:i,onLand:a,onFinish:o};let p=e.result?.type===`task`&&!r;return(0,q.useEffect)(()=>{if(!e.result)return;let n=0,i,a,o=()=>f.current.onFinish(e.id);if(e.result.type!==`task`||r)return i=setTimeout(o,2200),()=>clearTimeout(i);let d=s.current;if(!d)return;let p=e.result.taskId,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=t.current,g=()=>{cancelAnimationFrame(n),clearTimeout(i),f.current.onLand(e.id),o()};h?.addEventListener(`pointerdown`,g,{once:!0}),h?.addEventListener(`wheel`,g,{once:!0,passive:!0});let _=performance.now(),v=0,y=!1,b=0,x,S=r=>{if(r-_>6e3){o();return}let s=t.current?.querySelector(`.map-macro[data-task-id="${CSS.escape(p)}"]`);if(!s||s.getBoundingClientRect().width<8){r-v>600&&(f.current.onReveal(p),v=r),n=requestAnimationFrame(S);return}if(m){f.current.onLand(e.id),i=setTimeout(o,1200);return}y||(f.current.onReveal(p),y=!0,v=r);let h=s.getBoundingClientRect();if((!x||Math.abs(x.x-h.x)+Math.abs(x.y-h.y)+Math.abs(x.width-h.width)>.7)&&(b=r),x=h,r-v<360||r-b<100){n=requestAnimationFrame(S);return}let g=t.current?.querySelector(`.map-composer`)?.getBoundingClientRect(),C=g?{x:g.left,y:g.top,width:g.width,height:g.height}:e.origin,w={x:C.x+C.width/2,y:C.y+C.height/2},T={x:w.x,y:w.y-26},E={x:h.left+h.width/2,y:h.top+h.height/2},D=le(T,E,innerWidth),O=Math.min(320,C.width),k=Math.min(68,C.height),A=performance.now(),j=!1,M=t=>{if(!s.isConnected){o();return}let r=Math.min(1,(t-A)/1050),p=se(Math.min(1,r/.22)),m=se(ce((r-.22)/.6,0,1)),h=se(ce((r-.82)/.18,0,1)),g=r<.22?{x:w.x,y:oe(w.y,T.y,p)}:D(m),_=oe(52,22,h),v=oe(O,_,p),y=oe(k,_,p);if(d.style.width=`${v}px`,d.style.height=`${y}px`,d.style.transform=`translate3d(${g.x-v/2}px,${g.y-y/2}px,0)`,d.style.opacity=String(Math.min(1,r/.045)*(1-h)),d.style.setProperty(`--dispatch-copy`,String(1-se(Math.min(1,r/.12)))),d.style.setProperty(`--dispatch-mark`,String(oe(1,.7,h))),d.dataset.phase=r<.22?`compress`:r<.82?`travel`:`arrive`,c.current&&l.current&&r>.22){let e=Math.max(0,m-.16),t=Array.from({length:13},(t,n)=>D(oe(e,m,n/12)));c.current.setAttribute(`d`,t.map((e,t)=>`${t?`L`:`M`} ${e.x} ${e.y}`).join(` `)),c.current.style.opacity=String(.7*(1-h)),l.current.setAttribute(`x1`,String(t[0].x)),l.current.setAttribute(`y1`,String(t[0].y)),l.current.setAttribute(`x2`,String(g.x)),l.current.setAttribute(`y2`,String(g.y))}r>=.82&&!j&&(j=!0,f.current.onLand(e.id),u.current&&(u.current.style.left=`${E.x}px`,u.current.style.top=`${E.y}px`,a=u.current.animate([{transform:`translate(-50%,-50%) scale(.65)`,opacity:.65},{transform:`translate(-50%,-50%) scale(2.8)`,opacity:0}],{duration:650,easing:`cubic-bezier(.16,1,.3,1)`,fill:`both`}))),r<1?n=requestAnimationFrame(M):i=setTimeout(o,550)};n=requestAnimationFrame(M)};return n=requestAnimationFrame(S),()=>{cancelAnimationFrame(n),clearTimeout(i),a?.cancel(),h?.removeEventListener(`pointerdown`,g),h?.removeEventListener(`wheel`,g)}},[e.id,e.result,t,r]),p?(0,J.createPortal)((0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`svg`,{className:`map-dispatch-trail`,"aria-hidden":`true`,children:[(0,K.jsx)(`defs`,{children:(0,K.jsxs)(`linearGradient`,{ref:l,id:d,gradientUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`stop`,{stopColor:`#6fbcce`,stopOpacity:`0`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`#87d9cf`})]})}),(0,K.jsx)(`path`,{ref:c,fill:`none`,stroke:`url(#${d})`,strokeWidth:`2.5`,strokeLinecap:`round`})]}),(0,K.jsxs)(`div`,{ref:s,className:`map-dispatch-flight`,"data-testid":`map-dispatch-flight`,"data-state":`task`,"data-task-id":e.result?.type===`task`?e.result.taskId:void 0,"aria-hidden":`true`,children:[(0,K.jsx)(`div`,{className:`map-dispatch-symbol`,children:(0,K.jsx)(C,{size:25})}),(0,K.jsxs)(`div`,{className:`map-dispatch-copy`,children:[(0,K.jsx)(`strong`,{children:e.text}),(0,K.jsx)(`span`,{children:n?`进入任务地图`:`Into your task map`})]})]}),(0,K.jsx)(`div`,{ref:u,className:`map-dispatch-halo`,"aria-hidden":`true`})]}),document.body):null}function de(e,t,n){let r=e?.model_revision&&e.model_revision!==n,i={...e?.cards};for(let[n,a]of Object.entries(t.cards)){if(r&&i[n]?.model_revision===e.model_revision)continue;let t=i[n];(!t||(a.copy_revision??0)>(t.copy_revision??0)||(a.copy_revision??0)===(t.copy_revision??0)&&(a.generated_at>t.generated_at||a.generated_at===t.generated_at&&!t.input_revision))&&(i[n]=a)}let a=(t.cache_revision??0)<(e?.cache_revision??0);return{...e,...t,cards:i,cache_revision:Math.max(t.cache_revision??0,e?.cache_revision??0),relations:(r||a)&&e?e.relations:t.relations,available:t.available??!0,...r?{model_revision:e.model_revision,available:e.available}:{}}}function fe(e,t,n){let r=n?.cards[e.key],i=t.tasks.find(t=>t.id===e.task_id);if(!r||!i)return!0;let a=[i.id,i.id+`:active`,i.id+`:outcome`].includes(e.key);if(a||!r.task_content_revision||!i.content_revision){if(i.revision&&r.task_revision!==i.revision||a&&r.task_status!==i.status)return!0}else if(r.task_content_revision!==i.content_revision)return!0;let o=r.event_ids||[];return e.event_ids.some(e=>{let n=o.indexOf(e),i=t.events.find(t=>t.id===e);return n<0||r.event_revisions&&i?.revision&&r.event_revisions[n]!==i.revision})||!a&&JSON.stringify(e.event_ids)!==JSON.stringify(o)}var pe=e=>`[[Argus引用 ${JSON.stringify(e)}]]\n`;function me(e){let t=[];return{refs:t,text:e.split(` `).filter(e=>{if(e.startsWith(`[[Argus引用 `)&&e.endsWith(`]]`))try{let n=JSON.parse(e.slice(10,-2));if(typeof n.task_id==`string`&&typeof n.source==`string`&&typeof n.task_title==`string`&&(n.part===void 0||Number.isInteger(n.part)&&n.part>0)&&(n.step_title===void 0||typeof n.step_title==`string`)&&(n.step_id===void 0||typeof n.step_id==`string`)&&(n.team_id===void 0||typeof n.team_id==`string`)&&(n.team_task_id===void 0||typeof n.team_task_id==`string`)&&Array.isArray(n.event_ids)&&n.event_ids.every(e=>typeof e==`string`))return t.push(n),!1}catch{}return!0}).join(` `).replace(/^\n+/,``)}}function he(e,t,n){let r=e.tasks.find(e=>e.id===n),i=r?[r,...e.tasks.filter(e=>e.id!==n)]:e.tasks,a=(t,n=1/0)=>{let r=Math.max(-1/0,...e.events.filter(e=>e.item_id===t&&e.type===`life.mission.started`&&e.ts<=n).map(e=>e.ts));return e.events.filter(e=>e.item_id===t&&e.ts>=r&&e.ts<=n&&[`round.main.completed`,`round.review.completed`].includes(e.type)).slice(-2).map(e=>e.id)},o=i.map(t=>({key:t.id,task_id:t.id,kind:`task`,event_ids:[...new Set([...a(t.id),...e.events.filter(e=>e.item_id===t.id).slice(-2).map(e=>e.id)])]})),s=r?t.map(e=>({key:e.id,task_id:r.id,kind:e.kind,event_ids:[...new Set([...e.kind===`result`?a(r.id,e.ts):[],...e.eventIds])].slice(-16)})):[];return[...o.slice(0,1),...s,...o.slice(1)]}var ge=()=>({revision:0,cards:{},steps:{},links:{}}),_e=(e,t)=>`${e}\u0000${t}`,ve=class{initialized=!1;seen=new Set;revision=0;loadingHistory=!1;observe(e,t=!1){let n=ge(),r=0;for(let t of e.cards){this.seen.has(`card:${t.id}`)||(n.cards[t.id]=Math.min(r++*100,400)),this.seen.add(`card:${t.id}`);let i=e.layouts[t.id],a=0;for(let e of i.steps){let r=_e(t.id,e.id);this.seen.has(`step:${r}`)||(n.steps[r]=160+Math.min(a++*120,720)),this.seen.add(`step:${r}`)}for(let e of i.links){let r=_e(t.id,e.id);this.seen.has(`link:${r}`)||(n.links[r]=Math.max(0,(n.steps[_e(t.id,e.target)]??160)-160)),this.seen.add(`link:${r}`)}}for(let t of e.links)this.seen.has(`outer:${t.id}`)||(n.links[t.id]=0),this.seen.add(`outer:${t.id}`);let i=!this.initialized||t||this.loadingHistory;return this.loadingHistory=t,this.initialized=!0,i||![n.cards,n.steps,n.links].some(e=>Object.keys(e).length)?null:{...n,revision:++this.revision}}};function ye(e,t=!1){let n=(0,q.useRef)(new ve),r=(0,q.useRef)(new Set),[i,a]=(0,q.useState)(ge);return(0,q.useEffect)(()=>{let i=n.current.observe(e,t);if(t)r.current.forEach(clearTimeout),r.current.clear(),a(ge());else if(i){a(e=>({revision:i.revision,cards:{...e.cards,...i.cards},steps:{...e.steps,...i.steps},links:{...e.links,...i.links}}));let e=setTimeout(()=>{r.current.delete(e),a(e=>({revision:e.revision,cards:Object.fromEntries(Object.entries(e.cards).filter(([e])=>!(e in i.cards))),steps:Object.fromEntries(Object.entries(e.steps).filter(([e])=>!(e in i.steps))),links:Object.fromEntries(Object.entries(e.links).filter(([e])=>!(e in i.links)))}))},2e3);r.current.add(e)}},[e,t]),(0,q.useEffect)(()=>()=>{r.current.forEach(clearTimeout),r.current.clear()},[]),i}function Y(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n{}};function xe(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Se.prototype=xe.prototype={constructor:Se,on:function(e,t){var n=this._,r=Ce(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Ee.hasOwnProperty(t)?{space:Ee[t],local:e}:e}function Oe(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function ke(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ae(e){var t=De(e);return(t.local?ke:Oe)(t)}function je(){}function Me(e){return e==null?je:function(){return this.querySelector(e)}}function Ne(e){typeof e!=`function`&&(e=Me(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function lt(e){e||=ut;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function dt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ft(){return Array.from(this)}function pt(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Tt:typeof t==`function`?Dt:Et)(e,t,n??``)):kt(this.node(),e)}function kt(e,t){return e.style.getPropertyValue(t)||wt(e).getComputedStyle(e,null).getPropertyValue(t)}function At(e){return function(){delete this[e]}}function jt(e,t){return function(){this[e]=t}}function Mt(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Nt(e,t){return arguments.length>1?this.each((t==null?At:typeof t==`function`?Mt:jt)(e,t)):this.node()[e]}function Pt(e){return e.trim().split(/^|\s+/)}function Ft(e){return e.classList||new It(e)}function It(e){this._node=e,this._names=Pt(e.getAttribute(`class`)||``)}It.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Lt(e,t){for(var n=Ft(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function pn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function Fn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Fn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function In(e){return!e.ctrlKey&&!e.button}function Ln(){return this.parentNode}function Rn(e,t){return t??{x:e.x,y:e.y}}function zn(){return navigator.maxTouchPoints||`ontouchstart`in this}function Bn(){var e=In,t=Ln,n=Rn,r=zn,i={},a=xe(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,On).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(Tn(n.view).on(`mousemove.drag`,m,kn).on(`mouseup.drag`,h,kn),Mn(n.view),An(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(jn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){Tn(e.view).on(`mousemove.drag mouseup.drag`,null),Nn(e.view,l),jn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?lr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?lr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Xn.exec(e))?new fr(t[1],t[2],t[3],1):(t=Zn.exec(e))?new fr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Qn.exec(e))?lr(t[1],t[2],t[3],t[4]):(t=$n.exec(e))?lr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=er.exec(e))?yr(t[1],t[2]/100,t[3]/100,1):(t=tr.exec(e))?yr(t[1],t[2]/100,t[3]/100,t[4]):nr.hasOwnProperty(e)?cr(nr[e]):e===`transparent`?new fr(NaN,NaN,NaN,0):null}function cr(e){return new fr(e>>16&255,e>>8&255,e&255,1)}function lr(e,t,n,r){return r<=0&&(e=t=n=NaN),new fr(e,t,n,r)}function ur(e){return e instanceof Un||(e=sr(e)),e?(e=e.rgb(),new fr(e.r,e.g,e.b,e.opacity)):new fr}function dr(e,t,n,r){return arguments.length===1?ur(e):new fr(e,t,n,r??1)}function fr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Vn(fr,dr,Hn(Un,{brighter(e){return e=e==null?Gn:Gn**+e,new fr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Wn:Wn**+e,new fr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new fr(_r(this.r),_r(this.g),_r(this.b),gr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pr,formatHex:pr,formatHex8:mr,formatRgb:hr,toString:hr}));function pr(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}`}function mr(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}${vr((isNaN(this.opacity)?1:this.opacity)*255)}`}function hr(){let e=gr(this.opacity);return`${e===1?`rgb(`:`rgba(`}${_r(this.r)}, ${_r(this.g)}, ${_r(this.b)}${e===1?`)`:`, ${e})`}`}function gr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function _r(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function vr(e){return e=_r(e),(e<16?`0`:``)+e.toString(16)}function yr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Sr(e,t,n,r)}function br(e){if(e instanceof Sr)return new Sr(e.h,e.s,e.l,e.opacity);if(e instanceof Un||(e=sr(e)),!e)return new Sr;if(e instanceof Sr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new Sr(o,s,c,e.opacity)}function xr(e,t,n,r){return arguments.length===1?br(e):new Sr(e,t,n,r??1)}function Sr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Vn(Sr,xr,Hn(Un,{brighter(e){return e=e==null?Gn:Gn**+e,new Sr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Wn:Wn**+e,new Sr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new fr(Tr(e>=240?e-240:e+120,i,r),Tr(e,i,r),Tr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Sr(Cr(this.h),wr(this.s),wr(this.l),gr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=gr(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Cr(this.h)}, ${wr(this.s)*100}%, ${wr(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Cr(e){return e=(e||0)%360,e<0?e+360:e}function wr(e){return Math.max(0,Math.min(1,e||0))}function Tr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Er=e=>()=>e;function Dr(e,t){return function(n){return e+n*t}}function Or(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function kr(e){return(e=+e)==1?Ar:function(t,n){return n-t?Or(t,n,e):Er(isNaN(t)?n:t)}}function Ar(e,t){var n=t-e;return n?Dr(e,n):Er(isNaN(e)?t:e)}var jr=(function e(t){var n=kr(t);function r(e,t){var r=n((e=dr(e)).r,(t=dr(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Ar(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Mr(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Ir(r,i)})),n=zr.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Ir(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Ir(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Ir(e,n)},{i:s-2,x:Ir(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--ii}function bi(){di=(ui=pi.now())+fi,ii=ai=0;try{yi()}finally{ii=0,Si(),di=0}}function xi(){var e=pi.now(),t=e-ui;t>si&&(fi-=t,ui=e)}function Si(){for(var e,t=ci,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ci=n);li=e,Ci(r)}function Ci(e){ii||(ai&&=clearTimeout(ai),e-di>24?(e<1/0&&(ai=setTimeout(bi,e-pi.now()-fi)),oi&&=clearInterval(oi)):(oi||=(ui=pi.now(),setInterval(xi,si)),ii=1,mi(bi)))}function wi(e,t,n){var r=new _i;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Ti=xe(`start`,`end`,`cancel`,`interrupt`),Ei=[];function Di(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ji(e,n,{name:t,index:r,group:i,on:Ti,tween:Ei,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Oi(e,t){var n=Ai(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function ki(e,t){var n=Ai(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Ai(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function ji(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=vi(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return wi(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Ni(e){return this.each(function(){Mi(this,e)})}function Pi(e,t){var n,r;return function(){var i=ki(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function ua(e,t,n){var r,i,a=la(t)?Oi:ki;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function da(e,t){var n=this._id;return arguments.length<2?Ai(this.node(),n).on.on(e):this.each(ua(n,e,t))}function fa(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function pa(){return this.on(`end.remove`,fa(this._id))}function ma(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Me(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function Wa(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ga(e,t,n){this.k=e,this.x=t,this.y=n}Ga.prototype={constructor:Ga,scale:function(e){return e===1?this:new Ga(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ga(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var Ka=new Ga(1,0,0);qa.prototype=Ga.prototype;function qa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ka;return e.__zoom}function Ja(e){e.stopImmediatePropagation()}function Ya(e){e.preventDefault(),e.stopImmediatePropagation()}function Xa(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Za(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Qa(){return this.__zoom||Ka}function $a(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function eo(){return navigator.maxTouchPoints||`ontouchstart`in this}function to(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function no(){var e=Xa,t=Za,n=to,r=$a,i=eo,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=ri,l=xe(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Qa).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Qa),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ka.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ga(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ga(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ga(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Tn(this.that).datum();l.call(e,this.that,new Wa(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Dn(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Mi(this),s.start();Ya(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Tn(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Dn(t,i),l=t.clientX,u=t.clientY;Mn(t.view),Ja(t),a.mouse=[c,this.__zoom.invert(c)],Mi(this),a.start();function d(e){if(Ya(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Dn(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),Nn(e.view,a.moved),Ya(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Dn(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Ya(r),s>0?Tn(this).transition().duration(s).call(x,d,c,r):Tn(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Ja(t),s=0;s`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},io=[[-1/0,-1/0],[1/0,1/0]],ao=[`Enter`,` `,`Escape`],oo={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},so;(function(e){e.Strict=`strict`,e.Loose=`loose`})(so||={});var co;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(co||={});var lo;(function(e){e.Partial=`partial`,e.Full=`full`})(lo||={});var uo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},fo;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(fo||={});var po;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(po||={});var X;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(X||={});var mo={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ho(e){return e===null?null:e?`valid`:`invalid`}var go=e=>`id`in e&&`source`in e&&`target`in e,_o=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),vo=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),yo=(e,t=[0,0])=>{let{width:n,height:r}=$o(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},bo=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Fo(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):vo(n)?n:t.nodeLookup.get(n.id)),No(e,i?Lo(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),xo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=No(n,Lo(e)),r=!0)}),r?Fo(n):{x:0,y:0,width:0,height:0}},So=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=zo(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},Co=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function wo(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function To({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Xo(xo(wo(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function Eo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,ro.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Qo(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Qo(d)?ko(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,ro.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Do({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Co(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var Oo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ko=(e={x:0,y:0},t,n)=>({x:Oo(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Oo(e.y,t[0][1],t[1][1]-(n?.height??0))});function Ao(e,t,n){let{width:r,height:i}=$o(n),{x:a,y:o}=n.internals.positionAbsolute;return ko(e,[[a,o],[a+r,o+i]],t)}var jo=(e,t,n)=>en?-Oo(Math.abs(e-n),1,t)/t:0,Mo=(e,t,n=15,r=40)=>[jo(e.x,r,t.width-r)*n,jo(e.y,r,t.height-r)*n],No=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Po=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Fo=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Io=(e,t=[0,0])=>{let{x:n,y:r}=vo(e)?e.internals.positionAbsolute:yo(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Lo=(e,t=[0,0])=>{let{x:n,y:r}=vo(e)?e.internals.positionAbsolute:yo(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Ro=(e,t)=>Fo(No(Po(e),Po(t))),zo=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Bo=(e,t)=>zo(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Vo=e=>Ho(e.width)&&Ho(e.height)&&Ho(e.x)&&Ho(e.y),Ho=e=>!isNaN(e)&&isFinite(e),Uo=(e,t)=>(e,t)=>{},Wo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Go=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Wo(s,o):s},Ko=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function qo(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Jo(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=qo(e,n),i=qo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=qo(e.top??e.y??0,n),i=qo(e.bottom??e.y??0,n),a=qo(e.left??e.x??0,t),o=qo(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Yo(e,t,n,r,i,a){let{x:o,y:s}=Ko(e,[t,n,r]),{x:c,y:l}=Ko({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Xo=(e,t,n,r,i,a)=>{let o=Jo(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Oo(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Yo(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Zo=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Qo(e){return e!=null&&e!==`parent`}function $o(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function es(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function ts(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function ns(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function rs(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function is(e){return{...oo,...e||{}}}function as(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=ds(e),s=Go({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Wo(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var os=e=>({width:e.offsetWidth,height:e.offsetHeight}),ss=e=>e?.getRootNode?.()||window?.document,cs=[`INPUT`,`SELECT`,`TEXTAREA`];function ls(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?cs.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var us=e=>`clientX`in e,ds=(e,t)=>{let n=us(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},fs=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...os(t)}})};function ps({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function ms(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function hs({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case X.Left:return[t-ms(t-r,a),n];case X.Right:return[t+ms(r-t,a),n];case X.Top:return[t,n-ms(n-i,a)];case X.Bottom:return[t,n+ms(i-n,a)]}}function gs({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:i,targetPosition:a=X.Top,curvature:o=.25}){let[s,c]=hs({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=hs({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=ps({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function _s({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n0}var bs=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,xs=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Ss=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,ro.error006()),t;let r=n.getEdgeId||bs,i;return i=go(e)?{...e}:{...e,id:r(e)},xs(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Cs({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=_s({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var ws={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},Ts=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.xMath.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Ds({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:r=X.Top,center:i,offset:a,stepPosition:o}){let s=ws[t],c=ws[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Ts({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=_s({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function Os(e,t,n,r){let i=Math.min(Es(e,t)/2,Es(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.xe.id===t):e[0])||null}function Fs(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Is(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Fs(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Ls=1e3,Rs=10,zs={nodeOrigin:[0,0],nodeExtent:io,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Bs={...zs,checkEquality:!0};function Vs(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Hs(e,t,n){let r=Vs(zs,n);for(let n of e.values())if(n.parentId)qs(n,e,t,r);else{let e=ko(yo(n,r.nodeOrigin),Qo(n.extent)?n.extent:r.nodeExtent,$o(n));n.internals.positionAbsolute=e}}function Us(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function Ws(e){return e===`manual`}function Gs(e,t,n,r={}){let i=Vs(Bs,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Ws(i.zIndexMode)?Ls:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=ko(yo(u,i.nodeOrigin),Qo(u.extent)?u.extent:i.nodeExtent,$o(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Us(u,e),z:Js(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&qs(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Ks(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function qs(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Vs(zs,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ks(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Rs),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Ys(e,u,o,s,a&&!Ws(c)?Ls:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Js(e,t,n){let r=Ho(e.zIndex)?e.zIndex:0;return Ws(n)?r:r+(e.selected?t:0)}function Ys(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=$o(e),l=yo(e,n),u=Qo(e.extent)?ko(l,e.extent,c):l,d=ko({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Ao(d,c,t));let f=Js(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Xs(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Ro(a.get(n.parentId)?.expandedRect??Io(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=$o(a),l=a.origin??r,u=t.x0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width0){let e=Xs(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Qs({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function $s(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function ec(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;$s(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),$s(`target`,s,c,e,i,o),t.set(r.id,r)}}function tc(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:tc(n,t):!1}function nc(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function rc(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!tc(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function ic({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function ac({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Wo(a,t);return{x:o.x-a.x,y:o.y-a.y}}function oc({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=Tn(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Po(xo(s)):null,x=v&&l?ac({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Wo(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=Eo({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=ic({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=Mo(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=as(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=rc(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=ic({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Bn().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=as(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=ds(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=as(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=ds(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=ds(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=ic({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!nc(t,`.${g}`,v))&&(!_||nc(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function sc(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Bo(i,Io(e))>0&&r.push(e);return r}var cc=250;function lc(e,t,n,r){let i=[],a=1/0,o=sc(e,n,t+cc);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Ns(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function uc(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Ns(o,c,c.position,!0)}:c}function dc(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function fc(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var pc=()=>!0;function mc(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=pc,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=ss(e.target),E=0,D,{x:O,y:k}=ds(e),A=dc(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=uc(i,A,r,c,t);if(!N)return;let P=ds(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=Mo(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:Ns(V,B,X.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:mo[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function ee(e){if(!M){let{x:t,y:n}=ds(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){W(e);return}let a=b();P=ds(e,j),D=lc(Go(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=hc(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=fc(!!D,s.isValid);let u=c.get(i),f=u?Ns(u,B,X.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?Ko({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:mo[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function W(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ee),T.removeEventListener(`mouseup`,W),T.removeEventListener(`touchmove`,ee),T.removeEventListener(`touchend`,W)}}T.addEventListener(`mousemove`,ee),T.addEventListener(`mouseup`,W),T.addEventListener(`touchmove`,ee),T.addEventListener(`touchend`,W)}function hc(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=pc,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=ds(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=dc(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===so.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=uc(t,e,a,u,n,!0)}return _}var gc={onPointerDown:mc,isValid:hc};function _c({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=Tn(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Zo()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=no().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Dn}}var vc=e=>({x:e.x,y:e.y,zoom:e.k}),yc=({x:e,y:t,zoom:n})=>Ka.translate(e,t).scale(n),bc=(e,t)=>e.target.closest(`.${t}`),xc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Sc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Cc=(e,t=0,n=Sc,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},wc=e=>{let t=e.ctrlKey&&Zo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Tc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(bc(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Dn(u),t=d*2**wc(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===co.Vertical?0:u.deltaX*f,m=i===co.Horizontal?0:u.deltaY*f;!Zo()&&u.shiftKey&&i!==co.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=vc(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function Ec({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=bc(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Dc({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=vc(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Oc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&xc(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,vc(a.transform))}}function kc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&xc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=vc(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Ac({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(bc(d,`${l}-flow__node`)||bc(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||bc(d,s)&&m||bc(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function jc({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=no().scaleExtent([t,n]).translateExtent(r),f=Tn(e).call(d);v({x:i.x,y:i.y,zoom:Oo(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(wc);async function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Ur:ri).transform(Cc(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Ho(E)||E<0?0:E);let k=O?Tc({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Ec({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});f.on(`wheel.zoom`,k,{passive:!1});let A=Dc({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,A);let j=Oc({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,j);let M=kc({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,M);let N=Ac({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(N),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=yc(e),i=d?.constrain()(r,t,n);return i&&await h(i),i}async function y(e,t){let n=yc(e);return await h(n,t),n}function b(e){if(f){let t=yc(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?qa(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Ur:ri).scaleTo(Cc(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Ur:ri).scaleBy(Cc(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Ho(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var Mc;(function(e){e.Line=`line`,e.Handle=`handle`})(Mc||={});function Nc({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function Pc(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Fc(e,t){return Math.max(0,t-e)}function Ic(e,t){return Math.max(0,e-t)}function Lc(e,t,n){return Math.max(0,t-e,e-n)}function Rc(e,t){return e?!t:t}function zc(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Lc(E,h,g),j=Lc(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Fc(y+w+O,o[0][0]):!c&&w>0&&(e=Ic(y+E+O,o[1][0])),l&&T<0?t=Fc(b+T+k,o[0][1]):!l&&T>0&&(t=Ic(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=Ic(y+w,s[0][0]):!c&&w<0&&(e=Fc(y+E,s[1][0])),l&&T>0?t=Ic(b+T,s[0][1]):!l&&T<0&&(t=Fc(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Lc(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Ic(b+k+E/C,o[1][1])*C:Fc(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Fc(b+E/C,s[1][1])*C:Ic(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Lc(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Ic(y+D*C+O,o[1][0])/C:Fc(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Fc(y+D*C,s[1][0])/C:Ic(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Rc(c,l)?-w:w)/C:w=(Rc(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Bc={width:0,height:0,x:0,y:0},Vc={...Bc,pointerX:0,pointerY:0,aspectRatio:1};function Hc(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Uc({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=Tn(e),o={controlDirection:Pc(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Bc},h={...Vc};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Pc(e)};let g,_=null,v=[],y,b,x,S=!1,C=Bn().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=as(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Qo(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Hc(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=as(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=zc(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var Wc=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Gc=t(((e,t)=>{t.exports=Wc()})),Kc=t((e=>{var t=n(),r=Gc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),qc=e(t(((e,t)=>{t.exports=Kc()}))(),1),Jc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Yc=e=>e?Jc(e):Jc,{useDebugValue:Xc}=q.default,{useSyncExternalStoreWithSelector:Zc}=qc.default,Qc=e=>e;function $c(e,t=Qc,n){let r=Zc(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Xc(r),r}var el=(e,t)=>{let n=Yc(e),r=(e,r=t)=>$c(n,e,r);return Object.assign(r,n),r},tl=(e,t)=>e?el(e,t):el;function Z(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var nl=(0,q.createContext)(null),rl=nl.Provider,il=ro.error001(`react`);function Q(e,t){let n=(0,q.useContext)(nl);if(n===null)throw Error(il);return $c(n,e,t)}function $(){let e=(0,q.useContext)(nl);if(e===null)throw Error(il);return(0,q.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var al={display:`none`},ol={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},sl=`react-flow__node-desc`,cl=`react-flow__edge-desc`,ll=`react-flow__aria-live`,ul=e=>e.ariaLiveMessage,dl=e=>e.ariaLabelConfig;function fl({rfId:e}){let t=Q(ul);return(0,K.jsx)(`div`,{id:`${ll}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:ol,children:t})}function pl({rfId:e,disableKeyboardA11y:t}){let n=Q(dl);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{id:`${sl}-${e}`,style:al,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,K.jsx)(`div`,{id:`${cl}-${e}`,style:al,children:n[`edge.a11yDescription.default`]}),!t&&(0,K.jsx)(fl,{rfId:e})]})}var ml=(0,q.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,K.jsx)(`div`,{className:Y([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});ml.displayName=`Panel`;var hl=`https://reactflow.dev?utm_source=attribution`;function gl({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,K.jsx)(ml,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${hl}`,children:(0,K.jsx)(`a`,{href:hl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var _l=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},vl=e=>e.id;function yl(e,t){return Z(e.selectedNodes.map(vl),t.selectedNodes.map(vl))&&Z(e.selectedEdges.map(vl),t.selectedEdges.map(vl))}function bl({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(_l,yl);return(0,q.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var xl=e=>!!e.onSelectionChangeHandlers;function Sl({onSelectionChange:e}){let t=Q(xl);return e||t?(0,K.jsx)(bl,{onSelectionChange:e}):null}var Cl=[0,0],wl={x:0,y:0,zoom:1},Tl=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],El=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Dl={translateExtent:io,nodeOrigin:Cl,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ol(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(El,Z),l=$();(0,q.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Dl,s()}),[]);let u=(0,q.useRef)(Dl);return(0,q.useEffect)(()=>{for(let s of Tl){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:is(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Tl.map(t=>e[t])),null}function kl(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Al(e){let[t,n]=(0,q.useState)(e===`system`?null:e);return(0,q.useEffect)(()=>{if(e!==`system`){n(e);return}let t=kl(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?kl()?.matches?`dark`:`light`:t}var jl=typeof document<`u`?document:null;function Ml(e=null,t={target:jl,actInsideInputWithModifier:!0}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(!1),a=(0,q.useRef)(new Set([])),[o,s]=(0,q.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,` `).replace(` diff --git a/frontend/web/dist/assets/ResearchWorkbenchPanel-BemKoueL.js b/frontend/web/dist/assets/ResearchWorkbenchPanel-CWXTxKbh.js similarity index 99% rename from frontend/web/dist/assets/ResearchWorkbenchPanel-BemKoueL.js rename to frontend/web/dist/assets/ResearchWorkbenchPanel-CWXTxKbh.js index c918ab627..5f1e38d94 100644 --- a/frontend/web/dist/assets/ResearchWorkbenchPanel-BemKoueL.js +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-CWXTxKbh.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-DN4bD3_L.js","assets/index-TnyRuCvG.js","assets/rolldown-runtime-hePW80VL.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/index-CErSsMQS.css"])))=>i.map(i=>d[i]); -import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,k as n}from"./icons-2gFhc0pq.js";import{i as r,n as i,t as a}from"./query-CGMsBv4s.js";import{i as o,n as s,r as c,t as l}from"./markdown-BtnlLdzu.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./square-xdbdHi0S.js";import{A as v,F as y,M as b,N as x,O as S,P as C,T as w,a as T,c as E,d as D,f as ee,g as O,h as k,i as te,m as A,n as j,o as M,p as ne,s as N,t as re,u as P}from"./index-TnyRuCvG.js";var F=O(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ie=O(`AudioLines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),I=O(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),L=O(`Calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),ae=O(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),oe=O(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),se=O(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ce=O(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),le=O(`FileCheck2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m3 15 2 2 4-4`,key:`1lhrkk`}]]),ue=O(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),de=O(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),fe=O(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),pe=O(`FileSearch2`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]),me=O(`FileSearch`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3`,key:`ms7g94`}],[`path`,{d:`m9 18-1.5-1.5`,key:`1j6qii`}],[`circle`,{cx:`5`,cy:`14`,r:`3`,key:`ufru5t`}]]),he=O(`FileUp`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),ge=O(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),_e=O(`Files`,[[`path`,{d:`M20 7h-3a2 2 0 0 1-2-2V2`,key:`x099mo`}],[`path`,{d:`M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z`,key:`18t6ie`}],[`path`,{d:`M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8`,key:`1nja0z`}]]),ve=O(`FlaskConical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),ye=O(`FolderKanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),be=O(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),xe=O(`FolderSearch`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),Se=O(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Ce=O(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),we=O(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),Te=O(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Ee=O(`Image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),De=O(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),Oe=O(`Lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),ke=O(`Link2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ae=O(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),je=O(`ListFilter`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M10 18h4`,key:`1ulq68`}]]),Me=O(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ne=O(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),Pe=O(`Megaphone`,[[`path`,{d:`m3 11 18-5v12L3 14v-3z`,key:`n962bs`}],[`path`,{d:`M11.6 16.8a3 3 0 1 1-5.8-1.6`,key:`1yl0tm`}]]),Fe=O(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),Ie=O(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Le=O(`Paperclip`,[[`path`,{d:`M13.234 20.252 21 12.3`,key:`1cbrk9`}],[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486`,key:`1pkts6`}]]),Re=O(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ze=O(`Presentation`,[[`path`,{d:`M2 3h20`,key:`91anmk`}],[`path`,{d:`M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3`,key:`2k9sn8`}],[`path`,{d:`m7 21 5-5 5 5`,key:`bip4we`}]]),Be=O(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),Ve=O(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),He=O(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Ue=O(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),We=O(`Scale`,[[`path`,{d:`m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`7g6ntu`}],[`path`,{d:`m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`ijws7r`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2`,key:`3gwbw2`}]]),Ge=O(`Send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ke=O(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),R=O(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),qe=O(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Je=O(`Table2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),Ye=O(`Target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Xe=O(`TimerReset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]),Ze=O(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Qe=O(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),$e=O(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),et=O(`UserRound`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),tt=O(`WandSparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),nt=O(`Watch`,[[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`polyline`,{points:`12 10 12 12 13 13`,key:`19dquz`}],[`path`,{d:`m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05`,key:`18k57s`}],[`path`,{d:`m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05`,key:`16ny36`}]]),rt=O(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),it=O(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),z=e(t(),1),at=12e3;function ot(e=!1){let t={...b()};return e&&(t[`Content-Type`]=`application/json`),t}async function B(e,t={}){await C();let n={...t,headers:{...ot(!!t.body),...t.headers??{}},cache:`no-store`},r=String(t.method??`GET`).toUpperCase(),i=async n=>{if(!n.ok){let r=await n.text().catch(()=>``),i=r;try{i=JSON.parse(r).detail??r}catch{}throw Error(i||`${t.method??`GET`} ${e} failed (${n.status})`)}return await n.json()};return r===`GET`?y(e,n,at,i):i(await fetch(e,n))}var V=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,st=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`;function ct(e){let t=e.replaceAll(`\r +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-Bit9sP4D.js","assets/index-DgpjrkHx.js","assets/rolldown-runtime-hePW80VL.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/index-CErSsMQS.css"])))=>i.map(i=>d[i]); +import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,k as n}from"./icons-2gFhc0pq.js";import{i as r,n as i,t as a}from"./query-CGMsBv4s.js";import{i as o,n as s,r as c,t as l}from"./markdown-BtnlLdzu.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./square-BJgTpitL.js";import{A as v,F as y,M as b,N as x,O as S,P as C,T as w,a as T,c as E,d as D,f as ee,g as O,h as k,i as te,m as A,n as j,o as M,p as ne,s as N,t as re,u as P}from"./index-DgpjrkHx.js";var F=O(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ie=O(`AudioLines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),I=O(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),L=O(`Calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),ae=O(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),oe=O(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),se=O(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ce=O(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),le=O(`FileCheck2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m3 15 2 2 4-4`,key:`1lhrkk`}]]),ue=O(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),de=O(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),fe=O(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),pe=O(`FileSearch2`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]),me=O(`FileSearch`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3`,key:`ms7g94`}],[`path`,{d:`m9 18-1.5-1.5`,key:`1j6qii`}],[`circle`,{cx:`5`,cy:`14`,r:`3`,key:`ufru5t`}]]),he=O(`FileUp`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),ge=O(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),_e=O(`Files`,[[`path`,{d:`M20 7h-3a2 2 0 0 1-2-2V2`,key:`x099mo`}],[`path`,{d:`M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z`,key:`18t6ie`}],[`path`,{d:`M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8`,key:`1nja0z`}]]),ve=O(`FlaskConical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),ye=O(`FolderKanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),be=O(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),xe=O(`FolderSearch`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),Se=O(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Ce=O(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),we=O(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),Te=O(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Ee=O(`Image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),De=O(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),Oe=O(`Lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),ke=O(`Link2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ae=O(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),je=O(`ListFilter`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M10 18h4`,key:`1ulq68`}]]),Me=O(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ne=O(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),Pe=O(`Megaphone`,[[`path`,{d:`m3 11 18-5v12L3 14v-3z`,key:`n962bs`}],[`path`,{d:`M11.6 16.8a3 3 0 1 1-5.8-1.6`,key:`1yl0tm`}]]),Fe=O(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),Ie=O(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Le=O(`Paperclip`,[[`path`,{d:`M13.234 20.252 21 12.3`,key:`1cbrk9`}],[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486`,key:`1pkts6`}]]),Re=O(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ze=O(`Presentation`,[[`path`,{d:`M2 3h20`,key:`91anmk`}],[`path`,{d:`M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3`,key:`2k9sn8`}],[`path`,{d:`m7 21 5-5 5 5`,key:`bip4we`}]]),Be=O(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),Ve=O(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),He=O(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Ue=O(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),We=O(`Scale`,[[`path`,{d:`m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`7g6ntu`}],[`path`,{d:`m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`ijws7r`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2`,key:`3gwbw2`}]]),Ge=O(`Send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ke=O(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),R=O(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),qe=O(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Je=O(`Table2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),Ye=O(`Target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Xe=O(`TimerReset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]),Ze=O(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Qe=O(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),$e=O(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),et=O(`UserRound`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),tt=O(`WandSparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),nt=O(`Watch`,[[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`polyline`,{points:`12 10 12 12 13 13`,key:`19dquz`}],[`path`,{d:`m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05`,key:`18k57s`}],[`path`,{d:`m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05`,key:`16ny36`}]]),rt=O(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),it=O(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),z=e(t(),1),at=12e3;function ot(e=!1){let t={...b()};return e&&(t[`Content-Type`]=`application/json`),t}async function B(e,t={}){await C();let n={...t,headers:{...ot(!!t.body),...t.headers??{}},cache:`no-store`},r=String(t.method??`GET`).toUpperCase(),i=async n=>{if(!n.ok){let r=await n.text().catch(()=>``),i=r;try{i=JSON.parse(r).detail??r}catch{}throw Error(i||`${t.method??`GET`} ${e} failed (${n.status})`)}return await n.json()};return r===`GET`?y(e,n,at,i):i(await fetch(e,n))}var V=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,st=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`;function ct(e){let t=e.replaceAll(`\r `,` `).split(` @@ -11,7 +11,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,k as n}from"./i `):`Not configured`}),(0,Y.jsx)(`i`,{className:C.remotes.length?`ok`:`missing`,children:C.remotes.length?(0,Y.jsx)(A,{size:12}):(0,Y.jsx)(M,{size:12})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`dt`,{children:[(0,Y.jsx)(m,{size:13}),`Upstream`]}),(0,Y.jsxs)(`dd`,{children:[C.upstream||`Not configured`,C.upstream?` · ahead ${C.ahead}, behind ${C.behind}`:``]}),(0,Y.jsx)(`i`,{className:C.upstream?`ok`:`missing`,children:C.upstream?(0,Y.jsx)(A,{size:12}):(0,Y.jsx)(M,{size:12})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`dt`,{children:[(0,Y.jsx)(et,{size:13}),`Commit identity`]}),(0,Y.jsx)(`dd`,{children:C.identity.name&&C.identity.email?`${C.identity.name} <${C.identity.email}>`:`Not configured`}),(0,Y.jsx)(`i`,{className:C.identity.valid?`ok`:`missing`,children:C.identity.valid?(0,Y.jsx)(A,{size:12}):(0,Y.jsx)(M,{size:12})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`dt`,{children:[(0,Y.jsx)(we,{size:13}),`GitHub CLI`]}),(0,Y.jsx)(`dd`,{children:C.github.authenticated?`${C.github.login} · ${C.github.protocol}`:`Not authenticated`}),(0,Y.jsx)(`i`,{className:C.github.authenticated?`ok`:`missing`,children:C.github.authenticated?(0,Y.jsx)(A,{size:12}):(0,Y.jsx)(M,{size:12})})]})]}),(0,Y.jsx)(`p`,{children:C.publish_ready?`Repository is ready for an explicitly approved push.`:`Configure the missing items before publishing. No credentials are shown in this UI.`})]}):(0,Y.jsx)(Z,{icon:m,title:`Not a Git repository`})})]}),(0,Y.jsxs)(`section`,{className:`vscode-terminal`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsx)(`strong`,{children:`ARGUS ACTIVITY`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(qe,{size:13}),`read-only`]})]}),(0,Y.jsx)(`div`,{children:b.length?b.map((e,n)=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(`time`,{children:xt(e.ts,t)}),(0,Y.jsx)(`b`,{className:`terminal-role terminal-role--${K(e)}`,children:K(e)}),(0,Y.jsx)(`span`,{children:`›`}),(0,Y.jsx)(`code`,{children:J(e,800)||q(e)})]},`${e.ts}-${n}`)):(0,Y.jsx)(`p`,{children:`$ waiting for Argus activity`})})]}),(0,Y.jsxs)(`footer`,{className:`vscode-statusbar`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(m,{size:12}),C?.branch||`no branch`]}),(0,Y.jsx)(`span`,{children:_.isError?`Workspace error`:_.isFetching?`Workspace syncing`:_.data?.truncated?`Tree truncated`:`Workspace synced`}),(0,Y.jsx)(`span`,{children:C?.github.authenticated?`GitHub: ${C.github.login}`:`GitHub: offline`}),(0,Y.jsx)(`span`,{children:`UTF-8`}),(0,Y.jsx)(`span`,{children:s.split(`.`).at(-1)?.toUpperCase()||`Plain Text`})]})]})]})}var Nn=2e5,Pn=5,Fn=e=>`argus-v2-inbox:${e}`,In=e=>{try{let t=JSON.parse(localStorage.getItem(Fn(e))??`[]`);return Array.isArray(t)?t:[]}catch{return[]}},Ln=(e,t)=>({id:crypto.randomUUID(),title:e,source:t,raw:``,prompt:``,changes:[],questions:[],createdAt:Date.now(),updatedAt:Date.now()});function Rn(e,t,n){let r=[...e.matchAll(/^#{1,3}\s+(.+)\n([\s\S]*?)(?=^#{1,3}\s+|$)/gm)],i=e=>/目标|objective|question/i.test(e)?Ye:/约束|constraint|boundary|non-goal/i.test(e)?Ae:/文献|evidence|source|paper/i.test(e)?ke:Oe,a=r.map(e=>({title:e[1].trim(),body:e[2].trim(),icon:i(e[1])})).filter(e=>e.body);if(a.length)return a.slice(0,8);let o=e.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),s=[];o[0]&&s.push({title:n(`研究目标与背景`,`Research goal and context`),body:o[0],icon:Ye});let c=e.split(` `).filter(e=>/不得|不要|必须|约束|only|must|do not|without/i.test(e)).join(` `);return c&&s.push({title:n(`约束与边界`,`Constraints and boundaries`),body:c,icon:Ae}),t.length&&s.push({title:n(`仍需确认`,`Questions to confirm`),body:t.map(e=>`- ${e}`).join(` -`),icon:Oe}),s}function zn(e){let{locale:t,text:n}=W(),[r,i]=(0,z.useState)(()=>In(e.sid)),[a,o]=(0,z.useState)(()=>In(e.sid)[0]?.id??``),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)([]),[d,f]=(0,z.useState)(0),[p,m]=(0,z.useState)(``),[h,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(`current`),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),w=kt(e.sid,e.refresh);(0,z.useEffect)(()=>{let t=In(e.sid);i(t),o(t[0]?.id??``),u([]),f(0)},[e.sid]),(0,z.useEffect)(()=>{try{localStorage.setItem(Fn(e.sid),JSON.stringify(r)),_(``)}catch{_(n(`本机草稿存储空间不足;请缩短文本或删除旧草稿。`,`Not enough local storage for this draft. Shorten the text or delete older drafts.`))}},[r,e.sid,n]);let T=r.find(e=>e.id===a)??null,E=(0,z.useMemo)(()=>Rn(T?.prompt??``,T?.questions??[],n),[T?.prompt,T?.questions,n]),D=e=>T&&i(t=>t.map(t=>t.id===T.id?{...t,...e,updatedAt:Date.now()}:t)),ee=()=>{let e=Ln(n(`新的科研输入`,`New research input`),n(`导师 / 组会 / 灵感`,`Advisor / meeting / idea`));i(t=>[e,...t]),o(e.id)},O=()=>{if(!T||!confirm(n(`删除“${T.title}”?`,`Delete “${T.title}”?`)))return;let e=r.filter(e=>e.id!==T.id);i(e),o(e[0]?.id??``)},k=T?n(`这是科研收信箱的预处理步骤,只分析输入并回复,不创建后台任务、不修改项目。请读取下面的零散内容和附件,提取知识点并生成第一版可直接交给 Argus 的研究 Prompt。必须保留事实来源和不确定性,不得虚构论文、实验或结论;使用以下 Markdown 结构:\n## 研究目标\n## 已知背景与知识点\n## 约束与非目标\n## 文献与证据线索\n## 建议任务与验收方式\n## 待确认问题\n\n标题:${T.title}\n来源:${T.source}\n\n原始内容:\n${T.raw}`,`This is a Research Inbox preprocessing step. Analyze and reply only; do not create background work or modify the project. Read the rough content and attachments, extract the useful knowledge, and produce a first research prompt ready for Argus. Preserve sources and uncertainty, and do not invent papers, experiments, or conclusions. Use this Markdown structure:\n## Research goal\n## Known context and knowledge\n## Constraints and non-goals\n## Literature and evidence leads\n## Suggested tasks and acceptance criteria\n## Questions to confirm\n\nTitle: ${T.title}\nSource: ${T.source}\n\nRaw content:\n${T.raw}`):``,te=async e=>{let r=/\.(txt|md|markdown|json|csv|ya?ml|log|tex)$/i,i=/\.(pdf|png|jpe?g|webp|wav|mp3|m4a|ogg)$/i,a=e.filter(e=>!r.test(e.name)&&!i.test(e.name));if(a.length){m(n(`不支持的附件:${a.map(e=>e.name).join(`、`)}`,`Unsupported attachments: ${a.map(e=>e.name).join(`, `)}`));return}let o=e.find(e=>e.size>10485760);if(o){m(n(`${o.name} 超过单文件 10 MB 限制`,`${o.name} exceeds the 10 MB per-file limit`));return}if(l.length+d+e.length>Pn){m(n(`每次分析最多导入 ${Pn} 个文件`,`You can import up to ${Pn} files per analysis`));return}let s=e.filter(e=>r.test(e.name)),c=s.find(e=>e.size>1048576);if(c){m(n(`${c.name} 超过本机文本导入 1 MB 限制;请改为摘要或拆分文件`,`${c.name} exceeds the 1 MB local text-import limit. Summarize or split the file.`));return}let p=e.filter(e=>i.test(e.name)),h=[...l,...p];if(h.reduce((e,t)=>e+t.size,0)>26214400){m(n(`附件总大小超过 25 MB`,`Attachments exceed the 25 MB total limit`));return}let g=await Promise.all(s.map(async e=>`\n\n--- ${n(`文件`,`File`)}: ${e.name} ---\n${await e.text()}`)),_=`${T?.raw??``}${g.join(``)}`.trim();if(_.length>Nn){m(n(`原始输入超过 ${Nn.toLocaleString(t)} 字符限制,请拆分或摘要`,`Raw input exceeds the ${Nn.toLocaleString(t)}-character limit. Split or summarize it.`));return}g.length&&(D({raw:_}),f(e=>e+s.length)),u(h),m(``)},j=async()=>{if(!(!T||!T.raw.trim()&&!l.length)){c(!0),m(``);try{if(l.length){let e=await w.run(k,l),t=String(e?.reply||w.output||``).trim();if(!t)throw Error(n(`Argus 没有返回可用的知识提取结果`,`Argus did not return a usable knowledge extraction result`));D({prompt:t,changes:[n(`分析了 ${l.length} 个附件和原始输入`,`Analyzed ${l.length} attachments and the raw input`)],questions:[]}),u([])}else{let t=await H.rewritePrompt(e.sid,k);if(t.error)throw Error(t.error);D({prompt:t.rewritten,changes:t.changes,questions:t.questions})}}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}}},ne=async()=>{if(T?.prompt.trim()){if(v===`new`){if(!b.trim()||!confirm(n(`确认用当前 Prompt 创建一个新的 Argus 项目?`,`Create a new Argus project with this prompt?`)))return;try{let e=await H.createDaemon(T.prompt,b,S);D({sentAt:Date.now()}),window.location.hash=`project/${e.sid}/overview`}catch(e){m(e instanceof Error?e.message:String(e))}return}confirm(n(`确认把这份第一版 Prompt 发送给当前 Argus 项目?`,`Send this first prompt to the current Argus project?`))&&await w.run(T.prompt)&&D({sentAt:Date.now()})}},N=T?.sentAt?4:T?.prompt?3:T?.raw||l.length?2:1;return(0,Y.jsxs)(`div`,{className:`ros-page inbox-v2`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`RESEARCH INBOX`}),(0,Y.jsx)(`h1`,{children:n(`从零散输入开始研究`,`Start research from rough input`)}),(0,Y.jsx)(`p`,{children:n(`把消息、会议记录、文件或灵感交给 AI,提取知识点并形成第一版 Argus Prompt。`,`Give AI messages, meeting notes, files, or ideas to extract knowledge and create a first Argus prompt.`)})]}),(0,Y.jsxs)(X,{tone:`neutral`,children:[(0,Y.jsx)(Ue,{size:12}),n(`本机自动保存`,`Saved locally`)]})]}),(0,Y.jsx)(`div`,{className:`intake-steps`,children:[[n(`收集原始内容`,`Collect input`),Fe],[n(`AI 提取知识`,`Extract knowledge`),tt],[n(`形成 Argus Prompt`,`Build Argus prompt`),P],[n(`创建 / 发送项目`,`Create / send project`),Ge]].map(([e,t],n)=>(0,Y.jsxs)(`div`,{className:N>n?`is-done`:N===n+1?`is-active`:``,children:[(0,Y.jsx)(`span`,{children:N>n+1?(0,Y.jsx)(A,{size:14}):(0,Y.jsx)(t,{size:15})}),(0,Y.jsx)(`strong`,{children:String(e)}),n<3?(0,Y.jsx)(g,{size:14}):null]},String(e)))}),(0,Y.jsxs)(`div`,{className:`inbox-v2__layout`,children:[(0,Y.jsxs)(`aside`,{className:`ros-card inbox-sources`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`INBOX`}),(0,Y.jsx)(`h2`,{children:n(`科研输入`,`Research input`)})]}),(0,Y.jsx)(`button`,{className:`icon-button`,type:`button`,onClick:ee,"aria-label":n(`新增输入`,`Add input`),children:(0,Y.jsx)(Re,{size:15})})]}),(0,Y.jsx)(`div`,{children:r.length?r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:T?.id===e.id?`is-active`:``,onClick:()=>o(e.id),children:[(0,Y.jsx)(`span`,{className:`inbox-item-icon`,children:e.sentAt?(0,Y.jsx)(A,{size:14}):e.prompt?(0,Y.jsx)(R,{size:14}):(0,Y.jsx)(De,{size:14})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),(0,Y.jsxs)(`small`,{children:[e.source,` · `,St(e.updatedAt/1e3,t)]})]})]},e.id)):(0,Y.jsx)(Z,{icon:De,title:n(`暂无输入`,`No input yet`),description:n(`新增一条导师消息、组会笔记或研究灵感。`,`Add an advisor message, meeting note, or research idea.`)})})]}),(0,Y.jsxs)(`main`,{className:`ros-card inbox-input`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`RAW MATERIAL`}),(0,Y.jsx)(`h2`,{children:n(`原始内容与附件`,`Raw content and attachments`)})]}),T?(0,Y.jsx)(`button`,{className:`icon-button`,type:`button`,onClick:O,"aria-label":n(`删除`,`Delete`),children:(0,Y.jsx)(Ze,{size:14})}):null]}),T?(0,Y.jsxs)(`div`,{className:`inbox-input__form`,children:[(0,Y.jsxs)(`div`,{className:`form-grid`,children:[(0,Y.jsxs)(`label`,{children:[(0,Y.jsx)(`span`,{children:n(`标题`,`Title`)}),(0,Y.jsx)(`input`,{value:T.title,onChange:e=>D({title:e.target.value})})]}),(0,Y.jsxs)(`label`,{children:[(0,Y.jsx)(`span`,{children:n(`来源`,`Source`)}),(0,Y.jsx)(`input`,{value:T.source,onChange:e=>D({source:e.target.value})})]})]}),(0,Y.jsxs)(`label`,{className:`field field--grow`,children:[(0,Y.jsx)(`span`,{children:n(`零散消息、笔记或转写文本`,`Rough messages, notes, or transcripts`)}),(0,Y.jsx)(`textarea`,{maxLength:Nn,value:T.raw,onChange:e=>D({raw:e.target.value}),placeholder:n(`不需要先整理,直接粘贴原始内容。AI 会区分目标、事实、约束、文献线索、待办和疑问…`,`Paste raw content directly. AI will separate goals, facts, constraints, evidence leads, tasks, and questions…`)})]}),l.length?(0,Y.jsx)(`div`,{className:`inbox-attachment-list`,children:l.map((e,t)=>(0,Y.jsxs)(`span`,{children:[e.type.startsWith(`audio/`)?(0,Y.jsx)(ie,{size:14}):e.type.startsWith(`image/`)?(0,Y.jsx)(Ee,{size:14}):(0,Y.jsx)(P,{size:14}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsxs)(`small`,{children:[(e.size/1024/1024).toFixed(1),` MB · `,n(`仅在本次分析上传`,`Uploaded only for this analysis`)]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e=>e.filter((e,n)=>n!==t)),children:(0,Y.jsx)(M,{size:13})})]},`${e.name}-${t}`))}):null,(0,Y.jsxs)(`div`,{className:`inbox-upload-types`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(P,{size:14}),`PDF / `,n(`文本`,`text`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(Ee,{size:14}),n(`图片`,`images`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ie,{size:14}),n(`语音`,`audio`)]}),(0,Y.jsx)(`p`,{children:n(`语音会交给 Argus 和已配置工具处理,不把“上传成功”冒充“已完成转写”。`,`Audio is handed to Argus and configured tools; an upload is never presented as a completed transcript.`)})]}),(0,Y.jsxs)(`div`,{className:`inbox-input__actions`,children:[(0,Y.jsxs)(`label`,{className:`button button--secondary file-button`,children:[(0,Y.jsx)($e,{size:14}),n(`添加文件`,`Add files`),(0,Y.jsx)(`input`,{type:`file`,multiple:!0,accept:`.txt,.md,.markdown,.json,.csv,.yaml,.yml,.log,.tex,.pdf,.png,.jpg,.jpeg,.webp,.wav,.mp3,.m4a,.ogg`,onChange:e=>void te(Array.from(e.target.files??[]))})]}),(0,Y.jsxs)(`button`,{className:`button button--primary`,type:`button`,disabled:!T.raw.trim()&&!l.length||s||w.busy,onClick:()=>void j(),children:[s||w.busy?(0,Y.jsx)(R,{size:14}):(0,Y.jsx)(tt,{size:14}),s||w.busy?w.phase||n(`AI 正在分析`,`AI is analyzing`):n(`分析内容并生成 Prompt`,`Analyze and generate prompt`)]})]}),p?(0,Y.jsx)(`div`,{className:`inline-error`,children:p}):null,h?(0,Y.jsx)(`div`,{className:`inline-error`,children:h}):null]}):(0,Y.jsx)(Z,{icon:De,title:n(`选择或新增一条科研输入`,`Select or add research input`)})]}),(0,Y.jsxs)(`aside`,{className:`inbox-output`,children:[(0,Y.jsxs)(`section`,{className:`ros-card knowledge-panel`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`KNOWLEDGE EXTRACTION`}),(0,Y.jsx)(`h2`,{children:n(`AI 提取的知识点`,`AI-extracted knowledge`)})]}),E.length?(0,Y.jsxs)(X,{tone:`success`,children:[E.length,` `,n(`组`,`groups`)]}):null]}),E.length?(0,Y.jsx)(`div`,{className:`knowledge-grid`,children:E.map(e=>{let t=e.icon;return(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(t,{size:15})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),(0,Y.jsx)(Q,{children:e.body})]})]},e.title)})}):(0,Y.jsx)(Z,{icon:Oe,title:n(`等待 AI 提取`,`Waiting for AI extraction`),description:n(`结果会明确区分目标、知识点、约束、证据线索和待确认问题。`,`The result separates goals, knowledge, constraints, evidence leads, and open questions.`)})]}),(0,Y.jsxs)(`section`,{className:`ros-card first-prompt`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`FIRST ARGUS PROMPT`}),(0,Y.jsx)(`h2`,{children:n(`第一版 Argus Prompt`,`First Argus prompt`)})]}),T?.prompt?(0,Y.jsx)(X,{tone:`info`,children:n(`可编辑`,`Editable`)}):null]}),T?.prompt?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`textarea`,{value:T.prompt,onChange:e=>D({prompt:e.target.value})}),(0,Y.jsxs)(`div`,{className:`dispatch-mode`,children:[(0,Y.jsx)(`button`,{type:`button`,className:v===`current`?`is-active`:``,onClick:()=>y(`current`),children:n(`发送当前项目`,`Send to current project`)}),(0,Y.jsx)(`button`,{type:`button`,className:v===`new`?`is-active`:``,onClick:()=>y(`new`),children:n(`创建新项目`,`Create new project`)})]}),v===`new`?(0,Y.jsxs)(`div`,{className:`new-project-fields`,children:[(0,Y.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:n(`新项目名称`,`New project name`)}),(0,Y.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),placeholder:n(`工作目录(可选,留空自动创建)`,`Workdir (optional; blank creates one)`)})]}):null,(0,Y.jsxs)(`button`,{className:`button button--primary button--full`,type:`button`,disabled:w.busy,onClick:()=>void ne(),children:[(0,Y.jsx)(Ge,{size:14}),w.busy?w.phase||n(`正在发送`,`Sending`):v===`new`?n(`用此 Prompt 创建 Argus 项目`,`Create Argus project with this prompt`):n(`确认并发送给当前 Argus`,`Confirm and send to current Argus`)]}),w.output?(0,Y.jsx)(`div`,{className:`manager-mini-result`,children:(0,Y.jsx)(Q,{children:w.output})}):null]}):(0,Y.jsx)(Z,{icon:P,title:n(`尚未生成 Prompt`,`No prompt generated`),description:n(`AI 提取后会在这里生成第一版 Prompt,你可以先修改再发送。`,`The first prompt appears here after extraction and can be edited before sending.`)})]})]})]})]})}function Bn({paper:e,selected:t,onClick:n}){let{text:r}=W();return(0,Y.jsxs)(`button`,{type:`button`,className:`paper-card ${t?`is-selected`:``}`,onClick:n,children:[(0,Y.jsxs)(`div`,{className:`paper-card__meta`,children:[(0,Y.jsx)(X,{tone:e.evidenceStatus===`verified_artifact`?`success`:e.evidenceStatus===`metadata`?`info`:`warn`,children:e.evidenceStatus===`verified_artifact`?r(`原文文件已验证`,`Source verified`):e.evidenceStatus===`metadata`?r(`仅元数据`,`Metadata only`):r(`待核验`,`Needs verification`)}),(0,Y.jsxs)(`span`,{className:`paper-card__year`,children:[e.year||`—`,e.venue?` · ${e.venue}`:``]})]}),(0,Y.jsx)(`h3`,{children:e.title}),e.authors.length?(0,Y.jsxs)(`p`,{className:`paper-card__authors`,children:[e.authors.slice(0,4).join(`, `),e.authors.length>4?` et al.`:``]}):null,(0,Y.jsx)(`p`,{className:`paper-card__summary`,children:e.relevance||e.abstract||r(`该记录尚未写入项目相关性摘要。`,`No project-relevance summary has been recorded.`)}),(0,Y.jsxs)(`div`,{className:`paper-card__footer`,children:[(0,Y.jsx)(`code`,{children:e.sourcePath}),(0,Y.jsx)(`span`,{children:r(`查看详情`,`View details`)})]})]})}function Vn(e){let{locale:t,text:n}=W(),r=kn(e.sid,`literature`),a=r.active?.path||``,o=i({queryKey:[`workspace-literature`,e.sid,r.workspaceId],queryFn:({signal:t})=>$.literature(e.sid,r.workspaceId,t),enabled:!!r.workspaceId,refetchInterval:15e3}),[s,c]=(0,z.useState)(`all`),[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(``),g=kt(e.sid,async()=>{await e.refresh(),await o.refetch()}),_=o.data?.papers??[],v=Math.max(0,..._.map(e=>e.year??0)),y=(0,z.useMemo)(()=>_.filter(e=>{if(s===`recent`&&(e.year??0)e.id===d)??y[0]??null,x=(0,z.useMemo)(()=>e.events.filter(e=>/paper|arxiv|doi|literature|search|citation|http/i.test(`${e.type} ${e.kind} ${J(e,2e3)}`)).slice(-30).reverse(),[e.events]),S=async()=>{p.trim()&&await g.run(`请为当前项目执行新的文献调研:${p}\n\n要求读取原始论文或官方仓库,把结构化记录追加到项目的 literature grounding/audit 文件中,包括标题、作者、年份、URL、与当前项目关系、最近工作威胁和仍待全文核验项。完成后文献中心应能从工作目录直接读取这些记录。`)};return(0,Y.jsxs)(`div`,{className:`ros-page literature-v2`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`LITERATURE CENTER`}),(0,Y.jsx)(`h1`,{children:n(`文献中心`,`Literature center`)}),(0,Y.jsx)(`p`,{children:n(`直接读取 Argus 工作目录中的论文清单、文献审计和实时检索轨迹,不再依赖手工注册 artifacts。`,`Read paper inventories, literature audits, and live retrieval traces directly from the Argus workdir.`)})]}),(0,Y.jsxs)(`div`,{className:`header-badges`,children:[(0,Y.jsxs)(X,{tone:`success`,children:[(0,Y.jsx)(I,{size:12}),_.length,` `,n(`篇论文`,`papers`)]}),(0,Y.jsxs)(X,{tone:`neutral`,children:[o.data?.sourceFiles.length??0,` `,n(`个证据文件`,`evidence files`)]})]})]}),(0,Y.jsxs)(`section`,{className:`literature-stats`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--blue`,children:(0,Y.jsx)(I,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`论文记录`,`Paper records`),(0,Y.jsx)(`strong`,{children:_.length})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--green`,children:(0,Y.jsx)(me,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`原文文件已验证`,`Verified sources`),(0,Y.jsx)(`strong`,{children:_.filter(e=>e.evidenceStatus===`verified_artifact`).length})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--amber`,children:(0,Y.jsx)(L,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`最近工作`,`Recent work`),(0,Y.jsx)(`strong`,{children:_.filter(e=>(e.year??0)>=v-1).length})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--violet`,children:(0,Y.jsx)(xe,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`扫描项目文件`,`Scanned files`),(0,Y.jsx)(`strong`,{children:o.data?.scannedFiles??0})]})]})]}),(0,Y.jsxs)(`div`,{className:`literature-v2__layout`,children:[(0,Y.jsxs)(`aside`,{className:`literature-v2__sidebar ros-card`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`LIBRARY`}),(0,Y.jsx)(`h2`,{children:n(`项目文献库`,`Project library`)})]})}),(0,Y.jsxs)(`label`,{className:`search-field search-field--block`,children:[(0,Y.jsx)(h,{size:14}),(0,Y.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:n(`搜索标题、作者、主题`,`Search title, author, or topic`)})]}),(0,Y.jsx)(`nav`,{className:`library-tabs`,children:[[`all`,n(`全部论文`,`All papers`),_.length],[`recent`,n(`最近工作`,`Recent work`),_.filter(e=>(e.year??0)>=v-1).length],[`read`,n(`已验证原文`,`Verified sources`),_.filter(e=>e.evidenceStatus===`verified_artifact`).length],[`sources`,n(`证据文件`,`Evidence files`),o.data?.sourceFiles.length??0]].map(([e,t,n])=>(0,Y.jsxs)(`button`,{type:`button`,className:s===e?`is-active`:``,onClick:()=>c(e),children:[(0,Y.jsx)(`span`,{children:t}),(0,Y.jsx)(`small`,{children:n})]},e))}),(0,Y.jsxs)(`div`,{className:`literature-source-note`,children:[(0,Y.jsx)(fe,{size:15}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:n(`实时来源`,`Live source`)}),(0,Y.jsx)(`p`,{title:a,children:a})]})]})]}),(0,Y.jsxs)(`main`,{className:`literature-v2__main`,children:[(0,Y.jsxs)(`div`,{className:`literature-list-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:s===`recent`?n(`最近工作`,`Recent work`):s===`read`?n(`已验证原文文件`,`Verified source files`):s===`sources`?n(`文献证据文件`,`Literature evidence files`):n(`全部论文`,`All papers`)}),(0,Y.jsx)(`p`,{children:s===`recent`?n(`按项目中最新年份 ${v||`—`} 自动筛选`,`Filtered by the latest project year: ${v||`—`}`):n(`Argus 写入工作目录后约 5 秒内自动更新`,`Updates shortly after Argus writes to the workdir`)})]}),o.isError?(0,Y.jsx)(X,{tone:`danger`,children:n(`同步失败`,`Sync failed`)}):o.isFetching?(0,Y.jsx)(X,{tone:`live`,dot:!0,children:n(`同步中`,`Syncing`)}):(0,Y.jsx)(X,{tone:`success`,children:n(`已同步`,`Synced`)})]}),o.isError?(0,Y.jsx)(`div`,{className:`inline-error`,children:o.error.message}):null,s===`sources`?(0,Y.jsx)(`div`,{className:`source-file-grid`,children:o.data?.sourceFiles.map(e=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(fe,{size:17}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]}),(0,Y.jsx)(`time`,{children:St(e.mtime,t)})]},e.path))}):y.length?(0,Y.jsx)(`div`,{className:`paper-grid`,children:y.map(e=>(0,Y.jsx)(Bn,{paper:e,selected:b?.id===e.id,onClick:()=>f(e.id)},e.id))}):(0,Y.jsx)(Z,{icon:I,title:n(`此筛选下暂无论文`,`No papers match this filter`),description:n(`Argus 完成检索并写入 LITERATURE_GROUNDING.json 后会自动出现。`,`Papers appear after Argus writes LITERATURE_GROUNDING.json.`)})]}),(0,Y.jsxs)(`aside`,{className:`literature-v2__detail`,children:[(0,Y.jsx)(`section`,{className:`ros-card paper-detail`,children:b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`paper-detail__top`,children:[(0,Y.jsx)(X,{tone:b.evidenceStatus===`verified_artifact`?`success`:b.evidenceStatus===`metadata`?`info`:`warn`,children:b.evidenceStatus===`verified_artifact`?`verified artifact`:b.evidenceStatus}),(0,Y.jsxs)(`span`,{children:[b.year||`—`,b.venue?` · ${b.venue}`:``]})]}),(0,Y.jsx)(`h2`,{children:b.title}),b.authors.length?(0,Y.jsx)(`p`,{className:`paper-detail__authors`,children:b.authors.join(`, `)}):null,(0,Y.jsxs)(`div`,{className:`paper-detail__body`,children:[(0,Y.jsx)(`h3`,{children:n(`与当前项目的关系`,`Relationship to this project`)}),(0,Y.jsx)(Q,{children:b.relevance||b.abstract||n(`尚未写入摘要。`,`No summary recorded.`)}),b.abstract&&b.relevance?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:n(`摘要`,`Abstract`)}),(0,Y.jsx)(`p`,{children:b.abstract})]}):null]}),(0,Y.jsxs)(`div`,{className:`paper-detail__source`,children:[(0,Y.jsx)(`span`,{children:n(`证据文件`,`Evidence file`)}),(0,Y.jsx)(`code`,{children:b.sourcePath})]}),b.url?(0,Y.jsxs)(`a`,{className:`button button--secondary button--full`,href:b.url,target:`_blank`,rel:`noreferrer`,children:[n(`打开原始来源`,`Open source`),` `,(0,Y.jsx)(ce,{size:14})]}):null]}):(0,Y.jsx)(Z,{icon:I,title:n(`选择一篇论文`,`Select a paper`)})}),(0,Y.jsxs)(`section`,{className:`ros-card retrieval-panel`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`ARGUS RETRIEVAL`}),(0,Y.jsx)(`h2`,{children:n(`最近检索`,`Recent retrieval`)})]}),(0,Y.jsx)(X,{tone:e.connected?`live`:`warn`,dot:!0,children:e.connected?`Live`:`Polling`})]}),(0,Y.jsxs)(`div`,{children:[(o.data?.searchFiles??[]).slice(0,8).map(e=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(me,{size:13}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]}),(0,Y.jsx)(`time`,{children:xt(e.mtime,t)})]},e.path)),!o.data?.searchFiles.length&&x.slice(0,8).map((e,n)=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(me,{size:13}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:q(e)}),(0,Y.jsx)(`code`,{children:J(e,100)})]}),(0,Y.jsx)(`time`,{children:xt(e.ts,t)})]},`${e.ts}-${n}`))]})]}),(0,Y.jsxs)(`section`,{className:`ros-card literature-ask`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`NEW SEARCH`}),(0,Y.jsx)(`h2`,{children:n(`让 Argus 调研新工作`,`Ask Argus to research new work`)})]})}),(0,Y.jsx)(`textarea`,{rows:3,value:p,onChange:e=>m(e.target.value),placeholder:n(`例如:检索 2025–2026 年与当前方法最接近的直接竞争工作…`,`Example: find the closest competing work from 2025–2026…`)}),(0,Y.jsxs)(`button`,{className:`button button--primary button--full`,type:`button`,disabled:!p.trim()||g.busy,onClick:()=>void S(),children:[(0,Y.jsx)(R,{size:14}),g.busy?g.phase||n(`检索中`,`Researching`):n(`发起文献调研`,`Start literature research`)]}),g.output?(0,Y.jsx)(`div`,{className:`manager-mini-result`,children:(0,Y.jsx)(Q,{children:g.output})}):null]})]})]})]})}function Hn(e){return[`.png`,`.jpg`,`.jpeg`,`.webp`,`.svg`].includes(e.extension)}function Un(e){return[`.csv`,`.tsv`].includes(e.extension)}function Wn(e){return[`.tex`,`.md`].includes(e.extension)}function Gn({src:e,name:t}){let{text:n}=W(),r=(0,z.useRef)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(1),[c,l]=(0,z.useState)(1.25),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let t=!0,n=null;a(null),s(1),d(``),p(!1);let r=localStorage.getItem(`argus_web_token`);return Promise.all([fetch(e,{headers:r?{Authorization:`Bearer ${r}`}:{}}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),S(()=>import(`./pdf-DN4bD3_L.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))]).then(([e,r])=>{if(t)return r.GlobalWorkerOptions.workerSrc=T,n=r.getDocument({data:e}),n.promise}).then(e=>{t&&e&&a(e)}).catch(e=>{t&&d(e instanceof Error?e.message:String(e))}),()=>{t=!1,n?.destroy()}},[e]),(0,z.useEffect)(()=>{if(!i||!r.current)return;p(!1);let e=!1,t=null;return i.getPage(o).then(n=>{if(e||!r.current)return;let i=n.getViewport({scale:c}),a=r.current,o=a.getContext(`2d`);if(!o)return;let s=Math.min(window.devicePixelRatio||1,2);return a.width=Math.floor(i.width*s),a.height=Math.floor(i.height*s),a.style.width=`${i.width}px`,a.style.height=`${i.height}px`,t=n.render({canvas:a,canvasContext:o,viewport:i,transform:s===1?void 0:[s,0,0,s,0,0]}),t.promise.then(()=>{e||p(!0)})}).catch(t=>{e||d(t instanceof Error?t.message:String(t))}),()=>{e=!0,t?.cancel()}},[i,o,c]),(0,Y.jsxs)(`div`,{className:`pdf-canvas-viewer`,children:[(0,Y.jsxs)(`div`,{className:`pdf-canvas-toolbar`,children:[(0,Y.jsx)(`strong`,{children:t}),(0,Y.jsxs)(`span`,{children:[n(`第`,`Page`),` `,o,` / `,i?.numPages??`…`]}),(0,Y.jsx)(`button`,{type:`button`,disabled:o<=1,onClick:()=>s(e=>e-1),children:n(`上一页`,`Previous`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:!i||o>=i.numPages,onClick:()=>s(e=>e+1),children:n(`下一页`,`Next`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e=>Math.max(.75,e-.15)),children:`−`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e=>Math.min(2,e+.15)),children:`+`})]}),u?(0,Y.jsx)(`div`,{className:`inline-error`,children:u}):null,(0,Y.jsx)(`div`,{className:`pdf-canvas-scroll`,children:(0,Y.jsx)(`canvas`,{ref:r,"data-rendered":f?`true`:`false`})})]})}function Kn({sid:e,workspaceId:t,entry:n}){let{text:r}=W(),a=i({queryKey:[`paper-source-file`,e,t,n?.path,n?.mtime],queryFn:({signal:r})=>$.file(e,t,n.path,r),enabled:!!(n&&t),refetchInterval:8e3});return n?a.isError?(0,Y.jsx)(Z,{icon:P,title:r(`源文件暂时无法读取`,`Source file unavailable`),description:a.error.message}):n.extension===`.md`&&a.data?(0,Y.jsx)(`div`,{className:`paper-markdown-preview`,children:(0,Y.jsx)(Q,{children:a.data.content})}):(0,Y.jsxs)(`div`,{className:`latex-source`,children:[(0,Y.jsx)(`div`,{className:`latex-line-numbers`,children:(a.data?.content??``).split(` +`),icon:Oe}),s}function zn(e){let{locale:t,text:n}=W(),[r,i]=(0,z.useState)(()=>In(e.sid)),[a,o]=(0,z.useState)(()=>In(e.sid)[0]?.id??``),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)([]),[d,f]=(0,z.useState)(0),[p,m]=(0,z.useState)(``),[h,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(`current`),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),w=kt(e.sid,e.refresh);(0,z.useEffect)(()=>{let t=In(e.sid);i(t),o(t[0]?.id??``),u([]),f(0)},[e.sid]),(0,z.useEffect)(()=>{try{localStorage.setItem(Fn(e.sid),JSON.stringify(r)),_(``)}catch{_(n(`本机草稿存储空间不足;请缩短文本或删除旧草稿。`,`Not enough local storage for this draft. Shorten the text or delete older drafts.`))}},[r,e.sid,n]);let T=r.find(e=>e.id===a)??null,E=(0,z.useMemo)(()=>Rn(T?.prompt??``,T?.questions??[],n),[T?.prompt,T?.questions,n]),D=e=>T&&i(t=>t.map(t=>t.id===T.id?{...t,...e,updatedAt:Date.now()}:t)),ee=()=>{let e=Ln(n(`新的科研输入`,`New research input`),n(`导师 / 组会 / 灵感`,`Advisor / meeting / idea`));i(t=>[e,...t]),o(e.id)},O=()=>{if(!T||!confirm(n(`删除“${T.title}”?`,`Delete “${T.title}”?`)))return;let e=r.filter(e=>e.id!==T.id);i(e),o(e[0]?.id??``)},k=T?n(`这是科研收信箱的预处理步骤,只分析输入并回复,不创建后台任务、不修改项目。请读取下面的零散内容和附件,提取知识点并生成第一版可直接交给 Argus 的研究 Prompt。必须保留事实来源和不确定性,不得虚构论文、实验或结论;使用以下 Markdown 结构:\n## 研究目标\n## 已知背景与知识点\n## 约束与非目标\n## 文献与证据线索\n## 建议任务与验收方式\n## 待确认问题\n\n标题:${T.title}\n来源:${T.source}\n\n原始内容:\n${T.raw}`,`This is a Research Inbox preprocessing step. Analyze and reply only; do not create background work or modify the project. Read the rough content and attachments, extract the useful knowledge, and produce a first research prompt ready for Argus. Preserve sources and uncertainty, and do not invent papers, experiments, or conclusions. Use this Markdown structure:\n## Research goal\n## Known context and knowledge\n## Constraints and non-goals\n## Literature and evidence leads\n## Suggested tasks and acceptance criteria\n## Questions to confirm\n\nTitle: ${T.title}\nSource: ${T.source}\n\nRaw content:\n${T.raw}`):``,te=async e=>{let r=/\.(txt|md|markdown|json|csv|ya?ml|log|tex)$/i,i=/\.(pdf|png|jpe?g|webp|wav|mp3|m4a|ogg)$/i,a=e.filter(e=>!r.test(e.name)&&!i.test(e.name));if(a.length){m(n(`不支持的附件:${a.map(e=>e.name).join(`、`)}`,`Unsupported attachments: ${a.map(e=>e.name).join(`, `)}`));return}let o=e.find(e=>e.size>10485760);if(o){m(n(`${o.name} 超过单文件 10 MB 限制`,`${o.name} exceeds the 10 MB per-file limit`));return}if(l.length+d+e.length>Pn){m(n(`每次分析最多导入 ${Pn} 个文件`,`You can import up to ${Pn} files per analysis`));return}let s=e.filter(e=>r.test(e.name)),c=s.find(e=>e.size>1048576);if(c){m(n(`${c.name} 超过本机文本导入 1 MB 限制;请改为摘要或拆分文件`,`${c.name} exceeds the 1 MB local text-import limit. Summarize or split the file.`));return}let p=e.filter(e=>i.test(e.name)),h=[...l,...p];if(h.reduce((e,t)=>e+t.size,0)>26214400){m(n(`附件总大小超过 25 MB`,`Attachments exceed the 25 MB total limit`));return}let g=await Promise.all(s.map(async e=>`\n\n--- ${n(`文件`,`File`)}: ${e.name} ---\n${await e.text()}`)),_=`${T?.raw??``}${g.join(``)}`.trim();if(_.length>Nn){m(n(`原始输入超过 ${Nn.toLocaleString(t)} 字符限制,请拆分或摘要`,`Raw input exceeds the ${Nn.toLocaleString(t)}-character limit. Split or summarize it.`));return}g.length&&(D({raw:_}),f(e=>e+s.length)),u(h),m(``)},j=async()=>{if(!(!T||!T.raw.trim()&&!l.length)){c(!0),m(``);try{if(l.length){let e=await w.run(k,l),t=String(e?.reply||w.output||``).trim();if(!t)throw Error(n(`Argus 没有返回可用的知识提取结果`,`Argus did not return a usable knowledge extraction result`));D({prompt:t,changes:[n(`分析了 ${l.length} 个附件和原始输入`,`Analyzed ${l.length} attachments and the raw input`)],questions:[]}),u([])}else{let t=await H.rewritePrompt(e.sid,k);if(t.error)throw Error(t.error);D({prompt:t.rewritten,changes:t.changes,questions:t.questions})}}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}}},ne=async()=>{if(T?.prompt.trim()){if(v===`new`){if(!b.trim()||!confirm(n(`确认用当前 Prompt 创建一个新的 Argus 项目?`,`Create a new Argus project with this prompt?`)))return;try{let e=await H.createDaemon(T.prompt,b,S);D({sentAt:Date.now()}),window.location.hash=`project/${e.sid}/overview`}catch(e){m(e instanceof Error?e.message:String(e))}return}confirm(n(`确认把这份第一版 Prompt 发送给当前 Argus 项目?`,`Send this first prompt to the current Argus project?`))&&await w.run(T.prompt)&&D({sentAt:Date.now()})}},N=T?.sentAt?4:T?.prompt?3:T?.raw||l.length?2:1;return(0,Y.jsxs)(`div`,{className:`ros-page inbox-v2`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`RESEARCH INBOX`}),(0,Y.jsx)(`h1`,{children:n(`从零散输入开始研究`,`Start research from rough input`)}),(0,Y.jsx)(`p`,{children:n(`把消息、会议记录、文件或灵感交给 AI,提取知识点并形成第一版 Argus Prompt。`,`Give AI messages, meeting notes, files, or ideas to extract knowledge and create a first Argus prompt.`)})]}),(0,Y.jsxs)(X,{tone:`neutral`,children:[(0,Y.jsx)(Ue,{size:12}),n(`本机自动保存`,`Saved locally`)]})]}),(0,Y.jsx)(`div`,{className:`intake-steps`,children:[[n(`收集原始内容`,`Collect input`),Fe],[n(`AI 提取知识`,`Extract knowledge`),tt],[n(`形成 Argus Prompt`,`Build Argus prompt`),P],[n(`创建 / 发送项目`,`Create / send project`),Ge]].map(([e,t],n)=>(0,Y.jsxs)(`div`,{className:N>n?`is-done`:N===n+1?`is-active`:``,children:[(0,Y.jsx)(`span`,{children:N>n+1?(0,Y.jsx)(A,{size:14}):(0,Y.jsx)(t,{size:15})}),(0,Y.jsx)(`strong`,{children:String(e)}),n<3?(0,Y.jsx)(g,{size:14}):null]},String(e)))}),(0,Y.jsxs)(`div`,{className:`inbox-v2__layout`,children:[(0,Y.jsxs)(`aside`,{className:`ros-card inbox-sources`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`INBOX`}),(0,Y.jsx)(`h2`,{children:n(`科研输入`,`Research input`)})]}),(0,Y.jsx)(`button`,{className:`icon-button`,type:`button`,onClick:ee,"aria-label":n(`新增输入`,`Add input`),children:(0,Y.jsx)(Re,{size:15})})]}),(0,Y.jsx)(`div`,{children:r.length?r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:T?.id===e.id?`is-active`:``,onClick:()=>o(e.id),children:[(0,Y.jsx)(`span`,{className:`inbox-item-icon`,children:e.sentAt?(0,Y.jsx)(A,{size:14}):e.prompt?(0,Y.jsx)(R,{size:14}):(0,Y.jsx)(De,{size:14})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),(0,Y.jsxs)(`small`,{children:[e.source,` · `,St(e.updatedAt/1e3,t)]})]})]},e.id)):(0,Y.jsx)(Z,{icon:De,title:n(`暂无输入`,`No input yet`),description:n(`新增一条导师消息、组会笔记或研究灵感。`,`Add an advisor message, meeting note, or research idea.`)})})]}),(0,Y.jsxs)(`main`,{className:`ros-card inbox-input`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`RAW MATERIAL`}),(0,Y.jsx)(`h2`,{children:n(`原始内容与附件`,`Raw content and attachments`)})]}),T?(0,Y.jsx)(`button`,{className:`icon-button`,type:`button`,onClick:O,"aria-label":n(`删除`,`Delete`),children:(0,Y.jsx)(Ze,{size:14})}):null]}),T?(0,Y.jsxs)(`div`,{className:`inbox-input__form`,children:[(0,Y.jsxs)(`div`,{className:`form-grid`,children:[(0,Y.jsxs)(`label`,{children:[(0,Y.jsx)(`span`,{children:n(`标题`,`Title`)}),(0,Y.jsx)(`input`,{value:T.title,onChange:e=>D({title:e.target.value})})]}),(0,Y.jsxs)(`label`,{children:[(0,Y.jsx)(`span`,{children:n(`来源`,`Source`)}),(0,Y.jsx)(`input`,{value:T.source,onChange:e=>D({source:e.target.value})})]})]}),(0,Y.jsxs)(`label`,{className:`field field--grow`,children:[(0,Y.jsx)(`span`,{children:n(`零散消息、笔记或转写文本`,`Rough messages, notes, or transcripts`)}),(0,Y.jsx)(`textarea`,{maxLength:Nn,value:T.raw,onChange:e=>D({raw:e.target.value}),placeholder:n(`不需要先整理,直接粘贴原始内容。AI 会区分目标、事实、约束、文献线索、待办和疑问…`,`Paste raw content directly. AI will separate goals, facts, constraints, evidence leads, tasks, and questions…`)})]}),l.length?(0,Y.jsx)(`div`,{className:`inbox-attachment-list`,children:l.map((e,t)=>(0,Y.jsxs)(`span`,{children:[e.type.startsWith(`audio/`)?(0,Y.jsx)(ie,{size:14}):e.type.startsWith(`image/`)?(0,Y.jsx)(Ee,{size:14}):(0,Y.jsx)(P,{size:14}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsxs)(`small`,{children:[(e.size/1024/1024).toFixed(1),` MB · `,n(`仅在本次分析上传`,`Uploaded only for this analysis`)]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e=>e.filter((e,n)=>n!==t)),children:(0,Y.jsx)(M,{size:13})})]},`${e.name}-${t}`))}):null,(0,Y.jsxs)(`div`,{className:`inbox-upload-types`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(P,{size:14}),`PDF / `,n(`文本`,`text`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(Ee,{size:14}),n(`图片`,`images`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ie,{size:14}),n(`语音`,`audio`)]}),(0,Y.jsx)(`p`,{children:n(`语音会交给 Argus 和已配置工具处理,不把“上传成功”冒充“已完成转写”。`,`Audio is handed to Argus and configured tools; an upload is never presented as a completed transcript.`)})]}),(0,Y.jsxs)(`div`,{className:`inbox-input__actions`,children:[(0,Y.jsxs)(`label`,{className:`button button--secondary file-button`,children:[(0,Y.jsx)($e,{size:14}),n(`添加文件`,`Add files`),(0,Y.jsx)(`input`,{type:`file`,multiple:!0,accept:`.txt,.md,.markdown,.json,.csv,.yaml,.yml,.log,.tex,.pdf,.png,.jpg,.jpeg,.webp,.wav,.mp3,.m4a,.ogg`,onChange:e=>void te(Array.from(e.target.files??[]))})]}),(0,Y.jsxs)(`button`,{className:`button button--primary`,type:`button`,disabled:!T.raw.trim()&&!l.length||s||w.busy,onClick:()=>void j(),children:[s||w.busy?(0,Y.jsx)(R,{size:14}):(0,Y.jsx)(tt,{size:14}),s||w.busy?w.phase||n(`AI 正在分析`,`AI is analyzing`):n(`分析内容并生成 Prompt`,`Analyze and generate prompt`)]})]}),p?(0,Y.jsx)(`div`,{className:`inline-error`,children:p}):null,h?(0,Y.jsx)(`div`,{className:`inline-error`,children:h}):null]}):(0,Y.jsx)(Z,{icon:De,title:n(`选择或新增一条科研输入`,`Select or add research input`)})]}),(0,Y.jsxs)(`aside`,{className:`inbox-output`,children:[(0,Y.jsxs)(`section`,{className:`ros-card knowledge-panel`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`KNOWLEDGE EXTRACTION`}),(0,Y.jsx)(`h2`,{children:n(`AI 提取的知识点`,`AI-extracted knowledge`)})]}),E.length?(0,Y.jsxs)(X,{tone:`success`,children:[E.length,` `,n(`组`,`groups`)]}):null]}),E.length?(0,Y.jsx)(`div`,{className:`knowledge-grid`,children:E.map(e=>{let t=e.icon;return(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(t,{size:15})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),(0,Y.jsx)(Q,{children:e.body})]})]},e.title)})}):(0,Y.jsx)(Z,{icon:Oe,title:n(`等待 AI 提取`,`Waiting for AI extraction`),description:n(`结果会明确区分目标、知识点、约束、证据线索和待确认问题。`,`The result separates goals, knowledge, constraints, evidence leads, and open questions.`)})]}),(0,Y.jsxs)(`section`,{className:`ros-card first-prompt`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`FIRST ARGUS PROMPT`}),(0,Y.jsx)(`h2`,{children:n(`第一版 Argus Prompt`,`First Argus prompt`)})]}),T?.prompt?(0,Y.jsx)(X,{tone:`info`,children:n(`可编辑`,`Editable`)}):null]}),T?.prompt?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`textarea`,{value:T.prompt,onChange:e=>D({prompt:e.target.value})}),(0,Y.jsxs)(`div`,{className:`dispatch-mode`,children:[(0,Y.jsx)(`button`,{type:`button`,className:v===`current`?`is-active`:``,onClick:()=>y(`current`),children:n(`发送当前项目`,`Send to current project`)}),(0,Y.jsx)(`button`,{type:`button`,className:v===`new`?`is-active`:``,onClick:()=>y(`new`),children:n(`创建新项目`,`Create new project`)})]}),v===`new`?(0,Y.jsxs)(`div`,{className:`new-project-fields`,children:[(0,Y.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:n(`新项目名称`,`New project name`)}),(0,Y.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),placeholder:n(`工作目录(可选,留空自动创建)`,`Workdir (optional; blank creates one)`)})]}):null,(0,Y.jsxs)(`button`,{className:`button button--primary button--full`,type:`button`,disabled:w.busy,onClick:()=>void ne(),children:[(0,Y.jsx)(Ge,{size:14}),w.busy?w.phase||n(`正在发送`,`Sending`):v===`new`?n(`用此 Prompt 创建 Argus 项目`,`Create Argus project with this prompt`):n(`确认并发送给当前 Argus`,`Confirm and send to current Argus`)]}),w.output?(0,Y.jsx)(`div`,{className:`manager-mini-result`,children:(0,Y.jsx)(Q,{children:w.output})}):null]}):(0,Y.jsx)(Z,{icon:P,title:n(`尚未生成 Prompt`,`No prompt generated`),description:n(`AI 提取后会在这里生成第一版 Prompt,你可以先修改再发送。`,`The first prompt appears here after extraction and can be edited before sending.`)})]})]})]})]})}function Bn({paper:e,selected:t,onClick:n}){let{text:r}=W();return(0,Y.jsxs)(`button`,{type:`button`,className:`paper-card ${t?`is-selected`:``}`,onClick:n,children:[(0,Y.jsxs)(`div`,{className:`paper-card__meta`,children:[(0,Y.jsx)(X,{tone:e.evidenceStatus===`verified_artifact`?`success`:e.evidenceStatus===`metadata`?`info`:`warn`,children:e.evidenceStatus===`verified_artifact`?r(`原文文件已验证`,`Source verified`):e.evidenceStatus===`metadata`?r(`仅元数据`,`Metadata only`):r(`待核验`,`Needs verification`)}),(0,Y.jsxs)(`span`,{className:`paper-card__year`,children:[e.year||`—`,e.venue?` · ${e.venue}`:``]})]}),(0,Y.jsx)(`h3`,{children:e.title}),e.authors.length?(0,Y.jsxs)(`p`,{className:`paper-card__authors`,children:[e.authors.slice(0,4).join(`, `),e.authors.length>4?` et al.`:``]}):null,(0,Y.jsx)(`p`,{className:`paper-card__summary`,children:e.relevance||e.abstract||r(`该记录尚未写入项目相关性摘要。`,`No project-relevance summary has been recorded.`)}),(0,Y.jsxs)(`div`,{className:`paper-card__footer`,children:[(0,Y.jsx)(`code`,{children:e.sourcePath}),(0,Y.jsx)(`span`,{children:r(`查看详情`,`View details`)})]})]})}function Vn(e){let{locale:t,text:n}=W(),r=kn(e.sid,`literature`),a=r.active?.path||``,o=i({queryKey:[`workspace-literature`,e.sid,r.workspaceId],queryFn:({signal:t})=>$.literature(e.sid,r.workspaceId,t),enabled:!!r.workspaceId,refetchInterval:15e3}),[s,c]=(0,z.useState)(`all`),[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(``),g=kt(e.sid,async()=>{await e.refresh(),await o.refetch()}),_=o.data?.papers??[],v=Math.max(0,..._.map(e=>e.year??0)),y=(0,z.useMemo)(()=>_.filter(e=>{if(s===`recent`&&(e.year??0)e.id===d)??y[0]??null,x=(0,z.useMemo)(()=>e.events.filter(e=>/paper|arxiv|doi|literature|search|citation|http/i.test(`${e.type} ${e.kind} ${J(e,2e3)}`)).slice(-30).reverse(),[e.events]),S=async()=>{p.trim()&&await g.run(`请为当前项目执行新的文献调研:${p}\n\n要求读取原始论文或官方仓库,把结构化记录追加到项目的 literature grounding/audit 文件中,包括标题、作者、年份、URL、与当前项目关系、最近工作威胁和仍待全文核验项。完成后文献中心应能从工作目录直接读取这些记录。`)};return(0,Y.jsxs)(`div`,{className:`ros-page literature-v2`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`LITERATURE CENTER`}),(0,Y.jsx)(`h1`,{children:n(`文献中心`,`Literature center`)}),(0,Y.jsx)(`p`,{children:n(`直接读取 Argus 工作目录中的论文清单、文献审计和实时检索轨迹,不再依赖手工注册 artifacts。`,`Read paper inventories, literature audits, and live retrieval traces directly from the Argus workdir.`)})]}),(0,Y.jsxs)(`div`,{className:`header-badges`,children:[(0,Y.jsxs)(X,{tone:`success`,children:[(0,Y.jsx)(I,{size:12}),_.length,` `,n(`篇论文`,`papers`)]}),(0,Y.jsxs)(X,{tone:`neutral`,children:[o.data?.sourceFiles.length??0,` `,n(`个证据文件`,`evidence files`)]})]})]}),(0,Y.jsxs)(`section`,{className:`literature-stats`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--blue`,children:(0,Y.jsx)(I,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`论文记录`,`Paper records`),(0,Y.jsx)(`strong`,{children:_.length})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--green`,children:(0,Y.jsx)(me,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`原文文件已验证`,`Verified sources`),(0,Y.jsx)(`strong`,{children:_.filter(e=>e.evidenceStatus===`verified_artifact`).length})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--amber`,children:(0,Y.jsx)(L,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`最近工作`,`Recent work`),(0,Y.jsx)(`strong`,{children:_.filter(e=>(e.year??0)>=v-1).length})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`stat-icon stat-icon--violet`,children:(0,Y.jsx)(xe,{size:18})}),(0,Y.jsxs)(`p`,{children:[n(`扫描项目文件`,`Scanned files`),(0,Y.jsx)(`strong`,{children:o.data?.scannedFiles??0})]})]})]}),(0,Y.jsxs)(`div`,{className:`literature-v2__layout`,children:[(0,Y.jsxs)(`aside`,{className:`literature-v2__sidebar ros-card`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`LIBRARY`}),(0,Y.jsx)(`h2`,{children:n(`项目文献库`,`Project library`)})]})}),(0,Y.jsxs)(`label`,{className:`search-field search-field--block`,children:[(0,Y.jsx)(h,{size:14}),(0,Y.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:n(`搜索标题、作者、主题`,`Search title, author, or topic`)})]}),(0,Y.jsx)(`nav`,{className:`library-tabs`,children:[[`all`,n(`全部论文`,`All papers`),_.length],[`recent`,n(`最近工作`,`Recent work`),_.filter(e=>(e.year??0)>=v-1).length],[`read`,n(`已验证原文`,`Verified sources`),_.filter(e=>e.evidenceStatus===`verified_artifact`).length],[`sources`,n(`证据文件`,`Evidence files`),o.data?.sourceFiles.length??0]].map(([e,t,n])=>(0,Y.jsxs)(`button`,{type:`button`,className:s===e?`is-active`:``,onClick:()=>c(e),children:[(0,Y.jsx)(`span`,{children:t}),(0,Y.jsx)(`small`,{children:n})]},e))}),(0,Y.jsxs)(`div`,{className:`literature-source-note`,children:[(0,Y.jsx)(fe,{size:15}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:n(`实时来源`,`Live source`)}),(0,Y.jsx)(`p`,{title:a,children:a})]})]})]}),(0,Y.jsxs)(`main`,{className:`literature-v2__main`,children:[(0,Y.jsxs)(`div`,{className:`literature-list-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:s===`recent`?n(`最近工作`,`Recent work`):s===`read`?n(`已验证原文文件`,`Verified source files`):s===`sources`?n(`文献证据文件`,`Literature evidence files`):n(`全部论文`,`All papers`)}),(0,Y.jsx)(`p`,{children:s===`recent`?n(`按项目中最新年份 ${v||`—`} 自动筛选`,`Filtered by the latest project year: ${v||`—`}`):n(`Argus 写入工作目录后约 5 秒内自动更新`,`Updates shortly after Argus writes to the workdir`)})]}),o.isError?(0,Y.jsx)(X,{tone:`danger`,children:n(`同步失败`,`Sync failed`)}):o.isFetching?(0,Y.jsx)(X,{tone:`live`,dot:!0,children:n(`同步中`,`Syncing`)}):(0,Y.jsx)(X,{tone:`success`,children:n(`已同步`,`Synced`)})]}),o.isError?(0,Y.jsx)(`div`,{className:`inline-error`,children:o.error.message}):null,s===`sources`?(0,Y.jsx)(`div`,{className:`source-file-grid`,children:o.data?.sourceFiles.map(e=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(fe,{size:17}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]}),(0,Y.jsx)(`time`,{children:St(e.mtime,t)})]},e.path))}):y.length?(0,Y.jsx)(`div`,{className:`paper-grid`,children:y.map(e=>(0,Y.jsx)(Bn,{paper:e,selected:b?.id===e.id,onClick:()=>f(e.id)},e.id))}):(0,Y.jsx)(Z,{icon:I,title:n(`此筛选下暂无论文`,`No papers match this filter`),description:n(`Argus 完成检索并写入 LITERATURE_GROUNDING.json 后会自动出现。`,`Papers appear after Argus writes LITERATURE_GROUNDING.json.`)})]}),(0,Y.jsxs)(`aside`,{className:`literature-v2__detail`,children:[(0,Y.jsx)(`section`,{className:`ros-card paper-detail`,children:b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`paper-detail__top`,children:[(0,Y.jsx)(X,{tone:b.evidenceStatus===`verified_artifact`?`success`:b.evidenceStatus===`metadata`?`info`:`warn`,children:b.evidenceStatus===`verified_artifact`?`verified artifact`:b.evidenceStatus}),(0,Y.jsxs)(`span`,{children:[b.year||`—`,b.venue?` · ${b.venue}`:``]})]}),(0,Y.jsx)(`h2`,{children:b.title}),b.authors.length?(0,Y.jsx)(`p`,{className:`paper-detail__authors`,children:b.authors.join(`, `)}):null,(0,Y.jsxs)(`div`,{className:`paper-detail__body`,children:[(0,Y.jsx)(`h3`,{children:n(`与当前项目的关系`,`Relationship to this project`)}),(0,Y.jsx)(Q,{children:b.relevance||b.abstract||n(`尚未写入摘要。`,`No summary recorded.`)}),b.abstract&&b.relevance?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:n(`摘要`,`Abstract`)}),(0,Y.jsx)(`p`,{children:b.abstract})]}):null]}),(0,Y.jsxs)(`div`,{className:`paper-detail__source`,children:[(0,Y.jsx)(`span`,{children:n(`证据文件`,`Evidence file`)}),(0,Y.jsx)(`code`,{children:b.sourcePath})]}),b.url?(0,Y.jsxs)(`a`,{className:`button button--secondary button--full`,href:b.url,target:`_blank`,rel:`noreferrer`,children:[n(`打开原始来源`,`Open source`),` `,(0,Y.jsx)(ce,{size:14})]}):null]}):(0,Y.jsx)(Z,{icon:I,title:n(`选择一篇论文`,`Select a paper`)})}),(0,Y.jsxs)(`section`,{className:`ros-card retrieval-panel`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`ARGUS RETRIEVAL`}),(0,Y.jsx)(`h2`,{children:n(`最近检索`,`Recent retrieval`)})]}),(0,Y.jsx)(X,{tone:e.connected?`live`:`warn`,dot:!0,children:e.connected?`Live`:`Polling`})]}),(0,Y.jsxs)(`div`,{children:[(o.data?.searchFiles??[]).slice(0,8).map(e=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(me,{size:13}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]}),(0,Y.jsx)(`time`,{children:xt(e.mtime,t)})]},e.path)),!o.data?.searchFiles.length&&x.slice(0,8).map((e,n)=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(me,{size:13}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:q(e)}),(0,Y.jsx)(`code`,{children:J(e,100)})]}),(0,Y.jsx)(`time`,{children:xt(e.ts,t)})]},`${e.ts}-${n}`))]})]}),(0,Y.jsxs)(`section`,{className:`ros-card literature-ask`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`NEW SEARCH`}),(0,Y.jsx)(`h2`,{children:n(`让 Argus 调研新工作`,`Ask Argus to research new work`)})]})}),(0,Y.jsx)(`textarea`,{rows:3,value:p,onChange:e=>m(e.target.value),placeholder:n(`例如:检索 2025–2026 年与当前方法最接近的直接竞争工作…`,`Example: find the closest competing work from 2025–2026…`)}),(0,Y.jsxs)(`button`,{className:`button button--primary button--full`,type:`button`,disabled:!p.trim()||g.busy,onClick:()=>void S(),children:[(0,Y.jsx)(R,{size:14}),g.busy?g.phase||n(`检索中`,`Researching`):n(`发起文献调研`,`Start literature research`)]}),g.output?(0,Y.jsx)(`div`,{className:`manager-mini-result`,children:(0,Y.jsx)(Q,{children:g.output})}):null]})]})]})]})}function Hn(e){return[`.png`,`.jpg`,`.jpeg`,`.webp`,`.svg`].includes(e.extension)}function Un(e){return[`.csv`,`.tsv`].includes(e.extension)}function Wn(e){return[`.tex`,`.md`].includes(e.extension)}function Gn({src:e,name:t}){let{text:n}=W(),r=(0,z.useRef)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(1),[c,l]=(0,z.useState)(1.25),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let t=!0,n=null;a(null),s(1),d(``),p(!1);let r=localStorage.getItem(`argus_web_token`);return Promise.all([fetch(e,{headers:r?{Authorization:`Bearer ${r}`}:{}}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),S(()=>import(`./pdf-Bit9sP4D.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))]).then(([e,r])=>{if(t)return r.GlobalWorkerOptions.workerSrc=T,n=r.getDocument({data:e}),n.promise}).then(e=>{t&&e&&a(e)}).catch(e=>{t&&d(e instanceof Error?e.message:String(e))}),()=>{t=!1,n?.destroy()}},[e]),(0,z.useEffect)(()=>{if(!i||!r.current)return;p(!1);let e=!1,t=null;return i.getPage(o).then(n=>{if(e||!r.current)return;let i=n.getViewport({scale:c}),a=r.current,o=a.getContext(`2d`);if(!o)return;let s=Math.min(window.devicePixelRatio||1,2);return a.width=Math.floor(i.width*s),a.height=Math.floor(i.height*s),a.style.width=`${i.width}px`,a.style.height=`${i.height}px`,t=n.render({canvas:a,canvasContext:o,viewport:i,transform:s===1?void 0:[s,0,0,s,0,0]}),t.promise.then(()=>{e||p(!0)})}).catch(t=>{e||d(t instanceof Error?t.message:String(t))}),()=>{e=!0,t?.cancel()}},[i,o,c]),(0,Y.jsxs)(`div`,{className:`pdf-canvas-viewer`,children:[(0,Y.jsxs)(`div`,{className:`pdf-canvas-toolbar`,children:[(0,Y.jsx)(`strong`,{children:t}),(0,Y.jsxs)(`span`,{children:[n(`第`,`Page`),` `,o,` / `,i?.numPages??`…`]}),(0,Y.jsx)(`button`,{type:`button`,disabled:o<=1,onClick:()=>s(e=>e-1),children:n(`上一页`,`Previous`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:!i||o>=i.numPages,onClick:()=>s(e=>e+1),children:n(`下一页`,`Next`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e=>Math.max(.75,e-.15)),children:`−`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e=>Math.min(2,e+.15)),children:`+`})]}),u?(0,Y.jsx)(`div`,{className:`inline-error`,children:u}):null,(0,Y.jsx)(`div`,{className:`pdf-canvas-scroll`,children:(0,Y.jsx)(`canvas`,{ref:r,"data-rendered":f?`true`:`false`})})]})}function Kn({sid:e,workspaceId:t,entry:n}){let{text:r}=W(),a=i({queryKey:[`paper-source-file`,e,t,n?.path,n?.mtime],queryFn:({signal:r})=>$.file(e,t,n.path,r),enabled:!!(n&&t),refetchInterval:8e3});return n?a.isError?(0,Y.jsx)(Z,{icon:P,title:r(`源文件暂时无法读取`,`Source file unavailable`),description:a.error.message}):n.extension===`.md`&&a.data?(0,Y.jsx)(`div`,{className:`paper-markdown-preview`,children:(0,Y.jsx)(Q,{children:a.data.content})}):(0,Y.jsxs)(`div`,{className:`latex-source`,children:[(0,Y.jsx)(`div`,{className:`latex-line-numbers`,children:(a.data?.content??``).split(` `).map((e,t)=>(0,Y.jsx)(`span`,{children:t+1},t))}),(0,Y.jsx)(`pre`,{children:a.data?.content||`Loading…`})]}):(0,Y.jsx)(Z,{icon:P,title:r(`等待 Argus 写入论文源文件`,`Waiting for Argus to write a paper source`),description:r(`paper/ 或 technical_report/ 中出现 .tex / .md 后会自动加入。`,`.tex and .md files under paper/ or technical_report/ appear automatically.`)})}function qn({sid:e,workspaceId:t,entry:n}){let r=On(e,t,n.path);return(0,Y.jsxs)(`figure`,{children:[r.url?(0,Y.jsx)(`img`,{src:r.url,alt:n.name}):(0,Y.jsx)(`div`,{className:`figure-loading`,children:r.error||`Loading…`}),(0,Y.jsx)(`figcaption`,{children:n.name})]})}function Jn(e){let{locale:t,text:n}=W(),r=kn(e.sid,`paper`),a=r.workspaceId,o=r.active?.path||``,s=i({queryKey:[`paper-workspace-tree`,e.sid,a],queryFn:({signal:t})=>$.tree(e.sid,a,t),enabled:!!a,refetchInterval:1e4}),c=(0,z.useMemo)(()=>En(s.data?.entries??[]),[s.data?.entries]),l=c.filter(Wn),u=c.filter(e=>e.extension===`.bib`),d=c.filter(e=>e.extension===`.pdf`),f=c.filter(e=>Hn(e)||Un(e)),[p,m]=(0,z.useState)(``),h=[...l,...u].find(e=>e.path===p)??l[0]??u[0]??null,[g,_]=(0,z.useState)(`pdf`),[v,y]=(0,z.useState)(``),b=d.find(e=>/(?:^|\/)(?:argus-technical-report|main|paper|manuscript)\.pdf$/i.test(e.path))??d[0],x=d.find(e=>e.path===v)??b??null;return(0,Y.jsxs)(`div`,{className:`ros-page paper-v3`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`PAPER WORKSPACE`}),(0,Y.jsx)(`h1`,{children:n(`LaTeX 论文工作区`,`LaTeX paper workspace`)}),(0,Y.jsx)(`p`,{children:n(`论文源文件、编译 PDF、图表和 BibTeX 与真实项目目录保持同步。`,`Keep paper sources, compiled PDFs, figures, and BibTeX synchronized with the real project directory.`)})]}),(0,Y.jsxs)(`div`,{className:`header-badges`,children:[(0,Y.jsxs)(X,{tone:s.isError?`danger`:s.isFetching?`live`:`success`,dot:!0,children:[(0,Y.jsx)(nt,{size:12}),s.isError?n(`同步失败`,`Sync failed`):s.isFetching?n(`同步中`,`Syncing`):n(`自动同步`,`Auto sync`)]}),(0,Y.jsxs)(X,{tone:d.length?`success`:`neutral`,children:[d.length,` PDF`]}),(0,Y.jsxs)(X,{tone:`neutral`,children:[f.length,` `,n(`图表`,`figures`)]})]})]}),(0,Y.jsxs)(`div`,{className:`paper-root-bar ros-card`,children:[(0,Y.jsx)(be,{size:16}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`APPROVED PAPER WORKSPACE`}),(0,Y.jsx)(`select`,{"aria-label":n(`选择论文工作区`,`Select paper workspace`),value:a,onChange:e=>{r.setWorkspaceId(e.target.value),m(``),y(``)},children:r.profiles.data?.profiles.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,Y.jsx)(`code`,{children:o})]}),s.isError?(0,Y.jsx)(X,{tone:`danger`,children:`Error`}):s.isFetching?(0,Y.jsx)(X,{tone:`live`,dot:!0,children:`Scanning`}):(0,Y.jsx)(X,{tone:`success`,children:`Synced`}),(0,Y.jsx)(`button`,{className:`icon-button`,type:`button`,onClick:()=>void s.refetch(),"aria-label":n(`刷新论文工作区`,`Refresh paper workspace`),children:(0,Y.jsx)(He,{size:14})})]}),(0,Y.jsxs)(`div`,{className:`paper-v3__shell`,children:[(0,Y.jsxs)(`aside`,{className:`paper-v3__sources ros-card`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`LATEX PROJECT`}),(0,Y.jsx)(`h2`,{children:n(`论文文件`,`Paper files`)})]}),(0,Y.jsx)(X,{tone:`neutral`,children:l.length+u.length})]}),(0,Y.jsxs)(`div`,{className:`paper-source-group`,children:[(0,Y.jsxs)(`h3`,{children:[(0,Y.jsx)(P,{size:13}),`MANUSCRIPT`]}),l.length?l.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:h?.path===e.path?`is-active`:``,onClick:()=>m(e.path),children:[(0,Y.jsx)(P,{size:14}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]}),(0,Y.jsx)(`small`,{children:Ct(e.size)})]},e.path)):(0,Y.jsx)(`p`,{children:`等待 .tex / .md`})]}),(0,Y.jsxs)(`div`,{className:`paper-source-group`,children:[(0,Y.jsxs)(`h3`,{children:[(0,Y.jsx)(I,{size:13}),`BIBTEX`]}),u.length?u.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(e.path),children:[(0,Y.jsx)(I,{size:14}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]})]},e.path)):(0,Y.jsx)(`p`,{children:n(`等待 references.bib`,`Waiting for references.bib`)})]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`span`,{children:n(`监听`,`Watching`)}),(0,Y.jsx)(`code`,{children:o})]})]}),(0,Y.jsxs)(`main`,{className:`paper-v3__source ros-card`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:h?.name||n(`源文件编辑器`,`Source editor`)}),(0,Y.jsx)(`code`,{children:h?.path||o})]}),h?(0,Y.jsxs)(`span`,{children:[n(`更新于`,`Updated`),` `,St(h.mtime,t)]}):null]}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Kn,{sid:e.sid,workspaceId:a,entry:h})}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`span`,{children:h?.extension.replace(`.`,``).toUpperCase()||`WAITING`}),(0,Y.jsx)(`span`,{children:h?Ct(h.size):n(`Argus 写入后自动出现`,`Appears after Argus writes it`)})]})]}),(0,Y.jsxs)(`aside`,{className:`paper-v3__outputs ros-card`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`BUILD OUTPUT`}),(0,Y.jsx)(`h2`,{children:n(`可视化产出`,`Visual outputs`)})]}),s.isError?(0,Y.jsx)(X,{tone:`danger`,children:`Error`}):s.isFetching?(0,Y.jsx)(X,{tone:`live`,dot:!0,children:`Scanning`}):(0,Y.jsx)(X,{tone:`success`,children:`Synced`})]}),(0,Y.jsxs)(`nav`,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:g===`pdf`?`is-active`:``,onClick:()=>_(`pdf`),children:[(0,Y.jsx)(P,{size:14}),`PDF `,(0,Y.jsx)(`small`,{children:d.length})]}),(0,Y.jsxs)(`button`,{type:`button`,className:g===`figures`?`is-active`:``,onClick:()=>_(`figures`),children:[(0,Y.jsx)(de,{size:14}),n(`图表`,`Figures`),` `,(0,Y.jsx)(`small`,{children:f.length})]}),(0,Y.jsxs)(`button`,{type:`button`,className:g===`references`?`is-active`:``,onClick:()=>_(`references`),children:[(0,Y.jsx)(I,{size:14}),n(`引用`,`References`),` `,(0,Y.jsx)(`small`,{children:u.length})]})]}),(0,Y.jsxs)(`div`,{className:`paper-output-surface`,children:[g===`pdf`?x?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`pdf-switcher`,children:d.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:x.path===e.path?`is-active`:``,onClick:()=>y(e.path),children:e.name},e.path))}),(0,Y.jsx)(Gn,{src:$.rawUrl(e.sid,a,x.path),name:x.name})]}):(0,Y.jsx)(Z,{icon:P,title:n(`尚无编译 PDF`,`No compiled PDF`),description:n(`Argus 或 LaTeX 流程生成 PDF 后会直接在这里可视化。`,`PDFs generated by Argus or the LaTeX pipeline appear here.`)}):null,g===`figures`?f.length?(0,Y.jsx)(`div`,{className:`paper-figure-grid`,children:f.map(t=>Hn(t)?(0,Y.jsx)(qn,{sid:e.sid,workspaceId:a,entry:t},t.path):(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(Je,{size:22}),(0,Y.jsx)(`strong`,{children:t.name}),(0,Y.jsx)(`code`,{children:t.path})]},t.path))}):(0,Y.jsx)(Z,{icon:de,title:n(`尚无图表产出`,`No figure outputs`)}):null,g===`references`?u.length?(0,Y.jsx)(`div`,{className:`paper-reference-list`,children:u.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.path)},children:[(0,Y.jsx)(I,{size:15}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`code`,{children:e.path})]})]},e.path))}):(0,Y.jsx)(Z,{icon:I,title:n(`尚无 BibTeX`,`No BibTeX`)}):null]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`span`,{children:d.length?`PDF build detected`:`Waiting for LaTeX build`}),(0,Y.jsxs)(`span`,{children:[c.length,` tracked assets`]})]})]})]})]})}var Yn=[{id:`counterexamples`,zh:`反例实验室`,en:`Counterexample Lab`,zhDesc:`切换查看每个猜想的实时阶段、反例构造、证据和复核状态。`,enDesc:`Switch between conjectures and track construction, evidence, and review live.`,icon:Be,color:`violet`,researchOnly:!1},{id:`experiments`,zh:`运行进程`,en:`Execution`,zhDesc:`实时查看 Argus 运行位置、任务路线、角色交接和停止原因。`,enDesc:`Track Argus execution, task progress, role handoffs, and stop reasons.`,icon:ve,color:`blue`,researchOnly:!1},{id:`copilot`,zh:`Argus Copilot`,en:`Argus Copilot`,zhDesc:`查看 Argus 对话、Prompt 优化和工具轨迹。`,enDesc:`Chat with Argus, refine prompts, and inspect tool activity.`,icon:Ie,color:`violet`,researchOnly:!1},{id:`literature`,zh:`文献中心`,en:`Literature`,zhDesc:`汇总已读论文、最近工作、检索记录和文献证据。`,enDesc:`Review papers, related work, retrieval history, and evidence.`,icon:I,color:`indigo`,researchOnly:!0},{id:`inbox`,zh:`科研收信箱`,en:`Research Inbox`,zhDesc:`从零散输入抽取知识点并形成第一版 Argus Prompt。`,enDesc:`Turn rough notes into structured knowledge and an Argus prompt.`,icon:De,color:`rose`,researchOnly:!0},{id:`ide`,zh:`AI IDE`,en:`AI IDE`,zhDesc:`连接真实服务器目录,查看代码、Git 和 Argus 活动。`,enDesc:`Browse server files, Git state, and Argus activity.`,icon:oe,color:`emerald`,researchOnly:!1},{id:`paper`,zh:`论文工作区`,en:`Paper Workspace`,zhDesc:`自动发现 Argus 新写入的文稿、BibTeX、图表和 PDF。`,enDesc:`Discover manuscripts, BibTeX, figures, and PDFs from the workspace.`,icon:P,color:`amber`,researchOnly:!0},{id:`reviewer`,zh:`模拟审稿`,en:`Reviewer`,zhDesc:`区分每轮过程审稿与项目完成后的最终投稿前审稿。`,enDesc:`Separate round-level review from final pre-submission review.`,icon:p,color:`slate`,researchOnly:!0},{id:`release`,zh:`成果发布`,en:`Release`,zhDesc:`规划 GitHub 仓库、学术海报和项目宣传页。`,enDesc:`Plan a GitHub repository, academic poster, and project page.`,icon:Pe,color:`rose`,researchOnly:!0}];function Xn(e){let{text:t}=W(),n=e.snapshot.mission_view,r=n?.routing.vertical===`research`,i=(r?Yn:Yn.filter(e=>!e.researchOnly)).filter(t=>t.id!==`counterexamples`||!!e.counterexamples?.total),a=n?.active_role||e.status?.active_role||`idle`,o=[U(n?.mission.status||`idle`,t),n?.outcome.stage_certification?vt(n.outcome.stage_certification,t):``].filter(Boolean).join(` · `);return(0,Y.jsxs)(`div`,{className:`overview-page`,children:[(0,Y.jsxs)(`section`,{className:`overview-hero`,children:[(0,Y.jsxs)(`div`,{className:`overview-hero__copy`,children:[(0,Y.jsxs)(`div`,{className:`overview-hero__badges`,children:[(0,Y.jsx)(X,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?t(`Argus 正在运行`,`Argus running`):t(`Argus 已停止`,`Argus stopped`)}),(0,Y.jsx)(X,{tone:G(n?.stage.id),children:n?.stage.label||_t(n?.stage.id,t)})]}),(0,Y.jsx)(`h1`,{children:e.snapshot.session.display_name||e.project.label}),(0,Y.jsx)(`p`,{children:n?.mission.objective||e.status?.continuous?.objective||e.project.objective||t(`尚未设置目标。`,`No objective has been set.`)})]}),(0,Y.jsxs)(`div`,{className:`overview-hero__stats`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:t(`当前角色`,`Active role`)}),(0,Y.jsx)(`strong`,{children:gt(a,t)}),(0,Y.jsx)(`small`,{children:e.snapshot.roles.find(e=>e.active)?.label||U(`waiting`,t)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:r?t(`研究阶段`,`Research stage`):t(`工作流阶段`,`Workflow stage`)}),(0,Y.jsx)(`strong`,{children:n?.stage.label||_t(n?.stage.id,t)}),(0,Y.jsx)(`small`,{children:o})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:t(`累计运行`,`Elapsed`)}),(0,Y.jsx)(`strong`,{children:bt(n?.mission.campaign_elapsed_seconds||e.snapshot.daemon.uptime_seconds)}),(0,Y.jsx)(`small`,{children:n?.round.current?t(`第 ${n.round.current}/${n.round.max||`—`} 轮`,`Round ${n.round.current}/${n.round.max||`—`}`):t(`暂无轮次`,`No round`)})]})]})]}),(0,Y.jsx)(`div`,{className:`overview-section-heading`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:t(`项目工作区`,`Project workspace`)}),(0,Y.jsx)(`p`,{children:t(`所有模块共享同一个 Argus 项目、项目文件和实时动态。`,`All modules share the same Argus project, project files, and live activity.`)})]})}),(0,Y.jsx)(`section`,{className:`module-grid`,children:i.map(n=>{let r=n.icon;return(0,Y.jsxs)(`button`,{className:`module-card`,type:`button`,onClick:()=>e.navigate(n.id),children:[(0,Y.jsx)(`span`,{className:`module-card__icon module-card__icon--${n.color}`,children:(0,Y.jsx)(r,{size:20})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:t(n.zh,n.en)}),(0,Y.jsx)(`p`,{children:t(n.zhDesc,n.enDesc)})]}),(0,Y.jsx)(F,{size:16})]},n.id)})}),(0,Y.jsxs)(`section`,{className:`overview-lower`,children:[(0,Y.jsx)(Tt,{eyebrow:`CURRENT MISSION`,title:t(`当前任务`,`Current mission`),children:(0,Y.jsxs)(`div`,{className:`overview-mission`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(Xe,{size:18}),(0,Y.jsx)(`span`,{children:U(n?.mission.status||`idle`,t)})]}),(0,Y.jsx)(`h3`,{children:n?.mission.title||e.project.current_task||t(`等待新任务`,`Waiting for a new task`)}),(0,Y.jsx)(`p`,{children:n?.mission.summary||n?.frontier.summary||n?.review.reason||t(`Argus 的下一步和 Reviewer 边界会在这里同步。`,`Argus next steps and reviewer boundaries appear here.`)}),(0,Y.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>e.navigate(`experiments`),children:[t(`查看完整实验进程`,`View experiment progress`),` `,(0,Y.jsx)(F,{size:14})]})]})}),(0,Y.jsx)(Tt,{eyebrow:`RECENT ACTIVITY`,title:t(`最近活动`,`Recent activity`),bodyClassName:`panel__body--flush`,children:(0,Y.jsx)(Dt,{events:e.events,limit:7,dense:!0})})]})]})}var Zn=[`ICLR`,`NeurIPS`,`ICML`,`TMLR`,`ACL`,`EMNLP`,`NAACL`,`CVPR`,`ICCV`,`ECCV`,`AAAI`,`KDD`,`Nature Machine Intelligence`,`JMLR`,`IEEE TPAMI`,`__custom__`],Qn=[`Novelty`,`Technical soundness`,`Experimental rigor`,`Baseline fairness`,`Statistical validity`,`Reproducibility`,`Writing clarity`,`Ethics / limitations`,`Artifact availability`],$n=`请特别检查 train/dev/test 泄漏、baseline 是否公平,以及 novelty claim 是否被现有直接工作覆盖。`,er=`Pay special attention to train/dev/test leakage, baseline fairness, and whether direct prior work covers the novelty claim.`;function tr({mode:e,reviewerActive:t,hasReport:n}){let{text:r}=W(),i=e===`process`?[[r(`Engineer 执行`,`Engineer execution`),r(`代码、实验与证据`,`Code, experiments, and evidence`),oe],[r(`Reviewer 检查`,`Reviewer check`),r(`独立核验当前轮次`,`Independent round verification`),p],[r(`得出判断`,`Reach a judgment`),`done / continue / blocked`,We],[r(`回流下一轮`,`Return to next round`),r(`修复任务进入 backlog`,`Repair tasks enter the backlog`),f]]:[[r(`选择最终稿`,`Select final draft`),r(`LaTeX / PDF 与全部证据`,`LaTeX / PDF and the supporting evidence`),P],[r(`独立最终审稿`,`Independent final review`),r(`按目标 venue 全面检查`,`Full target-venue review`),p],[r(`生成审稿报告`,`Generate review report`),r(`评分、问题与置信度`,`Scores, issues, and confidence`),pe],[r(`待修改事项`,`Revisions to make`),r(`投稿前人工确认`,`Human confirmation before submission`),Ae]];return(0,Y.jsx)(`div`,{className:`review-flow`,children:i.map(([e,r,a],o)=>(0,Y.jsxs)(`div`,{className:t&&o===1||n&&o>=2?`is-active`:o===0?`is-done`:``,children:[(0,Y.jsx)(`span`,{children:o+1}),(0,Y.jsx)(a,{size:17}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e}),(0,Y.jsx)(`small`,{children:r})]}),o(o?.role_work??[]).filter(e=>e.role===`reviewer`).filter(e=>/review|verdict|decision|completion|handoff/i.test(`${e.kind} ${e.title}`)).sort((e,t)=>t.ts-e.ts),[o?.role_work]),c=(0,z.useMemo)(()=>e.events.filter(e=>/review/.test(String(e.type??``))||/review/.test(String(e.agent_layer??e.actor??``))),[e.events]),[l,u]=(0,z.useState)(``),d=s.find(e=>e.id===l)??s[0]??null,f=kn(e.sid,`review`),m=i({queryKey:[`review-workspace-tree`,e.sid,f.workspaceId],queryFn:({signal:t})=>$.tree(e.sid,f.workspaceId,t),enabled:!!f.workspaceId,refetchInterval:12e3}),h=(m.data?.entries??[]).filter(e=>e.type===`file`&&!/final[_-]?review[_-]?request/i.test(e.path)&&/final[_-]?review|final[_-]?.*verdict|submission[_-]?review/i.test(e.path)).filter(e=>[`.md`,`.txt`,`.json`].includes(e.extension)).sort((e,t)=>t.mtime-e.mtime),g=(m.data?.entries??[]).filter(e=>e.type===`file`&&[`.tex`,`.md`,`.pdf`].includes(e.extension)&&/(?:^|\/)(paper|manuscript|technical_report)(?:\/|$)/i.test(e.path)).sort((e,t)=>t.mtime-e.mtime),[_,v]=(0,z.useState)(``),[y,b]=(0,z.useState)(``),x=h.find(e=>e.path===y)??h[0]??null,S=i({queryKey:[`final-review-file`,e.sid,f.workspaceId,x?.path,x?.mtime],queryFn:({signal:t})=>$.file(e.sid,f.workspaceId,x.path,t),enabled:!!(x&&f.workspaceId),refetchInterval:12e3}),[C,w]=(0,z.useState)(`ICLR`),[T,E]=(0,z.useState)(``),[D,O]=(0,z.useState)(`conference`),[k,te]=(0,z.useState)(`strict`),[A,j]=(0,z.useState)([`Novelty`,`Technical soundness`,`Experimental rigor`,`Baseline fairness`,`Reproducibility`]),[M,ne]=(0,z.useState)(()=>t===`zh-CN`?$n:er),[N,re]=(0,z.useState)(!1),[P,F]=(0,z.useState)(``),[ie,I]=(0,z.useState)(``),L=o?.review,ae=o?.roles.find(e=>e.role===`reviewer`)||e.snapshot.roles.find(e=>e.role===`reviewer`);(0,z.useEffect)(()=>{ne(e=>e===$n||e===er?t===`zh-CN`?$n:er:e)},[t]);let oe=async()=>{let t=C===`__custom__`?T.trim():C;if(!(!t||!M.trim()||!confirm(n(`确认在项目完成后按 ${t} 标准发起独立最终审稿?`,`Start an independent final review using ${t} standards?`)))){re(!0),F(``),I(``);try{let r=await H.createFinalReview(e.sid,{venue:t,venue_type:D,strictness:k,manuscript_path:_,emphasis:A,scope:M});I(n(`最终审稿已进入 Argus 队列 · ${r.manifest_path}`,`Final review queued in Argus · ${r.manifest_path}`)),await Promise.all([e.refresh(),m.refetch()])}catch(e){F(e instanceof Error?e.message:String(e))}finally{re(!1)}}};return(0,Y.jsxs)(`div`,{className:`ros-page reviewer-v2`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`REVIEWER ARENA`}),(0,Y.jsx)(`h1`,{children:n(`模拟审稿`,`Reviewer arena`)}),(0,Y.jsx)(`p`,{children:n(`过程审稿用于每轮 Engineer ⇄ Reviewer 纠偏;最终审稿用于论文完成后的投稿前独立检查。`,`Process review corrects each Engineer ⇄ Reviewer round; final review is an independent pre-submission check.`)})]}),(0,Y.jsx)(X,{tone:ae?.status?G(ae.status):`neutral`,dot:ae?.status===`active`,children:ae?.status||`waiting`})]}),(0,Y.jsxs)(`div`,{className:`review-mode-tabs`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:r===`process`?`is-active`:``,onClick:()=>a(`process`),children:[(0,Y.jsx)(Te,{size:16}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:n(`过程审稿`,`Process review`)}),(0,Y.jsx)(`small`,{children:n(`Argus 每轮执行中的 Reviewer 反馈`,`Reviewer feedback during each Argus round`)})]}),(0,Y.jsx)(X,{tone:`neutral`,children:s.length})]}),(0,Y.jsxs)(`button`,{type:`button`,className:r===`final`?`is-active`:``,onClick:()=>a(`final`),children:[(0,Y.jsx)(We,{size:16}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:n(`最终审稿`,`Final review`)}),(0,Y.jsx)(`small`,{children:n(`项目完成后的独立投稿前审稿`,`Independent pre-submission review`)})]}),(0,Y.jsx)(X,{tone:`neutral`,children:h.length})]})]}),r===`process`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(tr,{mode:`process`,reviewerActive:ae?.status===`active`,hasReport:!!L?.status}),(0,Y.jsxs)(`div`,{className:`process-review-layout`,children:[(0,Y.jsxs)(`aside`,{className:`ros-card review-rounds`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`ENGINEER ⇄ REVIEWER`}),(0,Y.jsx)(`h2`,{children:n(`过程审稿轮次`,`Process review rounds`)})]})}),(0,Y.jsx)(`div`,{children:s.length?s.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:d?.id===e.id?`is-active`:``,onClick:()=>u(e.id),children:[(0,Y.jsx)(`span`,{className:`review-state review-state--${G(e.status)}`,children:(0,Y.jsx)(p,{size:14})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.title}),(0,Y.jsxs)(`small`,{children:[St(e.ts,t),` · `,e.status||e.kind]})]})]},e.id)):(0,Y.jsx)(Z,{icon:p,title:n(`暂无过程审稿`,`No process reviews yet`)})})]}),(0,Y.jsxs)(`main`,{className:`ros-card process-report`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`ROUND JUDGMENT`}),(0,Y.jsx)(`h2`,{children:d?.title||n(`选择一轮 Reviewer 反馈`,`Select reviewer feedback`)})]}),d?(0,Y.jsx)(X,{tone:G(d.status),children:d.status}):null]}),d?(0,Y.jsxs)(`article`,{children:[(0,Y.jsxs)(`div`,{className:`process-report__meta`,children:[(0,Y.jsxs)(`span`,{children:[`Round `,d.round_index??`—`]}),(0,Y.jsx)(`time`,{children:St(d.ts,t)})]}),(0,Y.jsx)(Q,{children:d.detail||n(`该轮没有留下可展示报告。`,`This round has no displayable report.`)})]}):(0,Y.jsx)(Z,{icon:pe,title:n(`选择左侧过程审稿`,`Select a process review`)})]}),(0,Y.jsxs)(`aside`,{className:`ros-card review-live`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`LIVE REVIEW EVENTS`}),(0,Y.jsx)(`h2`,{children:n(`Reviewer 实时轨迹`,`Live reviewer activity`)})]}),(0,Y.jsx)(X,{tone:e.connected?`live`:`warn`,dot:!0,children:e.connected?`Live`:`Polling`})]}),(0,Y.jsx)(Dt,{events:c,limit:24,dense:!0})]}),(0,Y.jsxs)(`section`,{className:`process-verdict-card`,children:[(0,Y.jsx)(`span`,{className:`process-verdict-card__icon process-verdict-card__icon--${G(L?.status)}`,children:G(L?.status)===`success`?(0,Y.jsx)(ee,{size:21}):(0,Y.jsx)(Qe,{size:21})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`当前判断`,`Current judgment`)}),(0,Y.jsx)(`strong`,{children:L?.status||`Awaiting review`}),(0,Y.jsx)(`p`,{children:L?.reason||n(`Reviewer 完成下一轮后会写入判断和行动要求。`,`The Reviewer will record a decision and required actions after the next round.`)})]})]})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(tr,{mode:`final`,reviewerActive:N,hasReport:!!(x||ie)}),(0,Y.jsxs)(`div`,{className:`final-review-layout`,children:[(0,Y.jsxs)(`aside`,{className:`ros-card final-review-files`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`FINAL REPORTS`}),(0,Y.jsx)(`h2`,{children:n(`最终审稿报告`,`Final review reports`)})]})}),(0,Y.jsx)(`div`,{children:h.length?h.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:x?.path===e.path?`is-active`:``,onClick:()=>b(e.path),children:[(0,Y.jsx)(pe,{size:14}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`small`,{children:St(e.mtime,t)})]})]},e.path)):(0,Y.jsx)(Z,{icon:pe,title:n(`还没有最终审稿报告`,`No final review report yet`),description:n(`完成论文后可从右侧发起。`,`Start one from the form after the paper is complete.`)})})]}),(0,Y.jsxs)(`main`,{className:`ros-card final-review-report`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`INDEPENDENT REVIEW`}),(0,Y.jsx)(`h2`,{children:x?.name||n(`投稿前最终审稿`,`Pre-submission final review`)})]}),x?(0,Y.jsx)(X,{tone:`success`,children:`Saved report`}):null]}),S.data?(0,Y.jsx)(`article`,{children:(0,Y.jsx)(Q,{children:S.data.content})}):ie?(0,Y.jsxs)(`article`,{className:`final-review-receipt`,children:[(0,Y.jsx)(X,{tone:`success`,children:`Queued`}),(0,Y.jsx)(`p`,{children:ie}),(0,Y.jsx)(`small`,{children:n(`Argus 将生成结构化最终审稿报告;可在过程事件和任务路线查看执行状态。`,`Argus will generate a structured final review report; execution remains visible in events and the task route.`)})]}):(0,Y.jsx)(Z,{icon:We,title:n(`项目完成后再发起最终审稿`,`Start final review after project completion`),description:n(`最终 Reviewer 会读取完整稿件、实验、文献与过程审稿记录。`,`The final Reviewer reads the full manuscript, experiments, literature, and process-review history.`)})]}),(0,Y.jsxs)(`aside`,{className:`ros-card final-review-form`,children:[(0,Y.jsx)(`header`,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:`NEW FINAL REVIEW`}),(0,Y.jsx)(`h2`,{children:n(`发起独立最终审稿`,`Start independent final review`)})]})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{className:`field`,children:[(0,Y.jsx)(`span`,{children:n(`选择最终稿`,`Select final manuscript`)}),(0,Y.jsxs)(`select`,{value:_,onChange:e=>v(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:n(`自动选择最新稿件`,`Automatically select latest`)}),g.map(e=>(0,Y.jsx)(`option`,{value:e.path,children:e.path},e.path))]})]}),(0,Y.jsxs)(`div`,{className:`review-form-row`,children:[(0,Y.jsxs)(`label`,{className:`field`,children:[(0,Y.jsx)(`span`,{children:n(`Venue 类型`,`Venue type`)}),(0,Y.jsxs)(`select`,{value:D,onChange:e=>O(e.target.value),children:[(0,Y.jsx)(`option`,{value:`conference`,children:`Conference`}),(0,Y.jsx)(`option`,{value:`journal`,children:`Journal`}),(0,Y.jsx)(`option`,{value:`workshop`,children:`Workshop`})]})]}),(0,Y.jsxs)(`label`,{className:`field`,children:[(0,Y.jsx)(`span`,{children:n(`审稿严格度`,`Review strictness`)}),(0,Y.jsxs)(`select`,{value:k,onChange:e=>te(e.target.value),children:[(0,Y.jsx)(`option`,{value:`preflight`,children:n(`快速预检`,`Quick preflight`)}),(0,Y.jsx)(`option`,{value:`standard`,children:n(`标准审稿`,`Standard review`)}),(0,Y.jsx)(`option`,{value:`strict`,children:n(`严格模拟审稿`,`Strict simulated review`)}),(0,Y.jsx)(`option`,{value:`red-team`,children:`Red Team / Desk Reject`})]})]})]}),(0,Y.jsxs)(`label`,{className:`field`,children:[(0,Y.jsx)(`span`,{children:n(`目标会议 / 期刊`,`Target venue`)}),(0,Y.jsx)(`select`,{value:C,onChange:e=>w(e.target.value),children:Zn.map(e=>(0,Y.jsx)(`option`,{value:e,children:e===`__custom__`?n(`其他 / 自定义…`,`Other / custom…`):e},e))})]}),C===`__custom__`?(0,Y.jsxs)(`label`,{className:`field`,children:[(0,Y.jsx)(`span`,{children:n(`自定义 Venue 名称`,`Custom venue name`)}),(0,Y.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:n(`例如:Nature Machine Intelligence / CHI Workshop`,`Example: Nature Machine Intelligence / CHI Workshop`)})]}):null,(0,Y.jsxs)(`fieldset`,{className:`review-emphasis`,children:[(0,Y.jsx)(`legend`,{children:n(`重点审查维度`,`Review emphasis`)}),Qn.map(e=>(0,Y.jsxs)(`label`,{children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:A.includes(e),onChange:()=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}),(0,Y.jsx)(`span`,{children:e})]},e))]}),(0,Y.jsxs)(`label`,{className:`field`,children:[(0,Y.jsx)(`span`,{children:n(`特别强调`,`Special emphasis`)}),(0,Y.jsx)(`textarea`,{rows:5,value:M,onChange:e=>ne(e.target.value),placeholder:n(`写明你最希望 Reviewer 严格检查的问题…`,`Describe what the Reviewer should scrutinize most…`)})]}),(0,Y.jsxs)(`div`,{className:`final-review-warning`,children:[(0,Y.jsx)(Qe,{size:15}),(0,Y.jsx)(`p`,{children:n(`这是完成阶段的独立 Reviewer,不替代正式同行评审,也不会自动投稿。`,`This independent completion-stage Reviewer does not replace peer review and never submits automatically.`)})]}),(0,Y.jsxs)(`button`,{className:`button button--primary button--full`,type:`button`,disabled:N||!M.trim()||C===`__custom__`&&!T.trim(),onClick:()=>void oe(),children:[N?(0,Y.jsx)(R,{size:14}):(0,Y.jsx)(Ge,{size:14}),N?n(`正在创建审稿任务`,`Creating review task`):n(`开始最终审稿`,`Start final review`)]}),P?(0,Y.jsx)(`div`,{className:`inline-error`,children:P}):null]})]})]})]})]})}var rr=[{icon:we,title:`GitHub Repository`,zhDetail:`README、LICENSE、CITATION.cff、环境文件、Secret Scan 与人工确认后的仓库创建。`,enDetail:`Prepare README, LICENSE, CITATION.cff, environment files, secret scanning, and an approved repository.`,zhItems:[`选择账户与可见性`,`生成发布清单`,`预览 Git diff`,`人工批准后 push`],enItems:[`Choose account and visibility`,`Generate release manifest`,`Preview Git diff`,`Push after approval`]},{icon:ze,title:`Academic Poster`,zhDetail:`从最终稿、图表和结果中生成可审阅的学术海报。`,enDetail:`Generate a reviewable academic poster from the final paper, figures, and results.`,zhItems:[`A0/A1 与横竖版`,`机构 Logo 与主题`,`图表布局`,`PDF / PNG / SVG`],enItems:[`A0/A1 portrait or landscape`,`Institution logo and theme`,`Figure layout`,`PDF / PNG / SVG`]},{icon:se,title:`Project Page`,zhDetail:`生成论文项目宣传页和可部署的静态站点。`,enDetail:`Generate a paper project page and deployable static site.`,zhItems:[`方法与结果展示`,`交互式图表`,`Paper / Code / Model`,`预览后部署`],enItems:[`Methods and results`,`Interactive charts`,`Paper / Code / Model`,`Deploy after preview`]}];function ir(e){let{text:t}=W();return(0,Y.jsxs)(`div`,{className:`ros-page release-page`,children:[(0,Y.jsxs)(`header`,{className:`ros-page-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`RESULTS RELEASE`}),(0,Y.jsx)(`h1`,{children:t(`成果发布`,`Results release`)}),(0,Y.jsx)(`p`,{children:t(`未来用于把研究工作整理成 GitHub 仓库、学术海报和项目宣传页。当前只展示规划,不执行发布。`,`Plan a GitHub repository, academic poster, and project page. This view does not publish anything yet.`)})]}),(0,Y.jsx)(X,{tone:`warn`,children:t(`敬请期待`,`Planned`)})]}),(0,Y.jsxs)(`section`,{className:`release-hero`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(R,{size:28})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`eyebrow`,children:`PLANNED WORKSPACE`}),(0,Y.jsx)(`h2`,{children:t(`从研究产物到可审核的公开成果`,`From research artifacts to reviewable public outputs`)}),(0,Y.jsx)(`p`,{children:t(`后续将调用受审计的 AI Agent 基于真实工作区生成发布补丁和视觉资产,但任何外部创建、push 或部署都需要人工批准。`,`Audited agents will generate release patches and visual assets from the real workspace, while every external create, push, or deploy requires approval.`)})]})]}),(0,Y.jsx)(`div`,{className:`release-module-grid`,children:rr.map(e=>{let n=e.icon,r=t(e.zhItems.join(` `),e.enItems.join(` `)).split(` diff --git a/frontend/web/dist/assets/index-TnyRuCvG.js b/frontend/web/dist/assets/index-DgpjrkHx.js similarity index 99% rename from frontend/web/dist/assets/index-TnyRuCvG.js rename to frontend/web/dist/assets/index-DgpjrkHx.js index fdd23a3c0..6456b8322 100644 --- a/frontend/web/dist/assets/index-TnyRuCvG.js +++ b/frontend/web/dist/assets/index-DgpjrkHx.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/motion-sqs9Ax-g.js","assets/rolldown-runtime-hePW80VL.js","assets/ResearchWorkbenchPanel-BemKoueL.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/square-xdbdHi0S.js","assets/ResearchWorkbenchPanel-JfmqMXVB.css","assets/MapPanel-aVcW4FvE.js","assets/MapPanel-COJlNZLH.css"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/motion-sqs9Ax-g.js","assets/rolldown-runtime-hePW80VL.js","assets/ResearchWorkbenchPanel-CWXTxKbh.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/square-BJgTpitL.js","assets/ResearchWorkbenchPanel-JfmqMXVB.css","assets/MapPanel-psIb5IiP.js","assets/MapPanel-COJlNZLH.css"])))=>i.map(i=>d[i]); import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,C as r,D as i,E as a,O as o,S as s,T as c,_ as l,a as u,b as d,c as f,d as p,f as m,g as h,h as g,i as _,k as v,l as y,m as b,n as x,o as S,p as C,r as w,s as T,t as ee,u as E,v as te,w as ne,x as re,y as ie}from"./icons-2gFhc0pq.js";import{_ as D,a as ae,b as oe,c as O,d as k,f as se,h as A,i as ce,l as le,m as j,n as M,o as ue,p as de,r as fe,s as pe,t as N,u as P,v as me,y as he}from"./query-CGMsBv4s.js";import{i as ge,n as _e,r as ve,t as ye}from"./markdown-BtnlLdzu.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var be=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,D(x);else{var t=n(l);t!==null&&ae(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&ae(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,ee=-1;function E(){return!(e.unstable_now()-eee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,ae(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,D(x))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),xe=t(((e,t)=>{t.exports=be()})),Se=t((e=>{var t=n(),r=xe();function i(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n`u`||window.document===void 0||window.document.createElement===void 0),u=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},p={};function m(e){return u.call(p,e)?!0:u.call(f,e)?!1:d.test(e)?p[e]=!0:(f[e]=!0,!1)}function h(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function g(e,t,n,r){if(t==null||h(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function _(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var v={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){v[e]=new _(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];v[t]=new _(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){v[e]=new _(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){v[e]=new _(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){v[e]=new _(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){v[e]=new _(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){v[e]=new _(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){v[e]=new _(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){v[e]=new _(e,5,!1,e.toLowerCase(),null,!1,!1)});var y=/[\-:]([a-z])/g;function b(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(y,b);v[t]=new _(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(y,b);v[t]=new _(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(y,b);v[t]=new _(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!1,!1)}),v.xlinkHref=new _(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!0,!0)});function x(e,t,n,r){var i=v.hasOwnProperty(t)?v[t]:null;(i===null?r||!(2`)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{j=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?le(e):``}function ue(e){switch(e.tag){case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return le(`Suspense`);case 19:return le(`SuspenseList`);case 0:case 2:case 15:return e=M(e.type,!1),e;case 11:return e=M(e.type.render,!1),e;case 1:return e=M(e.type,!0),e;default:return``}}function de(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case T:return`Fragment`;case w:return`Portal`;case E:return`Profiler`;case ee:return`StrictMode`;case ie:return`Suspense`;case D:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case ne:return(e.displayName||`Context`)+`.Consumer`;case te:return(e._context.displayName||`Context`)+`.Provider`;case re:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?de(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return de(e(t))}catch{}}return null}function fe(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return de(t);case 8:return t===ee?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function pe(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function N(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function P(e){var t=N(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function me(e){e._valueTracker||=P(e)}function he(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=N(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function ge(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function _e(e,t){var n=t.checked;return A({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ve(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=pe(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ye(e,t){t=t.checked,t!=null&&x(e,`checked`,t,!1)}function be(e,t){ye(e,t);var n=pe(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?Ce(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&Ce(e,t.type,pe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Se(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function Ce(e,t,n){(t!==`number`||ge(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var we=Array.isArray;function Te(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ne(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Fe=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Pe).forEach(function(e){Fe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Pe[t]=Pe[e]})});function Ie(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Pe.hasOwnProperty(e)&&Pe[e]?(``+t).trim():t+`px`}function Le(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ie(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Re=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ze(e,t){if(t){if(Re[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(i(62))}}function Be(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ve=null;function He(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ue=null,We=null,Ge=null;function Ke(e){if(e=ji(e)){if(typeof Ue!=`function`)throw Error(i(280));var t=e.stateNode;t&&(t=Ni(t),Ue(e.stateNode,e.type,t))}}function qe(e){We?Ge?Ge.push(e):Ge=[e]:We=e}function Je(){if(We){var e=We,t=Ge;if(Ge=We=null,Ke(e),t)for(e=0;e>>=0,e===0?32:31-(xt(e)/St|0)|0}var wt=64,Tt=4194304;function Et(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Dt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Et(a))):r=Et(s)}else o=n&~i,o===0?a!==0&&(r=Et(a)):r=Et(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Nt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function Pt(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Jn),Zn=` `,J=!1;function Qn(e,t){switch(e){case`keyup`:return Kn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Y(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var $n=!1;function er(e,t){switch(e){case`compositionend`:return Y(t);case`keypress`:return t.which===32?(J=!0,Zn):null;case`textInput`:return e=t.data,e===Zn&&J?null:e;default:return null}}function tr(e,t){if($n)return e===`compositionend`||!qn&&Qn(e,t)?(e=_n(),gn=hn=mn=null,$n=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Cr(n)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Er(){for(var e=window,t=ge();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=ge(e.document)}return t}function Dr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Or(e){var t=Er(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Tr(n.ownerDocument.documentElement,n)){if(r!==null&&Dr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=wr(n,a);var o=wr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==ge(r)||(r=Ar,`selectionStart`in r&&Dr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Mr&&Sr(Mr,r)||(Mr=r,r=ii(jr,`onSelect`),0Fi||(e.current=Pi[Fi],Pi[Fi]=null,Fi--)}function Ri(e,t){Fi++,Pi[Fi]=e.current,e.current=t}var zi={},Bi=Ii(zi),Vi=Ii(!1),Hi=zi;function Ui(e,t){var n=e.type.contextTypes;if(!n)return zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Wi(e){return e=e.childContextTypes,e!=null}function Gi(){Li(Vi),Li(Bi)}function Ki(e,t,n){if(Bi.current!==zi)throw Error(i(168));Ri(Bi,t),Ri(Vi,n)}function qi(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!=`function`)return n;for(var a in r=r.getChildContext(),r)if(!(a in t))throw Error(i(108,fe(e)||`Unknown`,a));return A({},n,r)}function Ji(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zi,Hi=Bi.current,Ri(Bi,e),Ri(Vi,Vi.current),!0}function Yi(e,t,n){var r=e.stateNode;if(!r)throw Error(i(169));n?(e=qi(e,t,Hi),r.__reactInternalMemoizedMergedChildContext=e,Li(Vi),Li(Bi),Ri(Bi,e)):Li(Vi),Ri(Vi,n)}var Xi=null,Zi=!1,Qi=!1;function $i(e){Xi===null?Xi=[e]:Xi.push(e)}function ea(e){Zi=!0,$i(e)}function ta(){if(!Qi&&Xi!==null){Qi=!0;var e=0,t=K;try{var n=Xi;for(K=1;e>=o,i-=o,la=1<<32-bt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),_a&&da(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),_a&&da(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return _a&&da(a,g),u}for(h=r(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),_a&&da(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===T&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case C:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===T){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===oe&&ja(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=ka(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===T?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=ka(e,r,i),o.return=e,e=o)}return s(e);case w:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case oe:return l=i._init,_(e,r,l(i._payload),o)}if(we(i))return h(e,r,i,o);if(se(i))return g(e,r,i,o);Aa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Na=Ma(!0),Pa=Ma(!1),Fa=Ii(null),Ia=null,La=null,Ra=null;function za(){Ra=La=Ia=null}function Ba(e){var t=Fa.current;Li(Fa),e._currentValue=t}function Va(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ha(e,t){Ia=e,Ra=La=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ms=!0),e.firstContext=null)}function Ua(e){var t=e._currentValue;if(Ra!==e){if(e={context:e,memoizedValue:t,next:null},La===null){if(Ia===null)throw Error(i(308));La=e,Ia.dependencies={lanes:0,firstContext:e}}else La=La.next=e}return t}var Wa=null;function Ga(e){Wa===null?Wa=[e]:Wa.push(e)}function Ka(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ga(t)):(n.next=i.next,i.next=n),t.interleaved=n,qa(e,r)}function qa(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ja=!1;function Ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Za(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,qa(e,n)}return i=r.interleaved,i===null?(t.next=t,Ga(r)):(t.next=i.next,i.next=t),r.interleaved=t,qa(e,n)}function $a(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function to(e,t,n,r){var i=e.updateQueue;Ja=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=A({},d,f);break a;case 2:Ja=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Jc|=o,e.lanes=o,e.memoizedState=d}}function no(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=vo.transition;vo.transition={};try{e(!1),t()}finally{K=n,vo.transition=r}}function as(){return Mo().memoizedState}function os(e,t,n){var r=pl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cs(e))ls(t,n);else if(n=Ka(e,t,n,r),n!==null){var i=fl();ml(n,e,r,i),us(n,t,r)}}function ss(e,t,n){var r=pl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cs(e))ls(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,xr(s,o)){var c=t.interleaved;c===null?(i.next=i,Ga(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ka(e,t,i,r),n!==null&&(i=fl(),ml(n,e,r,i),us(n,t,r))}}function cs(e){var t=e.alternate;return e===bo||t!==null&&t===bo}function ls(e,t){wo=Co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function us(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}var ds={readContext:Ua,useCallback:Do,useContext:Do,useEffect:Do,useImperativeHandle:Do,useInsertionEffect:Do,useLayoutEffect:Do,useMemo:Do,useReducer:Do,useRef:Do,useState:Do,useDebugValue:Do,useDeferredValue:Do,useTransition:Do,useMutableSource:Do,useSyncExternalStore:Do,useId:Do,unstable_isNewReconciler:!1},fs={readContext:Ua,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:Ua,useEffect:Jo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Ko(4194308,4,Qo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ko(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ko(4,2,e,t)},useMemo:function(e,t){var n=jo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jo();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=os.bind(null,bo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:Uo,useDebugValue:es,useDeferredValue:function(e){return jo().memoizedState=e},useTransition:function(){var e=Uo(!1),t=e[0];return e=is.bind(null,e[1]),jo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=bo,a=jo();if(_a){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Vc===null)throw Error(i(349));yo&30||Ro(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Jo(Bo.bind(null,r,o,e),[e]),r.flags|=2048,Wo(9,zo.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=jo(),t=Vc.identifierPrefix;if(_a){var n=ua,r=la;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=To++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof r.is==`string`?e=c.createElement(n,{is:r.is}):(e=c.createElement(n),n===`select`&&(c=e,r.multiple?c.multiple=!0:r.size&&(c.size=r.size))):e=c.createElementNS(e,n),e[wi]=t,e[Ti]=r,nc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Be(n,r),n){case`dialog`:Zr(`cancel`,e),Zr(`close`,e),a=r;break;case`iframe`:case`object`:case`embed`:Zr(`load`,e),a=r;break;case`video`:case`audio`:for(a=0;ael&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}}else{if(!r){if(e=mo(c),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ac(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!_a)return oc(t),null}else 2*W()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(oc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=W(),t.sibling=null,n=po.current,Ri(po,r?n&1|2:n&1),t);case 22:case 23:return wl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Wc&1073741824&&(oc(t),t.subtreeFlags&6&&(t.flags|=8192)):oc(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function cc(e,t){switch(ma(t),t.tag){case 1:return Wi(t.type)&&Gi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lo(),Li(Vi),Li(Bi),go(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fo(t),null;case 13:if(Li(po),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Li(po),null;case 4:return lo(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var lc=!1,uc=!1,dc=typeof WeakSet==`function`?WeakSet:Set,Q=null;function fc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}}function pc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var mc=!1;function hc(e,t){if(fi=q,e=Er(),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(pi={focusedElem:e,selectionRange:n},q=!1,Q=t;Q!==null;)if(t=Q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:hs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return h=mc,mc=!1,h}function gc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&pc(t,n,a)}i=i.next}while(i!==r)}}function _c(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function yc(e){var t=e.alternate;t!==null&&(e.alternate=null,yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Ti],delete t[Di],delete t[Oi],delete t[ki])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bc(e){return e.tag===5||e.tag===3||e.tag===4}function xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||bc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=di));else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}function Cc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Cc(e,t,n),e=e.sibling;e!==null;)Cc(e,t,n),e=e.sibling}var wc=null,Tc=!1;function Ec(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount==`function`)try{vt.onCommitFiberUnmount(G,n)}catch{}switch(n.tag){case 5:uc||fc(n,t);case 6:var r=wc,i=Tc;wc=null,Ec(e,t,n),wc=r,Tc=i,wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wc.removeChild(n.stateNode));break;case 18:wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),on(e)):bi(wc,n.stateNode));break;case 4:r=wc,i=Tc,wc=n.stateNode.containerInfo,Tc=!0,Ec(e,t,n),wc=r,Tc=i;break;case 0:case 11:case 14:case 15:if(!uc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&pc(n,t,o),i=i.next}while(i!==r)}Ec(e,t,n);break;case 1:if(!uc&&(fc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Ec(e,t,n);break;case 21:Ec(e,t,n);break;case 22:n.mode&1?(uc=(r=uc)||n.memoizedState!==null,Ec(e,t,n),uc=r):Ec(e,t,n);break;default:Ec(e,t,n)}}function Oc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function kc(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=s),r&=~o}if(r=a,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Lc(r/1960))-r,10e?16:e,ol===null)var r=!1;else{if(e=ol,ol=null,sl=0,$&6)throw Error(i(331));var a=$;for($|=4,Q=e.current;Q!==null;){var o=Q,s=o.child;if(Q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lW()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Tt,Tt<<=1,!(Tt&130023424)&&(Tt=4194304)):t=1);var n=fl();e=qa(e,t),e!==null&&(Nt(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(i(314))}r!==null&&r.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Vi.current)Ms=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ms=!1,tc(e,t,n);Ms=!!(e.flags&131072)}}else Ms=!1,_a&&t.flags&1048576&&fa(t,aa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;$s(e,t),e=t.pendingProps;var a=Ui(t,Bi.current);Ha(t,n),a=ko(null,t,r,e,a,n);var o=Ao();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wi(r)?(o=!0,Ji(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ya(t),a.updater=_s,t.stateNode=a,a._reactInternals=t,xs(t,r,e,n),t=Vs(null,t,r,!0,o,n)):(t.tag=0,_a&&o&&pa(t),Ns(null,t,a,n),t=t.child),t;case 16:r=t.elementType;a:{switch($s(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Jl(r),e=hs(r,e),a){case 0:t=zs(null,t,r,e,n);break a;case 1:t=Bs(null,t,r,e,n);break a;case 11:t=Ps(null,t,r,e,n);break a;case 14:t=Fs(null,t,r,hs(r.type,e),n);break a}throw Error(i(306,r,``))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),zs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Bs(e,t,r,a,n);case 3:a:{if(Hs(t),e===null)throw Error(i(387));r=t.pendingProps,o=t.memoizedState,a=o.element,Xa(e,t),to(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ss(Error(i(423)),t),t=Us(e,t,r,n,a);break a}if(r!==a){a=Ss(Error(i(424)),t),t=Us(e,t,r,n,a);break a}for(ga=xi(t.stateNode.containerInfo.firstChild),ha=t,_a=!0,va=null,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ea(),r===a){t=ec(e,t,n);break a}Ns(e,t,r,n)}t=t.child}return t;case 5:return uo(t),e===null&&Sa(t),r=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,mi(r,a)?s=null:o!==null&&mi(r,o)&&(t.flags|=32),Rs(e,t),Ns(e,t,s,n),t.child;case 6:return e===null&&Sa(t),null;case 13:return Ks(e,t,n);case 4:return co(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):Ns(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Ps(e,t,r,a,n);case 7:return Ns(e,t,t.pendingProps,n),t.child;case 8:return Ns(e,t,t.pendingProps.children,n),t.child;case 12:return Ns(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(r=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ri(Fa,r._currentValue),r._currentValue=s,o!==null){if(xr(o.value,s)){if(o.children===a.children&&!Vi.current){t=ec(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Za(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Va(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(i(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Va(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Ns(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Ha(t,n),a=Ua(a),r=r(a),t.flags|=1,Ns(e,t,r,n),t.child;case 14:return r=t.type,a=hs(r,t.pendingProps),a=hs(r.type,a),Fs(e,t,r,a,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),$s(e,t),t.tag=1,Wi(r)?(e=!0,Ji(t)):e=!1,Ha(t,n),ys(t,r,a),xs(t,r,a,n),Vs(null,t,r,!0,e,n);case 19:return Qs(e,t,n);case 22:return Ls(e,t,n)}throw Error(i(156,t.tag))};function Wl(e,t){return lt(e,t)}function Gl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===re)return 11;if(e===ae)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,r,a,o){var s=2;if(r=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case T:return Zl(n.children,a,o,t);case ee:s=8,a|=8;break;case E:return e=Kl(12,n,t,a|2),e.elementType=E,e.lanes=o,e;case ie:return e=Kl(13,n,t,a),e.elementType=ie,e.lanes=o,e;case D:return e=Kl(19,n,t,a),e.elementType=D,e.lanes=o,e;case O:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case te:s=10;break a;case ne:s=9;break a;case re:s=11;break a;case ae:s=14;break a;case oe:s=16,r=null;break a}throw Error(i(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=O,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mt(0),this.expirationTimes=Mt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ya(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Se()})),we=t((e=>{var t=Ce();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),Te=class extends oe{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new ae({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ee(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ee(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ee(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Ee(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){O.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>se(t,e))}findAll(e={}){return this.getAll().filter(t=>se(e,t))}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return O.batch(()=>Promise.all(e.map(e=>e.continue().catch(j))))}};function Ee(e){return e.options.scope?.id}var De=class extends oe{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??k(r,t),a=this.get(i);return a||(a=new ue({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){O.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>de(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>de(e,t)):t}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){O.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Oe=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new De,this.#t=e.mutationCache||new Te,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=pe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(D(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=le(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return O.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;O.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return O.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=O.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(j).catch(j)}invalidateQueries(e,t={}){return O.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=O.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(j)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(j)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(D(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(j).catch(j)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(j).catch(j)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return pe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{A(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{A(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=k(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===me&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},F=e(n(),1),ke=e(we(),1),Ae=class extends Error{status;method;path;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.status=t,this.method=n,this.path=r}};function je(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;try{let t=JSON.parse(e);for(let e of[`detail`,`error`,`message`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim();if(Array.isArray(n)){let e=n.map(e=>e&&typeof e==`object`?String(e.msg??``):``).filter(Boolean);if(e.length)return e.join(`; `)}}}catch{}return t.startsWith(`typeof e==`string`):[],o=ze(r?.major),s=ze(r?.minor);if(!n||!r||!i)return{compatible:!1,reason:`malformed /api/meta response`};if(typeof i.source_root!=`string`||ze(i.pid)===null||typeof i.package_version!=`string`||typeof i.release_id!=`string`)return{compatible:!1,reason:`malformed /api/meta runtime identity`};if(n.service!==`argus-skill-webapi`)return{compatible:!1,reason:`unexpected service ${String(n.service||`unknown`)}`};let c=e;if(r.name!==Fe.name||o!==Fe.major)return{compatible:!1,reason:`protocol ${String(r.name||`unknown`)}/${String(o)} is incompatible with client ${Fe.name}/${Fe.major}`,meta:c};if(s===null||s!a.includes(e));if(l.length>0)return{compatible:!1,reason:`missing capabilities: ${l.join(`, `)}`,meta:c};if(i.source_root_matches_config===!1)return{compatible:!1,reason:`backend is running from a different installation than configured`,meta:c};if(i.release_id!==t.releaseId)return{compatible:!1,reason:`backend and client installations are out of sync; restart or reinstall Argus`,meta:c};if(t.sourceDigest){if(typeof i.runtime_source_digest!=`string`||!i.runtime_source_digest)return{compatible:!1,reason:`backend cannot verify this local installation; restart it from the current checkout`,meta:c};if(i.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:`backend is running code from a different local installation; restart it`,meta:c}}return{compatible:!0,reason:``,warning:i.release_matches_source===!1?Ie:void 0,meta:c}}function Ve(e,t){let n=Be(e);if(!n.compatible||!n.meta)throw Error(`incompatible Argus API: ${n.reason}`);return n.warning&&t?.(n.warning),n.meta}function He(e){let t=Re(e),n=Re(t?.daemon);if(!t||t.schema_version!==7)throw Error(`incompatible snapshot schema: expected 7, got ${String(t?.schema_version??`missing`)}`);if(!n)throw Error(`invalid snapshot: daemon section is missing`);let r=[`global_daily_cap_usd`,`read_status`,`read_error`,`protocol_compatible`,`protocol_error`].filter(e=>!Object.hasOwn(n,e));if(r.length>0)throw Error(`invalid snapshot: daemon fields missing: ${r.join(`, `)}`);let i=[`spend_usd`,`spend_status`,`usage_summary`,`request_usage`,`cost_control`,`daemon_commands`,`observability`,`mission_view`,`partial`,`diagnostics`].filter(e=>!Object.hasOwn(t,e));if(i.length>0)throw Error(`invalid snapshot: fields missing: ${i.join(`, `)}`);if(!Array.isArray(t.diagnostics))throw Error(`invalid snapshot: diagnostics must be an array`);return e}var Ue=`argus_web_token`,We=null;function Ge(){let e;try{e=new URLSearchParams(window.location.search)}catch{return}let t=e.get(`token`);if(t){We=t;try{localStorage.setItem(Ue,t)}catch{}try{e.delete(`token`);let t=e.toString();window.history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)}catch{}}}var Ke=()=>{if(We)return We;try{return new URLSearchParams(window.location.search).get(`token`)||localStorage.getItem(Ue)}catch{return null}};function qe(){let e=Ke();return e?{Authorization:`Bearer ${e}`}:{}}function Je(){return Ke()??``}var Ye=8e3,Xe=12e3,I=class extends Error{constructor(){super(`This browser is not paired with Argus. Reopen it from Argus Desktop or use a fresh pairing link.`),this.name=`PairingRequiredError`}},Ze=class extends Error{method;path;constructor(e,t,n=`could not reach the local Argus service`){super(`${e.toUpperCase()} ${t} ${n}. Make sure Argus Desktop is running, then retry.`),this.name=`LocalArgusUnavailableError`,this.method=e.toUpperCase(),this.path=t}};function Qe(e){return e instanceof I||!!(e&&typeof e==`object`&&Number(e.status)===401)}function $e(e){return Qe(e)||e instanceof Ze}async function L(e,t){try{return await fetch(e,t)}catch(n){throw t.signal?.aborted?n:new Ze(String(t.method??`GET`),e)}}async function et(e,t,n,r){let i=new AbortController,a=t.signal??void 0,o=!1,s=()=>{};if(a){let e=()=>i.abort(a.reason);a.aborted?e():(a.addEventListener(`abort`,e,{once:!0}),s=()=>a.removeEventListener(`abort`,e))}let c,l=(async()=>await r(await L(e,{...t,signal:i.signal})))(),u=new Promise((e,t)=>{c=setTimeout(()=>{o=!0;let e=Error(`request timed out after ${n}ms`);i.abort(e),t(e)},n)});try{return await Promise.race([l,u])}catch(r){if(o){let r=Math.round(n/1e3);throw new Ze(String(t.method??`GET`),e,`timed out after ${r}s because the local Argus service did not respond`)}throw r}finally{c&&clearTimeout(c),s()}}async function R(e,t,n){return et(e,{headers:qe(),signal:t},n??Xe,async t=>(await Ne(t,`GET`,e),await t.json()))}async function z(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...qe()},body:t===void 0?void 0:JSON.stringify(t),signal:n});return await Ne(r,`POST`,e),await r.json()}async function tt(e,t,n){let r=await fetch(e,{method:`POST`,headers:qe(),body:t,signal:n});return await Ne(r,`POST`,e),await r.json()}function nt(e){let t=e&&typeof e==`object`?e:{},n=String(t.command_status??``);if(Number(t.rc??0)!==0||n===`failed`||n===`rejected`)throw Error(String(t.error||`daemon command ${n||`failed`}`));return e}async function rt(e,t,n){let r=await fetch(t,{method:e,headers:{"Content-Type":`application/json`,...qe()},body:n===void 0?void 0:JSON.stringify(n)});return await Ne(r,e,t),await r.json()}async function it(e,t){let n=await fetch(e,{headers:qe(),signal:t});return await Ne(n,`GET`,e),n.blob()}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,at=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,V;function H(e){return!!(e&&typeof e==`object`&&`aborted`in e&&typeof e.aborted==`boolean`)}function ot(e,t,n){let r={text:e};return t?.length&&(r.attachments=t),n&&n!==`auto`&&(r.route_override=n),r}function st(){if(!V){let e=(async()=>{let e=`/api/meta`,t=await et(e,{headers:qe()},Ye,async t=>{if(t.status===404)throw Error(`incompatible Argus API: service does not expose /api/meta`);return await Ne(t,`GET`,e),Ve(await t.json(),e=>console.warn(`Argus API compatibility warning: ${e}`))});if(t.authentication?.required&&!t.authentication.authenticated)throw new I;return t})();V=e,e.catch(t=>{V===e&&!(t instanceof I)&&(V=void 0)})}return V}function ct(e){let t=[],n;for(;(n=e.indexOf(` +`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Cs(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ws(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Ts=typeof WeakMap==`function`?WeakMap:Map;function Es(e,t,n){n=Za(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){nl||(nl=!0,rl=r),ws(e,t)},n}function Ds(e,t,n){n=Za(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){ws(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){ws(e,t),typeof r!=`function`&&(il===null?il=new Set([this]):il.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function Os(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ts;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=zl.bind(null,e,t,n),t.then(e,e))}function ks(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null||t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function As(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Za(-1,1),t.tag=2,Qa(n,t,1))),n.lanes|=1),e)}var js=S.ReactCurrentOwner,Ms=!1;function Ns(e,t,n,r){t.child=e===null?Pa(t,null,n,r):Na(t,e.child,n,r)}function Ps(e,t,n,r,i){n=n.render;var a=t.ref;return Ha(t,i),r=ko(e,t,n,r,a,i),n=Ao(),e!==null&&!Ms?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ec(e,t,i)):(_a&&n&&pa(t),t.flags|=1,Ns(e,t,r,i),t.child)}function Fs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ql(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Is(e,t,a,r,i)):(e=Xl(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Sr:n,n(o,r)&&e.ref===t.ref)return ec(e,t,i)}return t.flags|=1,e=Yl(a,r),e.ref=t.ref,e.return=t,t.child=e}function Is(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Sr(a,r)&&e.ref===t.ref){if(Ms=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Ms=!0);else return t.lanes=e.lanes,ec(e,t,i)}}return zs(e,t,n,r,i)}function Ls(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`){if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ri(Gc,Wc),Wc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ri(Gc,Wc),Wc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,Ri(Gc,Wc),Wc|=r}}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),Ri(Gc,Wc),Wc|=r;return Ns(e,t,i,n),t.child}function Rs(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function zs(e,t,n,r,i){var a=Wi(n)?Hi:Bi.current;return a=Ui(t,a),Ha(t,i),n=ko(e,t,n,r,a,i),r=Ao(),e!==null&&!Ms?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ec(e,t,i)):(_a&&r&&pa(t),t.flags|=1,Ns(e,t,n,i),t.child)}function Bs(e,t,n,r,i){if(Wi(n)){var a=!0;Ji(t)}else a=!1;if(Ha(t,i),t.stateNode===null)$s(e,t),ys(t,n,r),xs(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=Ua(l):(l=Wi(n)?Hi:Bi.current,l=Ui(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&bs(t,o,r,l),Ja=!1;var f=t.memoizedState;o.state=f,to(t,r,o,i),c=t.memoizedState,s!==r||f!==c||Vi.current||Ja?(typeof u==`function`&&(gs(t,n,u,r),c=t.memoizedState),(s=Ja||vs(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Xa(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:hs(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=Ua(c):(c=Wi(n)?Hi:Bi.current,c=Ui(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&bs(t,o,r,c),Ja=!1,f=t.memoizedState,o.state=f,to(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||Vi.current||Ja?(typeof p==`function`&&(gs(t,n,p,r),m=t.memoizedState),(l=Ja||vs(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Vs(e,t,n,r,a,i)}function Vs(e,t,n,r,i,a){Rs(e,t);var o=!!(t.flags&128);if(!r&&!o)return i&&Yi(t,n,!1),ec(e,t,a);r=t.stateNode,js.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Na(t,e.child,null,a),t.child=Na(t,null,s,a)):Ns(e,t,s,a),t.memoizedState=r.state,i&&Yi(t,n,!0),t.child}function Hs(e){var t=e.stateNode;t.pendingContext?Ki(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Ki(e,t.context,!1),co(e,t.containerInfo)}function Us(e,t,n,r,i){return Ea(),Da(i),t.flags|=256,Ns(e,t,n,r),t.child}var Ws={dehydrated:null,treeContext:null,retryLane:0};function Gs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Ks(e,t,n){var r=t.pendingProps,i=po.current,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(i&2)),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Ri(po,i&1),e===null)return Sa(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.lanes=t.mode&1?e.data===`$!`?8:1073741824:1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=Ql(o,r,0,null),e=Zl(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Gs(n),t.memoizedState=Ws,e):qs(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return Ys(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Yl(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=Zl(a,o,n,null),a.flags|=2):a=Yl(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?Gs(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Ws,r}return a=e.child,e=a.sibling,r=Yl(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function qs(e,t){return t=Ql({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function Js(e,t,n,r){return r!==null&&Da(r),Na(t,e.child,null,n),e=qs(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ys(e,t,n,r,a,o,s){if(n)return t.flags&256?(t.flags&=-257,r=Cs(Error(i(422))),Js(e,t,s,r)):t.memoizedState===null?(o=r.fallback,a=t.mode,r=Ql({mode:`visible`,children:r.children},a,0,null),o=Zl(o,a,s,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Na(t,e.child,null,s),t.child.memoizedState=Gs(s),t.memoizedState=Ws,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return Js(e,t,s,null);if(a.data===`$!`){if(r=a.nextSibling&&a.nextSibling.dataset,r)var c=r.dgst;return r=c,o=Error(i(419)),r=Cs(o,r,void 0),Js(e,t,s,r)}if(c=(s&e.childLanes)!==0,Ms||c){if(r=Vc,r!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(r.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,qa(e,a),ml(r,e,a,-1))}return Ol(),r=Cs(Error(i(421))),Js(e,t,s,r)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Vl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,ga=xi(a.nextSibling),ha=t,_a=!0,va=null,e!==null&&(oa[sa++]=la,oa[sa++]=ua,oa[sa++]=ca,la=e.id,ua=e.overflow,ca=t),t=qs(t,r.children),t.flags|=4096,t)}function Xs(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Va(e.return,t,n)}function Zs(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function Qs(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Ns(e,t,r.children,n),r=po.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xs(e,n,t);else if(e.tag===19)Xs(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ri(po,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&mo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Zs(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&mo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Zs(t,!0,n,null,a);break;case`together`:Zs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function $s(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ec(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Jc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Yl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function tc(e,t,n){switch(t.tag){case 3:Hs(t),Ea();break;case 5:uo(t);break;case 1:Wi(t.type)&&Ji(t);break;case 4:co(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ri(Fa,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ri(po,po.current&1),e=ec(e,t,n),e===null?null:e.sibling):Ks(e,t,n):(Ri(po,po.current&1),t.flags|=128,null);Ri(po,po.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Qs(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ri(po,po.current),r)break;return null;case 22:case 23:return t.lanes=0,Ls(e,t,n)}return ec(e,t,n)}var nc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},rc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,so(io.current);var a=null;switch(n){case`input`:i=_e(e,i),r=_e(e,r),a=[];break;case`select`:i=A({},i,{value:void 0}),r=A({},r,{value:void 0}),a=[];break;case`textarea`:i=Ee(e,i),r=Ee(e,r),a=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=di)}ze(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null){if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(o.hasOwnProperty(u)?a||=[]:(a||=[]).push(u,null))}for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null)){if(u===`style`){if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(a||=[],a.push(u,n)),n=l}else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(a||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(a||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(o.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&Zr(`scroll`,e),a||c===l||(a=[])):(a||=[]).push(u,l))}}n&&(a||=[]).push(`style`,n);var u=a;(t.updateQueue=u)&&(t.flags|=4)}},ic=function(e,t,n,r){n!==r&&(t.flags|=4)};function ac(e,t){if(!_a)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function oc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function sc(e,t,n){var r=t.pendingProps;switch(ma(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return oc(t),null;case 1:return Wi(t.type)&&Gi(),oc(t),null;case 3:return r=t.stateNode,lo(),Li(Vi),Li(Bi),go(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(wa(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,va!==null&&(vl(va),va=null))),oc(t),null;case 5:fo(t);var a=so(oo.current);if(n=t.type,e!==null&&t.stateNode!=null)rc(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(i(166));return oc(t),null}if(e=so(io.current),wa(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[wi]=t,r[Ti]=s,e=!!(t.mode&1),n){case`dialog`:Zr(`cancel`,r),Zr(`close`,r);break;case`iframe`:case`object`:case`embed`:Zr(`load`,r);break;case`video`:case`audio`:for(a=0;a<\/script>`,e=e.removeChild(e.firstChild)):typeof r.is==`string`?e=c.createElement(n,{is:r.is}):(e=c.createElement(n),n===`select`&&(c=e,r.multiple?c.multiple=!0:r.size&&(c.size=r.size))):e=c.createElementNS(e,n),e[wi]=t,e[Ti]=r,nc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Be(n,r),n){case`dialog`:Zr(`cancel`,e),Zr(`close`,e),a=r;break;case`iframe`:case`object`:case`embed`:Zr(`load`,e),a=r;break;case`video`:case`audio`:for(a=0;ael&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}}else{if(!r){if(e=mo(c),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ac(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!_a)return oc(t),null}else 2*W()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(oc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=W(),t.sibling=null,n=po.current,Ri(po,r?n&1|2:n&1),t);case 22:case 23:return wl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Wc&1073741824&&(oc(t),t.subtreeFlags&6&&(t.flags|=8192)):oc(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function cc(e,t){switch(ma(t),t.tag){case 1:return Wi(t.type)&&Gi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lo(),Li(Vi),Li(Bi),go(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fo(t),null;case 13:if(Li(po),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Li(po),null;case 4:return lo(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var lc=!1,uc=!1,dc=typeof WeakSet==`function`?WeakSet:Set,Q=null;function fc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}}function pc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var mc=!1;function hc(e,t){if(fi=q,e=Er(),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(pi={focusedElem:e,selectionRange:n},q=!1,Q=t;Q!==null;)if(t=Q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:hs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return h=mc,mc=!1,h}function gc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&pc(t,n,a)}i=i.next}while(i!==r)}}function _c(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function yc(e){var t=e.alternate;t!==null&&(e.alternate=null,yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Ti],delete t[Di],delete t[Oi],delete t[ki])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bc(e){return e.tag===5||e.tag===3||e.tag===4}function xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||bc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=di));else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}function Cc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Cc(e,t,n),e=e.sibling;e!==null;)Cc(e,t,n),e=e.sibling}var wc=null,Tc=!1;function Ec(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount==`function`)try{vt.onCommitFiberUnmount(G,n)}catch{}switch(n.tag){case 5:uc||fc(n,t);case 6:var r=wc,i=Tc;wc=null,Ec(e,t,n),wc=r,Tc=i,wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wc.removeChild(n.stateNode));break;case 18:wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),on(e)):bi(wc,n.stateNode));break;case 4:r=wc,i=Tc,wc=n.stateNode.containerInfo,Tc=!0,Ec(e,t,n),wc=r,Tc=i;break;case 0:case 11:case 14:case 15:if(!uc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&pc(n,t,o),i=i.next}while(i!==r)}Ec(e,t,n);break;case 1:if(!uc&&(fc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Ec(e,t,n);break;case 21:Ec(e,t,n);break;case 22:n.mode&1?(uc=(r=uc)||n.memoizedState!==null,Ec(e,t,n),uc=r):Ec(e,t,n);break;default:Ec(e,t,n)}}function Oc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function kc(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=s),r&=~o}if(r=a,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Lc(r/1960))-r,10e?16:e,ol===null)var r=!1;else{if(e=ol,ol=null,sl=0,$&6)throw Error(i(331));var a=$;for($|=4,Q=e.current;Q!==null;){var o=Q,s=o.child;if(Q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lW()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Tt,Tt<<=1,!(Tt&130023424)&&(Tt=4194304)):t=1);var n=fl();e=qa(e,t),e!==null&&(Nt(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(i(314))}r!==null&&r.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Vi.current)Ms=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ms=!1,tc(e,t,n);Ms=!!(e.flags&131072)}}else Ms=!1,_a&&t.flags&1048576&&fa(t,aa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;$s(e,t),e=t.pendingProps;var a=Ui(t,Bi.current);Ha(t,n),a=ko(null,t,r,e,a,n);var o=Ao();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wi(r)?(o=!0,Ji(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ya(t),a.updater=_s,t.stateNode=a,a._reactInternals=t,xs(t,r,e,n),t=Vs(null,t,r,!0,o,n)):(t.tag=0,_a&&o&&pa(t),Ns(null,t,a,n),t=t.child),t;case 16:r=t.elementType;a:{switch($s(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Jl(r),e=hs(r,e),a){case 0:t=zs(null,t,r,e,n);break a;case 1:t=Bs(null,t,r,e,n);break a;case 11:t=Ps(null,t,r,e,n);break a;case 14:t=Fs(null,t,r,hs(r.type,e),n);break a}throw Error(i(306,r,``))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),zs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Bs(e,t,r,a,n);case 3:a:{if(Hs(t),e===null)throw Error(i(387));r=t.pendingProps,o=t.memoizedState,a=o.element,Xa(e,t),to(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ss(Error(i(423)),t),t=Us(e,t,r,n,a);break a}if(r!==a){a=Ss(Error(i(424)),t),t=Us(e,t,r,n,a);break a}for(ga=xi(t.stateNode.containerInfo.firstChild),ha=t,_a=!0,va=null,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ea(),r===a){t=ec(e,t,n);break a}Ns(e,t,r,n)}t=t.child}return t;case 5:return uo(t),e===null&&Sa(t),r=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,mi(r,a)?s=null:o!==null&&mi(r,o)&&(t.flags|=32),Rs(e,t),Ns(e,t,s,n),t.child;case 6:return e===null&&Sa(t),null;case 13:return Ks(e,t,n);case 4:return co(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):Ns(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Ps(e,t,r,a,n);case 7:return Ns(e,t,t.pendingProps,n),t.child;case 8:return Ns(e,t,t.pendingProps.children,n),t.child;case 12:return Ns(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(r=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ri(Fa,r._currentValue),r._currentValue=s,o!==null){if(xr(o.value,s)){if(o.children===a.children&&!Vi.current){t=ec(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Za(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Va(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(i(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Va(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Ns(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Ha(t,n),a=Ua(a),r=r(a),t.flags|=1,Ns(e,t,r,n),t.child;case 14:return r=t.type,a=hs(r,t.pendingProps),a=hs(r.type,a),Fs(e,t,r,a,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),$s(e,t),t.tag=1,Wi(r)?(e=!0,Ji(t)):e=!1,Ha(t,n),ys(t,r,a),xs(t,r,a,n),Vs(null,t,r,!0,e,n);case 19:return Qs(e,t,n);case 22:return Ls(e,t,n)}throw Error(i(156,t.tag))};function Wl(e,t){return lt(e,t)}function Gl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===re)return 11;if(e===ae)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,r,a,o){var s=2;if(r=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case T:return Zl(n.children,a,o,t);case ee:s=8,a|=8;break;case E:return e=Kl(12,n,t,a|2),e.elementType=E,e.lanes=o,e;case ie:return e=Kl(13,n,t,a),e.elementType=ie,e.lanes=o,e;case D:return e=Kl(19,n,t,a),e.elementType=D,e.lanes=o,e;case O:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case te:s=10;break a;case ne:s=9;break a;case re:s=11;break a;case ae:s=14;break a;case oe:s=16,r=null;break a}throw Error(i(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=O,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mt(0),this.expirationTimes=Mt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ya(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Se()})),we=t((e=>{var t=Ce();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),Te=class extends oe{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new ae({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ee(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ee(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ee(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Ee(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){O.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>se(t,e))}findAll(e={}){return this.getAll().filter(t=>se(e,t))}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return O.batch(()=>Promise.all(e.map(e=>e.continue().catch(j))))}};function Ee(e){return e.options.scope?.id}var De=class extends oe{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??k(r,t),a=this.get(i);return a||(a=new ue({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){O.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>de(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>de(e,t)):t}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){O.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Oe=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new De,this.#t=e.mutationCache||new Te,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=pe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(D(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=le(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return O.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;O.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return O.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=O.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(j).catch(j)}invalidateQueries(e,t={}){return O.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=O.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(j)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(j)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(D(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(j).catch(j)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(j).catch(j)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return pe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{A(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{A(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=k(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===me&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},F=e(n(),1),ke=e(we(),1),Ae=class extends Error{status;method;path;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.status=t,this.method=n,this.path=r}};function je(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;try{let t=JSON.parse(e);for(let e of[`detail`,`error`,`message`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim();if(Array.isArray(n)){let e=n.map(e=>e&&typeof e==`object`?String(e.msg??``):``).filter(Boolean);if(e.length)return e.join(`; `)}}}catch{}return t.startsWith(`typeof e==`string`):[],o=ze(r?.major),s=ze(r?.minor);if(!n||!r||!i)return{compatible:!1,reason:`malformed /api/meta response`};if(typeof i.source_root!=`string`||ze(i.pid)===null||typeof i.package_version!=`string`||typeof i.release_id!=`string`)return{compatible:!1,reason:`malformed /api/meta runtime identity`};if(n.service!==`argus-skill-webapi`)return{compatible:!1,reason:`unexpected service ${String(n.service||`unknown`)}`};let c=e;if(r.name!==Fe.name||o!==Fe.major)return{compatible:!1,reason:`protocol ${String(r.name||`unknown`)}/${String(o)} is incompatible with client ${Fe.name}/${Fe.major}`,meta:c};if(s===null||s!a.includes(e));if(l.length>0)return{compatible:!1,reason:`missing capabilities: ${l.join(`, `)}`,meta:c};if(i.source_root_matches_config===!1)return{compatible:!1,reason:`backend is running from a different installation than configured`,meta:c};if(i.release_id!==t.releaseId)return{compatible:!1,reason:`backend and client installations are out of sync; restart or reinstall Argus`,meta:c};if(t.sourceDigest){if(typeof i.runtime_source_digest!=`string`||!i.runtime_source_digest)return{compatible:!1,reason:`backend cannot verify this local installation; restart it from the current checkout`,meta:c};if(i.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:`backend is running code from a different local installation; restart it`,meta:c}}return{compatible:!0,reason:``,warning:i.release_matches_source===!1?Ie:void 0,meta:c}}function Ve(e,t){let n=Be(e);if(!n.compatible||!n.meta)throw Error(`incompatible Argus API: ${n.reason}`);return n.warning&&t?.(n.warning),n.meta}function He(e){let t=Re(e),n=Re(t?.daemon);if(!t||t.schema_version!==7)throw Error(`incompatible snapshot schema: expected 7, got ${String(t?.schema_version??`missing`)}`);if(!n)throw Error(`invalid snapshot: daemon section is missing`);let r=[`global_daily_cap_usd`,`read_status`,`read_error`,`protocol_compatible`,`protocol_error`].filter(e=>!Object.hasOwn(n,e));if(r.length>0)throw Error(`invalid snapshot: daemon fields missing: ${r.join(`, `)}`);let i=[`spend_usd`,`spend_status`,`usage_summary`,`request_usage`,`cost_control`,`daemon_commands`,`observability`,`mission_view`,`partial`,`diagnostics`].filter(e=>!Object.hasOwn(t,e));if(i.length>0)throw Error(`invalid snapshot: fields missing: ${i.join(`, `)}`);if(!Array.isArray(t.diagnostics))throw Error(`invalid snapshot: diagnostics must be an array`);return e}var Ue=`argus_web_token`,We=null;function Ge(){let e;try{e=new URLSearchParams(window.location.search)}catch{return}let t=e.get(`token`);if(t){We=t;try{localStorage.setItem(Ue,t)}catch{}try{e.delete(`token`);let t=e.toString();window.history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)}catch{}}}var Ke=()=>{if(We)return We;try{return new URLSearchParams(window.location.search).get(`token`)||localStorage.getItem(Ue)}catch{return null}};function qe(){let e=Ke();return e?{Authorization:`Bearer ${e}`}:{}}function Je(){return Ke()??``}var Ye=8e3,Xe=12e3,I=class extends Error{constructor(){super(`This browser is not paired with Argus. Reopen it from Argus Desktop or use a fresh pairing link.`),this.name=`PairingRequiredError`}},Ze=class extends Error{method;path;constructor(e,t,n=`could not reach the local Argus service`){super(`${e.toUpperCase()} ${t} ${n}. Make sure Argus Desktop is running, then retry.`),this.name=`LocalArgusUnavailableError`,this.method=e.toUpperCase(),this.path=t}};function Qe(e){return e instanceof I||!!(e&&typeof e==`object`&&Number(e.status)===401)}function $e(e){return Qe(e)||e instanceof Ze}async function L(e,t){try{return await fetch(e,t)}catch(n){throw t.signal?.aborted?n:new Ze(String(t.method??`GET`),e)}}async function et(e,t,n,r){let i=new AbortController,a=t.signal??void 0,o=!1,s=()=>{};if(a){let e=()=>i.abort(a.reason);a.aborted?e():(a.addEventListener(`abort`,e,{once:!0}),s=()=>a.removeEventListener(`abort`,e))}let c,l=(async()=>await r(await L(e,{...t,signal:i.signal})))(),u=new Promise((e,t)=>{c=setTimeout(()=>{o=!0;let e=Error(`request timed out after ${n}ms`);i.abort(e),t(e)},n)});try{return await Promise.race([l,u])}catch(r){if(o){let r=Math.round(n/1e3);throw new Ze(String(t.method??`GET`),e,`timed out after ${r}s because the local Argus service did not respond`)}throw r}finally{c&&clearTimeout(c),s()}}async function R(e,t,n){return et(e,{headers:qe(),signal:t},n??Xe,async t=>(await Ne(t,`GET`,e),await t.json()))}async function z(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...qe()},body:t===void 0?void 0:JSON.stringify(t),signal:n});return await Ne(r,`POST`,e),await r.json()}async function tt(e,t,n){let r=await fetch(e,{method:`POST`,headers:qe(),body:t,signal:n});return await Ne(r,`POST`,e),await r.json()}function nt(e){let t=e&&typeof e==`object`?e:{},n=String(t.command_status??``);if(Number(t.rc??0)!==0||n===`failed`||n===`rejected`)throw Error(String(t.error||`daemon command ${n||`failed`}`));return e}async function rt(e,t,n){let r=await fetch(t,{method:e,headers:{"Content-Type":`application/json`,...qe()},body:n===void 0?void 0:JSON.stringify(n)});return await Ne(r,e,t),await r.json()}async function it(e,t){let n=await fetch(e,{headers:qe(),signal:t});return await Ne(n,`GET`,e),n.blob()}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,at=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,V;function H(e){return!!(e&&typeof e==`object`&&`aborted`in e&&typeof e.aborted==`boolean`)}function ot(e,t,n){let r={text:e};return t?.length&&(r.attachments=t),n&&n!==`auto`&&(r.route_override=n),r}function st(){if(!V){let e=(async()=>{let e=`/api/meta`,t=await et(e,{headers:qe()},Ye,async t=>{if(t.status===404)throw Error(`incompatible Argus API: service does not expose /api/meta`);return await Ne(t,`GET`,e),Ve(await t.json(),e=>console.warn(`Argus API compatibility warning: ${e}`))});if(t.authentication?.required&&!t.authentication.authenticated)throw new I;return t})();V=e,e.catch(t=>{V===e&&!(t instanceof I)&&(V=void 0)})}return V}function ct(e){let t=[],n;for(;(n=e.indexOf(` `))>=0;){let r=e.slice(0,n);e=e.slice(n+2);for(let e of r.split(` `)){let n=e.trim();if(n.startsWith(`data:`))try{t.push(JSON.parse(n.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var lt=null,U={liveMap:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r?.mode===`current`&&(i.set(`since`,String(r.since)),i.set(`event_since`,String(r.eventSince)),r.taskId&&i.set(`start_task`,r.taskId)),R(B(e,`/map`)+(i.size?`?${i}`:``),t)},mapInfo:(e,t)=>R(B(e,`/map-info`),t),mapHistory:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r&&i.set(`task_after`,r),R(B(e,`/map-history`)+(i.size?`?${i}`:``),t)},mapCopy:(e,t,n,r,i)=>R(`/api/map-copy/${e}/${encodeURIComponent(t)}?locale=${n}${i?`&session_id=${encodeURIComponent(i)}`:``}`,r),generateMapCopy:(e,t,n,r,i)=>z(`/api/map-copy/${e}/${encodeURIComponent(t)}${i?`?session_id=${encodeURIComponent(i)}`:``}`,n,r),mapDatasets:e=>R(`/api/map-datasets`,e),mapDataset:(e,t)=>R(`/api/map-datasets/${encodeURIComponent(e)}`,t),meta:st,projectIndex:async()=>(await st(),R(`/api/projects`,void 0,Xe)),listProjects:async()=>(await st(),R(`/api/projects`,void 0,Xe).then(e=>e.projects)),projectCosts:async e=>(await st(),R(`/api/projects/costs`,e)),createDaemon:async(e,t=``,n=``,r)=>{let i=`/api/daemons`,a={objective:e,name:t,workdir:n,command_id:at(),expected_revision:r},o=()=>fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...qe()},body:JSON.stringify(a),cache:`no-store`}),s=await o();return s.status===400&&/Invalid HTTP request received/i.test(await s.clone().text())&&(s=await o()),await Ne(s,`POST`,i),nt(await s.json())},updateProject:(e,t)=>rt(`PATCH`,B(e),{name:t}),deleteProject:e=>rt(`DELETE`,B(e)),snapshot:async(e,t,n=!1)=>(await st(),He(await R(B(e,`/snapshot?compact=true&events_limit=1${n?`&prewarm=true`:``}`),t,Xe))),activeSnapshot:async(e,t)=>{let n=lt!==e;n&&(lt=e);try{return await U.snapshot(e,t,n)}catch(t){throw n&<===e&&(lt=null),t}},prefetchSnapshot:(e,t)=>U.snapshot(e,t,!1),status:(e,t)=>R(B(e,`/status`),t),journal:(e,t=20,n)=>R(B(e,`/journal?n=${t}`),n).then(e=>e.journal),doctor:(e,t)=>R(B(e,`/doctor`),t),config:(e,t)=>R(B(e,`/config`),t),identity:(e,t)=>R(B(e,`/identity`),t).then(e=>e.identity),transcript:(e,t=30,n)=>R(B(e,`/transcript?n=${t}`),n).then(e=>e.turns),events:(e,t=80,n)=>R(B(e,`/events?limit=${t}&view=ui`),n).then(e=>e.events),backlogItem:(e,t,n)=>R(B(e,`/backlog/${encodeURIComponent(t)}`),n).then(e=>e.item),artifacts:(e,t)=>R(B(e,`/artifacts`),t).then(e=>e.artifacts),artifact:(e,t,n)=>R(B(e,`/artifact?${new URLSearchParams({path:t})}`),n),artifactPreview:(e,t,n)=>R(B(e,`/artifact/preview?${new URLSearchParams({path:t})}`),n),artifactBundle:(e,t,n)=>it(B(e,`/artifact/bundle?${new URLSearchParams({path:t})}`),n),artifactBlob:(e,t,n=!1,r)=>{let i=new URLSearchParams({path:t});return n&&i.set(`download`,`true`),it(B(e,`/artifact/raw?${i}`),r)},gitDiff:(e,t)=>R(B(e,`/git-diff`),t),metrics:e=>R(`/api/metrics`,e),sourceUpdateStatus:e=>R(`/api/runtime/source-update`,e),checkSourceUpdate:()=>z(`/api/runtime/source-update/check`),applySourceUpdate:()=>z(`/api/runtime/source-update/apply`),resources:e=>R(`/api/system/resources`,e),trash:(e=``,t=100,n=0,r)=>R(`/api/trash?${new URLSearchParams({query:e,limit:String(t),offset:String(n)})}`,r),restoreTrash:e=>z(`/api/trash/${encodeURIComponent(e)}/restore`),addTask:(e,t)=>z(B(e,`/tasks`),{text:t}).then(e=>e.item),abortMission:(e,t)=>z(B(e,`/mission/abort`),{reason:t}),answerPending:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/answer`),{text:n}),resolveDecision:(e,t,n,r)=>z(B(e,`/decisions/${encodeURIComponent(t)}/resolve`),{option_id:n,note:r}),uploadAttachments:async(e,t,n)=>{await st();let r=new FormData;return t.forEach(e=>r.append(`files`,e,e.name)),tt(B(e,`/attachments`),r,n)},message:(e,t,n)=>{let r=H(n)?n:n?.signal,i=H(n)?void 0:n?.attachments,a=H(n)?void 0:n?.routeOverride;return z(B(e,`/message`),ot(t,i,a),r)},messageStream:async(e,t,n,r)=>{let i=H(r)?r:r?.signal,a=H(r)?void 0:r?.attachments,o=H(r)?void 0:r?.routeOverride,s=await fetch(B(e,`/message/stream`),{method:`POST`,headers:{"Content-Type":`application/json`,...qe()},body:JSON.stringify(ot(t,a,o)),signal:i});if(await Ne(s,`POST`,B(e,`/message/stream`)),!s.body)throw Error(`Manager stream returned no response body`);let c=!1,l=e=>{if(!i?.aborted){if(e.type===`phase`){let t=Number(e.quiet_s??0);n.onPhase?.(String(e.label??``),String(e.role??`manager`),{heartbeat:e.heartbeat===!0,quietS:Number.isFinite(t)?t:0,kind:String(e.kind??``),detail:String(e.detail??``)})}else e.type===`delta`?n.onDelta?.(String(e.text??``),String(e.message_id??``),String(e.fragment_mode??`auto`)):e.type===`done`?(c=!0,n.onDone?.(e.result??{})):e.type===`error`&&(c=!0,n.onError?.(Error(String(e.error??`stream error`))))}},u=s.body.getReader(),d=new TextDecoder,f=``;for(;;){let{done:e,value:t}=await u.read();if(e)break;f+=d.decode(t,{stream:!0});let n=ct(f);f=n.rest,n.frames.forEach(l)}if(!i?.aborted&&(ct(f+` @@ -22,9 +22,9 @@ Error generating stack: `+e.message+` `);return(0,X.jsx)(`code`,{...n,className:r?`block min-w-0 whitespace-pre-wrap break-words font-mono text-xs text-ink ${e??``}`:`break-all rounded bg-bg px-1.5 py-0.5 font-mono text-xs text-ink`,children:t})},pre:({children:e})=>(0,X.jsxs)(`pre`,{className:`group/code relative my-2 max-w-full overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-line/50 bg-bg px-3 pb-3 pt-10`,children:[(0,X.jsx)(Si,{text:F.Children.toArray(e).map(Ci).join(``),label:r(`copy.code`),copiedLabel:r(`copy.copied`),className:`absolute right-2 top-2`}),e]}),table:({children:e})=>(0,X.jsx)(`table`,{className:`my-2 w-full table-fixed border-collapse text-left text-xs`,children:e}),th:({children:e})=>(0,X.jsx)(`th`,{className:`break-words border border-line/60 bg-bg px-2 py-1.5 font-semibold text-ink`,children:e}),td:({children:e})=>(0,X.jsx)(`td`,{className:`break-words border border-line/60 px-2 py-1.5 align-top`,children:e}),strong:({children:e})=>(0,X.jsx)(`strong`,{className:`font-semibold text-ink`,children:e}),img:({src:e,alt:t})=>(0,X.jsx)(Di,{src:e,alt:t})},children:e})}function ki({size:e,className:t=`text-ink`}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-mark`,viewBox:`0 0 512 512`,role:`img`,"aria-label":`Argus`,style:{width:e,height:e},className:`argus-brand-mark shrink-0 ${t}`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsxs)(`g`,{className:`argus-mark-eye`,children:[(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]})]})}function Ai({size:e}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-horizontal`,viewBox:`150 40 1160 390`,role:`img`,"aria-label":`Argus`,style:{width:e*2.75,height:e},className:`shrink-0 text-ink`,children:[(0,X.jsxs)(`g`,{className:`argus-brand-mark`,transform:`translate(180 92) scale(.54)`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]}),(0,X.jsxs)(`g`,{fill:`rgb(var(--brand-body))`,children:[(0,X.jsx)(`path`,{d:`M383 556Q394 556 409 555Q424 554 433 552L422 412Q415 414 401.5 415.5Q388 417 378 417Q340 417 305 403.5Q270 390 248.5 360Q227 330 227 278V0H78V546H191L213 454H220Q244 496 286 526Q328 556 383 556Z`,transform:`translate(444 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M255 556Q356 556 413 476H417L429 546H555V-1Q555-118 486-179Q417-240 282-240Q224-240 174.5-233Q125-226 78-208V-89Q179-131 291-131Q406-131 406-7V4Q406 21 407.5 39Q409 57 410 71H406Q378 28 339 9Q300-10 251-10Q154-10 99.5 64.5Q45 139 45 272Q45 406 101 481Q157 556 255 556ZM302 435Q197 435 197 270Q197 107 304 107Q361 107 388.5 139.5Q416 172 416 253V271Q416 359 389 397Q362 435 302 435Z`,transform:`translate(617.52 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M579 546V0H465L445 70H437Q411 28 365.5 9Q320-10 269-10Q181-10 128 37.5Q75 85 75 190V546H224V227Q224 169 245 139Q266 109 312 109Q380 109 405 155.5Q430 202 430 289V546Z`,transform:`translate(855.48 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M459 162Q459 79 400.5 34.5Q342-10 226-10Q169-10 128-2.5Q87 5 46 22V145Q90 125 141 112Q192 99 231 99Q275 99 293.5 112Q312 125 312 146Q312 160 304.5 171Q297 182 272 196Q247 210 194 232Q143 254 110 275.5Q77 297 61 327.5Q45 358 45 404Q45 480 104 518Q163 556 261 556Q312 556 358 546Q404 536 453 513L408 406Q368 423 332 434.5Q296 446 259 446Q193 446 193 410Q193 397 201.5 386.5Q210 376 234.5 364Q259 352 307 332Q354 313 388 292.5Q422 272 440.5 241.5Q459 211 459 162Z`,transform:`translate(1102.08 334) scale(.36 -.36)`})]})]})}function ji({size:e=20,tag:t,compact:n=!1}){return(0,X.jsxs)(`span`,{className:`inline-flex select-none items-center gap-2.5`,children:[n?(0,X.jsx)(ki,{size:e}):(0,X.jsx)(Ai,{size:e}),t&&!n?(0,X.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-ink-faint`,children:t}):null]})}var Mi={active:`label.status.inProgress`,claimed:`label.status.inProgress`,in_progress:`label.status.inProgress`,running:`label.status.inProgress`,working:`label.status.inProgress`,pending:`label.status.waiting`,queued:`label.status.waiting`,waiting:`label.status.waiting`,idle:`label.status.waiting`,accepted:`label.status.completed`,complete:`label.status.completed`,completed:`label.status.completed`,done:`label.status.completed`,success:`label.status.completed`,blocked:`label.status.blocked`,failed:`label.status.failed`,error:`label.status.failed`,rejected:`label.status.needsChanges`,continue:`label.status.needsChanges`,skipped:`label.status.skipped`,paused:`label.status.paused`,stopped:`label.status.paused`,cancelled:`label.status.paused`,aborted:`label.status.paused`,not_started:`label.status.waiting`,available:`label.status.available`,absent:`label.status.unavailable`,inaccessible:`label.status.inaccessible`,degraded:`label.status.limited`,healthy:`label.status.healthy`},Ni={manager:`label.role.manager`,planner:`label.role.planner`,engineer:`label.role.engineer`,reviewer:`label.role.reviewer`,system:`label.role.argus`,operator:`label.role.you`},Pi={completed:`label.outcome.workCompleted`,done:`label.outcome.workCompleted`,success:`label.outcome.workCompleted`,paused:`label.outcome.workPaused`,blocked:`label.outcome.workBlocked`,failed:`label.outcome.workFailed`,error:`label.outcome.workFailed`,aborted:`label.outcome.workEnded`,ended:`label.outcome.workEnded`,incomplete:`label.outcome.workIncomplete`,research_incomplete:`label.outcome.workIncomplete`,paused_no_breakthrough:`label.outcome.workIncomplete`,exhausted_current_methods:`label.outcome.workIncomplete`,stalled:`label.outcome.workStalled`,no_progress:`label.outcome.workStalled`,max_rounds:`label.outcome.workStalled`,infra_blocked:`label.outcome.workBlocked`,supervisor_error:`label.outcome.workFailed`},Fi={accepted:`label.outcome.reviewPassed`,done:`label.outcome.reviewPassed`,passed:`label.outcome.reviewPassed`,continue:`label.outcome.reviewNeedsChanges`,rejected:`label.outcome.reviewNeedsChanges`,blocked:`label.outcome.reviewBlocked`,stale:`label.outcome.reviewOutdated`,pending:`label.outcome.reviewPending`,pending_review:`label.outcome.reviewPending`},Ii={certified:`label.outcome.stageApproved`,not_certified:`label.outcome.stageNotApproved`,revoked:`label.outcome.stageRevoked`,intentionally_skipped:`label.outcome.stageNotNeeded`,deferred:`label.outcome.stagePending`},Li={budget_exhausted:`label.outcome.budgetPaused`,budget_pause:`label.outcome.budgetPaused`,operator_input_required:`label.outcome.waitingForYou`,operator_abort:`label.outcome.stoppedByYou`,operator_pause:`label.outcome.pausedByYou`,daemon_shutdown:`label.outcome.sessionPaused`,backend_unavailable:`label.outcome.serviceUnavailable`,provider_cooldown:`label.outcome.serviceCoolingDown`,provider_fence:`label.outcome.serviceUnavailable`,transient_error:`label.outcome.temporaryIssue`,permanent_error:`label.outcome.serviceError`,planner_empty_plan:`label.outcome.needsPlan`},Ri={cuda:`label.resource.nvidiaGpu`,rocm:`label.resource.amdGpu`,mps:`label.resource.appleGpu`,cpu:`label.resource.cpu`};function zi(e,t){return t(Mi[String(e??``).toLowerCase()]??`label.status.updated`)}function Bi(e,t){return t(Ni[String(e??``).toLowerCase()]??`label.role.argus`)}function Vi(e,t){return t(`label.priority`,{priority:e})}function Hi(e,t){if(!e?.execution_status)return[];let n=[t(Pi[e.execution_status.toLowerCase()]??`label.outcome.workUpdated`)],r=Fi[String(e.review_status??``).toLowerCase()],i=Ii[String(e.stage_certification??``).toLowerCase()],a=Li[String(e.interruption_kind??``).toLowerCase()];return r&&n.push(t(r)),i&&n.push(t(i)),a&&n.push(t(a)),e.resumable&&n.push(t(`label.outcome.canResume`)),n}function Ui(e,t){return t(Ri[e.toLowerCase()]??`label.resource.accelerator`)}function Wi(e,t){return t(e===`strict`?`label.resource.enforced`:`label.resource.advisory`)}function Gi(e,t){return t(e===`yield`?`label.resource.released`:`label.resource.kept`)}var Ki=[`manager`,`planner`,`engineer`,`reviewer`],qi=/Info: (?:Operation cancelled by user|Response was interrupted due to a server error\. Retrying\.\.\.)/gi;function Ji(e){let t=new Map;return e.forEach(e=>{let n=String(e.type??``);if(n===`life.mission.completed`||n===`mission.completed`){t.clear();return}let r=String(e.call_id??``);r&&(n===`provider.request.started`?t.set(r,e):(n===`provider.request.completed`||n===`provider.request.denied`)&&t.delete(r))}),Array.from(t.values()).at(-1)??null}function Yi({ev:e,r:t,first:n,last:r}){let i=W.role[t.role]??W.inkFaint,a=rr(t.tone);return(0,X.jsxs)(`div`,{className:`event-activity-row group relative grid grid-cols-[16px_minmax(0,1fr)] gap-3 px-4 py-3 transition-colors hover:bg-bg/70 ${r?`animate-appear`:``} ${t.reasoning?`opacity-60`:``}`,style:t.rule?{marginTop:4}:void 0,children:[(0,X.jsxs)(`div`,{className:`relative flex justify-center`,children:[n?null:(0,X.jsx)(`span`,{className:`absolute -top-2.5 h-4 w-px bg-line/60`}),r?null:(0,X.jsx)(`span`,{className:`absolute -bottom-2.5 top-2 w-px bg-line/60`}),(0,X.jsx)(`span`,{className:`relative z-10 mt-1.5 h-2 w-2 rounded-full border-2 border-panel`,style:{backgroundColor:i,boxShadow:`0 0 0 1px ${i}55`}})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-[0.06em]`,style:{color:i},title:t.label,children:t.label}),(0,X.jsx)(`span`,{className:`text-xs`,style:{color:a},children:t.glyph}),(0,X.jsx)(`time`,{className:`ml-auto font-mono text-xs tabular-nums text-ink-faint opacity-0 transition-opacity group-hover:opacity-100`,children:fi(e)})]}),(0,X.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-sm leading-5 ${t.reasoning?`italic`:``}`,style:{color:a},children:t.text})]})]})}function Xi({ev:e,r:t,artifacts:n,onOpenArtifact:r}){let{t:i}=Z(),a=String(e.type)===`ui.operator`,o=Number(e.response_latency_ms??0),s=!a&&o>=100?` · ${(o/1e3).toFixed(1)}s`:``,c=(0,F.useRef)(null);return si(c,(e,t)=>{c.current&&(t||e.fromTo(c.current,{autoAlpha:0,x:a?12:0,y:a?0:8},{autoAlpha:1,x:0,y:0,duration:.28,ease:`power2.out`,clearProps:`transform,opacity,visibility`}))}),(0,X.jsx)(`article`,{ref:c,className:`conversation-row group mx-auto w-full max-w-full px-4 py-3 sm:px-6 lg:max-w-[61.8vw]`,children:a?(0,X.jsxs)(`div`,{className:`flex items-end justify-end gap-2`,children:[(0,X.jsx)(Si,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsx)(`time`,{className:`shrink-0 pb-1 font-mono text-[10px] tabular-nums text-ink-faint`,children:fi(e)}),(0,X.jsx)(`div`,{className:`max-w-[calc(100%_-_3rem)] rounded-[18px] bg-conversation-user px-4 py-2.5 text-[15px] leading-relaxed text-ink ring-1 ring-line/35 sm:max-w-[82%]`,children:(0,X.jsx)(Oi,{artifacts:n,onOpenArtifact:r,children:t.text})})]}):(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center`,children:(0,X.jsx)(ki,{size:26,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1 text-[15px] leading-relaxed text-ink`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-blue`,children:`Argus`}),(0,X.jsx)(Si,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`ml-auto opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsxs)(`time`,{className:`font-mono text-[10px] tabular-nums text-ink-faint`,children:[fi(e),s]})]}),(0,X.jsx)(Oi,{artifacts:n,onOpenArtifact:r,children:t.text})]})]})})}function Zi({role:e,rows:t,open:n,active:r,onToggle:i}){let{t:a}=Z(),o=W.role[e],s=(0,F.useRef)(null),c=t[t.length-1]?.r.text.length??0;return(0,F.useEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{s.current&&s.current.scrollHeight>s.current.clientHeight&&(s.current.scrollTop=s.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[n,t.length,c]),(0,X.jsxs)(`section`,{className:`role-log-group border-b border-line/50`,"data-role":e,"data-open":n?`true`:`false`,"data-active":r?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":n,className:`group flex h-11 w-full items-center gap-2 px-4 text-left transition-colors hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${r?`animate-pulse`:`opacity-55`}`,style:{background:o}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink-dim`,children:Bi(e,a)}),(0,X.jsx)(`span`,{className:`font-mono text-xs text-ink-faint`,children:t.length}),t.length>0?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:t[t.length-1].r.text}):(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 text-ink-faint transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`grid grid-rows-[1fr]`,children:(0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{ref:s,className:`max-h-72 overflow-x-hidden overflow-y-auto border-t border-line/40 scroll-thin`,children:t.length>0?t.map(({ev:e,r:n,key:r},i)=>(0,X.jsx)(Yi,{ev:e,r:n,first:i===0,last:i===t.length-1},r)):(0,X.jsx)(`div`,{className:`px-4 py-3 text-xs text-ink-faint`,children:a(`stream.noLogs`)})})})}):null]})}function Qi(e){let t={manager:[],planner:[],engineer:[],reviewer:[]},n=[];return e.forEach(e=>{Ki.includes(e.r.role)?t[e.r.role].push(e):n.push(e)}),{roleRows:t,systemRows:n,lastRole:[...e].reverse().find(e=>Ki.includes(e.r.role))?.r.role??``}}function $i({rows:e}){let{t}=Z(),[n,r]=(0,F.useState)(!1);return(0,X.jsxs)(`section`,{className:`border-b border-line/50`,"data-system-open":n?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`flex h-10 w-full items-center gap-2 px-4 text-left text-xs text-ink-faint hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{children:t(`stream.system`)}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.length}),(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`border-t border-line/40`,children:e.map(({ev:t,r:n,key:r},i)=>(0,X.jsx)(Yi,{ev:t,r:n,first:i===0,last:i===e.length-1},r))}):null]})}function ea({rows:e,live:t}){let{roleRows:n,systemRows:r,lastRole:i}=(0,F.useMemo)(()=>Qi(e),[e]),[a,o]=(0,F.useState)(()=>new Set(t&&i?[i]:[])),s=(0,F.useRef)(!1);return(0,F.useEffect)(()=>{!t||!i||s.current||o(new Set([i]))},[i,t]),(0,X.jsxs)(`div`,{className:`bg-bg/25`,children:[Ki.map(e=>(0,X.jsx)(Zi,{role:e,rows:n[e],open:a.has(e),active:i===e,onToggle:()=>{s.current=!0,o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}},e)),r.length>0?(0,X.jsx)($i,{rows:r}):null]})}function ta(e){let t=e.delivery;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.delivery_id!=`string`||!n.delivery_id.trim()?null:n}function na(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.type===`ui.operator`)return null;let r=ta(n);if(r)return r}}function ra({delivery:e,onOpen:t}){let{t:n}=Z(),r=e.kind===`submission_certified`;return(0,X.jsxs)(`aside`,{className:`mx-auto my-3 flex w-full max-w-full gap-3 rounded-lg border border-ok/35 bg-ok/5 px-4 py-3 lg:max-w-[61.8vw]`,children:[(0,X.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-ok/15 font-semibold text-ok`,children:`✓`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:n(r?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-sm font-semibold text-ink`,title:e.title,children:e.title}),e.summary?(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-ink-dim`,children:$r(e.summary)}):null,t?(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`mt-2 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok hover:bg-ok/10`,children:n(e.primary_target?`mission.openResult`:`mission.viewTask`)}):null]})]})}function ia({group:e,latest:t,artifacts:n,onOpenArtifact:r,onOpenDelivery:i}){let a=e=>e.ev.type===`ui.argus`&&/^(info:|operation cancelled|cancelled\b)/i.test(e.r.text.trim()),o=e.rows.filter(e=>e.ev.type===`ui.argus`).map(e=>{let t=e.r.text.match(qi)??[],n=e.r.text.replace(qi,``).trim();return{reply:n&&!a(e)?{...e,r:{...e.r,text:n}}:null,messages:a(e)&&t.length===0?[e.r.text]:t}}),s=o.flatMap(e=>e.reply?[e.reply]:[]),c=o.flatMap(e=>e.messages),l=e.rows.filter(({ev:e})=>e.type!==`ui.argus`),u=(()=>{let t=new Set;return e.rows.flatMap(e=>{let n=ta(e.ev);return!n||t.has(n.delivery_id)?[]:(t.add(n.delivery_id),[n])})})();return(0,X.jsxs)(`section`,{className:`conversation-thread border-b border-line/60`,children:[(0,X.jsx)(Xi,{ev:e.operator.ev,r:e.operator.r,artifacts:n,onOpenArtifact:r}),s.map(e=>(0,X.jsx)(Xi,{ev:e.ev,r:e.r,artifacts:n,onOpenArtifact:r},e.key)),c.map((t,n)=>(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full px-6 py-1.5 text-center text-xs text-ink-faint lg:max-w-[61.8vw]`,children:t},`${e.key}-system-${n}`)),u.map(e=>(0,X.jsx)(ra,{delivery:e,onOpen:i},e.delivery_id)),l.length>0?(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full border-t border-line/40 lg:max-w-[61.8vw]`,children:(0,X.jsx)(ea,{rows:l,live:t})}):null]})}function aa({events:e,connected:t,showReasoning:n,onToggleReasoning:r,embedded:i=!1,showHeader:a=!0,filter:o=`all`,query:s=``,skipFirst:c=0,artifacts:l,onOpenArtifact:u,onOpenDelivery:d}){let{locale:f,t:p}=Z(),[m,h]=(0,F.useState)(!0),[g,_]=(0,F.useState)(()=>Date.now()),v=(0,F.useRef)(null),y=(0,F.useDeferredValue)(e),b=(0,F.useMemo)(()=>Ji(y),[y]);(0,F.useEffect)(()=>{if(!b)return;_(Date.now());let e=window.setInterval(()=>_(Date.now()),1e3);return()=>window.clearInterval(e)},[b]);let x=b?Math.max(0,Math.floor((g-Number(b.ts??0)*1e3)/1e3)):0,S=(0,F.useMemo)(()=>{let e=[],t=new Map,r=0;return(c>0?y.slice(c):y).forEach((i,a)=>{let c=ir(i,f);if(!c)return;if(c.reasoning&&!n){r++;return}if(!Mt(i,c,o,s))return;let l=i,u=String(l.message_id??``),d=!!u&&String(l.type)===`engineer.progress`&&[`assistant_message`,`agent_message`,`message`].includes(String(l.kind));if(d&&t.has(u)){let n=t.get(u);e[n]={...e[n],ev:{...e[n].ev,...i},r:{...e[n].r,...c,text:kt(e[n].r.text,c.text,Dt(i))}};return}let p={ev:i,r:c,key:ar(i,a)};d&&t.set(u,e.length),e.push(p)}),{list:e,hiddenReasoning:r}},[y,n,o,s,c,f]),C=(0,F.useMemo)(()=>{let e=[],t=[],n=null;return S.list.forEach(r=>{r.ev.type===`ui.operator`?(n={key:r.key,operator:r,rows:[]},e.push(n)):n?n.rows.push(r):t.push(r)}),{groups:e,earlier:t}},[S.list]),w=(0,F.useMemo)(()=>y.filter(Ct).length,[y]),T=(0,F.useMemo)(()=>S.list.slice(-20).reduce((e,t)=>e+t.r.text.length,0),[S.list]);return(0,F.useEffect)(()=>{if(!m)return;let e=window.requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[S.list.length,T,m]),(0,F.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>h(e.scrollHeight-e.scrollTop-e.clientHeight<40);return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,X.jsxs)(`section`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-panel ${i?``:`rounded-lg border border-line/80`}`,children:[a&&(0,X.jsx)(vi,{title:p(`panel.activity`),right:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`button`,{onClick:r,className:`rounded px-1.5 py-0.5 text-xs transition-colors ${n?`text-blue-sky`:`text-ink-faint hover:text-ink-dim`}`,title:p(`stream.toggleReasoning`),children:[p(`stream.reasoning`),w?` ·${w}`:``]}),(0,X.jsx)(`span`,{className:`text-xs ${t?`text-ok`:`text-ink-faint`}`,children:t?`● ${p(`common.live`)}`:`○ ${p(`common.reconnecting`)}`})]})}),b?(0,X.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-line/60 bg-blue-deep/5 px-4 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-blue-sky`}),(0,X.jsx)(`span`,{className:`truncate`,children:p(`stream.backgroundWork`)}),(0,X.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono tabular-nums text-ink-faint`,children:[x,`s`]})]}):null,(0,X.jsx)(`div`,{ref:v,className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto pb-6 pt-1.5 scroll-thin`,children:S.list.length===0?(0,X.jsx)(bi,{children:p(`stream.ready`)}):(0,X.jsxs)(X.Fragment,{children:[C.earlier.length>0?(0,X.jsxs)(`section`,{className:`mx-auto w-full max-w-full border-b border-line/60 lg:max-w-[61.8vw]`,children:[(0,X.jsxs)(`div`,{className:`flex h-10 items-center gap-2 border-b border-line/40 px-4 text-[10px] font-semibold uppercase tracking-[0.12em] text-ink-faint`,children:[p(`stream.autonomous`),(0,X.jsx)(`span`,{className:`font-mono font-normal tracking-normal`,children:C.earlier.length})]}),(0,X.jsx)(ea,{rows:C.earlier,live:C.groups.length===0})]}):null,C.groups.map((e,t)=>(0,X.jsx)(ia,{group:e,latest:t===C.groups.length-1,artifacts:l,onOpenArtifact:u,onOpenDelivery:d},e.key))]})}),!m&&(0,X.jsx)(`button`,{onClick:()=>{h(!0),v.current?.scrollTo({top:v.current.scrollHeight,behavior:`smooth`})},"aria-label":p(`stream.jumpToLatest`),title:p(`stream.jumpToLatest`),className:`absolute bottom-4 left-1/2 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full border border-line/60 bg-panel text-sm text-ink-dim shadow-glow transition-all duration-200 hover:border-ink-faint hover:text-ink`,children:`↓`})]})}function oa(e){return e.nativeEvent.isComposing||e.keyCode===229}var sa=`operator console`,ca={Everyday:`常用`,"Task management":`任务管理`,"Sessions & diagnostics":`会话与诊断`,Configuration:`配置`,Other:`其他`},la={status:`查看角色、队列、日志和健康状态`,roles:`查看各角色的后端、模型、推理强度和实时活动`,journal:`查看近期日志(默认 10 条)`,backlog:`查看待处理任务(all 包含已完成和已跳过)`,artifacts:`查看 Reviewer 批准的结果文件(按 Enter 预览)`,artifact:`预览一个已批准的结果文件`,events:`搜索动态:all / watch / milestones / messages`,find:`搜索当前事件缓冲区`,cancel:`停止等待当前 Manager 回复`,ask:`直接回答,不排任务、不走 Planner/Engineer/Reviewer`,task:`直接加入任务队列`,plan:`预览 Planner 编写的执行计划`,rewrite:`让 Manager 在发送前改写提示词`,nudge:`向正在运行的任务注入指导`,abort:`立即终止正在运行的任务`,note:`向时间线添加手动备注`,done:`将任务标记为完成`,skip:`跳过任务`,stop:`停止任务的自动迭代`,item:`查看完整任务契约`,run:`返回持续更新的任务动态`,new:`检查、创建并切换到新会话`,daemons:`查找全部会话并切换或创建`,resume:`切换到其他项目或会话`,attach:`跟随其他项目并读取其动态`,rename:`重命名当前会话`,doctor:`诊断为什么没有任务运行`,backend:`查看或更改共享 Runner 后端`,config:`查看或更改运行时设置`,identity:`查看或替换操作者身份卡`,reset:`清除 Manager 的热会话上下文`,skills:`查看或提升运行时 Skill`,clear:`清空事件动态视图`,reconnect:`重新连接实时动态`,help:`查看快捷键和完整命令参考`,quit:`离开控制台(后台工作继续运行)`};function ua(e,t){return t===`zh-CN`?la[e.id]:e.id===`reconnect`?`reconnect live activity`:e.desc}function da(e,t){return t===`zh-CN`?ca[e.group]:e.group}function fa(e,t){let n=new Map;for(let r of e){let e=da(r,t),i=r.aliases?.length?` (= ${r.aliases.join(`, `)})`:``,a=`${r.name}${r.arg?` ${r.arg}`:``}${i}`;n.has(e)||n.set(e,[]),n.get(e).push({label:a,desc:ua(r,t)})}return[...n.entries()].map(([e,t])=>({group:e,rows:t}))}var pa=`slash-completion-listbox`;function ma(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function ha(e){return`slash-completion-option-${e}`}function ga({query:e,selected:t,onSelect:n}){let{locale:r,t:i}=Z(),a=Rt(e);if(a.length===0)return null;let o=a.slice(0,8),s=ma(t,o.length);return(0,X.jsx)(`div`,{id:pa,role:`listbox`,"aria-label":i(`slash.suggestions`),className:`slash-completion-menu scroll-thin border-b border-line/40`,children:o.map((e,t)=>(0,X.jsxs)(`button`,{id:ha(e.id),type:`button`,role:`option`,"aria-selected":t===s,onPointerDown:e=>{e.preventDefault(),n(t)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm transition-colors ${t===s?`bg-blue/10 text-ink`:`text-ink-dim hover:bg-line/20`}`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-blue`,children:e.name}),e.arg?(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-ink-faint`,children:e.arg}):null,(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:ua(e,r)})]},e.id))})}var _a=10485760,va=26214400,ya=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.pdf`,`.md`,`.markdown`,`.txt`,`.json`,`.csv`].join(`,`),ba={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".pdf":`application/pdf`,".md":`text/markdown`,".markdown":`text/markdown`,".txt":`text/plain`,".json":`application/json`,".csv":`text/csv`};function xa(e){let t=String(e||``).trim().toLowerCase(),n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function Sa(e){return ba[xa(e.name)]||String(e.type||``).split(`;`,1)[0].trim()||`application/octet-stream`}function Ca(e){return Object.hasOwn(ba,xa(e.name))}function wa(e){return Sa(e).startsWith(`image/`)}function Ta(e){return[e.name,String(e.size),Sa(e),String(e.lastModified??``)].join(`::`)}function Ea(e,t){let n=[],r=[],i=new Set(e.map(Ta)),a=e.reduce((e,t)=>e+Math.max(0,t.size||0),0),o=e.length;for(let e of t){let t=Ta(e);if(!i.has(t)){if(i.add(t),!Ca(e)){r.push({code:`unsupported`,fileName:e.name});continue}if(o>=5){r.push({code:`too-many`,limitCount:5});continue}if(e.size>10485760){r.push({code:`too-large`,fileName:e.name,limitBytes:_a});continue}if(a+e.size>26214400){r.push({code:`too-large-total`,limitBytes:va});continue}n.push(e),a+=e.size,o+=1}}return{accepted:n,issues:r}}function Da(e){return e?Array.from(e):[]}function Oa(e){return Da(e?.types).map(e=>String(e)).includes(`Files`)||ka(e).length>0}function ka(e){let t=Da(e?.files).filter(e=>e instanceof File);if(t.length)return t;let n=[];for(let t of Da(e?.items)){if(String(t?.kind||``)!==`file`||typeof t?.getAsFile!=`function`)continue;let e=t.getAsFile();e instanceof File&&n.push(e)}return n}function Aa({file:e,removeLabel:t,onRemove:n,disabled:r=!1}){let[i,a]=(0,F.useState)(``);return(0,F.useEffect)(()=>{if(!wa(e)||typeof URL>`u`||typeof URL.createObjectURL!=`function`){a(``);return}let t=URL.createObjectURL(e);return a(t),()=>URL.revokeObjectURL(t)},[e]),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-2xl border border-line/50 bg-panel/80 px-2.5 py-2 text-xs shadow-[0_10px_24px_-20px_rgb(0_0_0/0.2)]`,children:[i?(0,X.jsx)(`img`,{src:i,alt:``,className:`h-10 w-10 shrink-0 rounded-xl border border-line/40 object-cover`}):null,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-ink`,title:e.name,children:e.name}),(0,X.jsxs)(`div`,{className:`truncate text-ink-faint`,children:[di(e.size),` · `,Sa(e)]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:r,"aria-label":t,title:t,className:`send-control h-8 w-8 shrink-0 rounded-full border-line/60 text-ink-faint hover:border-err/50 hover:bg-err/10 hover:text-err`,children:`×`})]})}function ja(e,t){if(!t.onRewrite||!Zn(e.key,e.ctrlKey,e.metaKey))return!1;e.preventDefault();let n=t.value.trim();return n&&!t.disabled&&!t.pending&&!t.rewriting&&t.onRewrite(n),!0}function Ma({value:e,onChange:t,onSend:n,onCancel:r,disabled:i,pending:a,focusSignal:o,embedded:s=!1,steps:c=[],onRewrite:l,rewriting:u=!1,slashSelection:d,onSlashSelectionChange:f,routeOverride:p=`auto`,onRouteOverrideChange:m}){let{t:h}=Z(),g=(0,F.useRef)(null),_=(0,F.useRef)(null),[v,y]=(0,F.useState)(0),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)([]),[w,T]=(0,F.useState)(``),[ee,E]=(0,F.useState)(0);(0,F.useEffect)(()=>{if(!a&&!u)return;y(e=>e+1);let e=setInterval(()=>y(e=>e+1),200);return()=>clearInterval(e)},[a,u]);let te=Jn(c),ne=Date.now()/1e3;(0,F.useEffect)(()=>{o&&!i&&g.current?.focus()},[o,i]);let re=Rt(e).slice(0,8),ie=re.length>0&&!b,D=ie?ma(d,re.length):0,ae=ie?re[D]:void 0,oe=e=>{let n=re[e];n&&(t(Bt(n)),n.argument===`none`&&x(!0),f(0),g.current?.focus())},O=async()=>{let r=e.trim();!r||a||i||await n(r,S.map(e=>e.file))&&(t(``),f(0),x(!1),C([]),T(``))},k=(e,t)=>h(e===`unsupported`?`chat.attachUnsupported`:e===`too-large`?`chat.attachTooLarge`:e===`too-many`?`chat.attachTooMany`:`chat.attachTotalTooLarge`,t),se=e=>{if(!e.length||i||a)return;let{accepted:t,issues:n}=Ea(S.map(e=>e.file),e);t.length&&C(e=>[...e,...t.map(e=>({id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,file:e}))]),T(n.map(e=>e.code===`unsupported`?k(e.code,{name:e.fileName}):e.code===`too-large`?k(e.code,{name:e.fileName,size:di(e.limitBytes)}):e.code===`too-many`?k(e.code,{count:e.limitCount}):k(e.code,{size:di(e.limitBytes)})).join(` `))};return(0,X.jsxs)(`div`,{onDragEnter:e=>{Oa(e.dataTransfer)&&(e.preventDefault(),E(e=>e+1))},onDragOver:e=>{Oa(e.dataTransfer)&&e.preventDefault()},onDragLeave:e=>{Oa(e.dataTransfer)&&(e.preventDefault(),E(e=>Math.max(0,e-1)))},onDrop:e=>{Oa(e.dataTransfer)&&(e.preventDefault(),E(0),se(ka(e.dataTransfer)))},className:`glass-card glass-panel--raised flex flex-col overflow-hidden rounded-2xl ${s?`shadow-[0_12px_36px_-22px_rgb(0_0_0/0.22)] backdrop-blur-md`:``} ${ee>0?`ring-2 ring-manager/60 ring-offset-0`:``}`,children:[a?(0,X.jsxs)(`div`,{className:`border-b border-line/40 px-3 py-2`,children:[te.length?(0,X.jsx)(`ol`,{className:`mt-1.5 space-y-0.5`,children:te.map((e,t)=>{let n=t===te.length-1&&!e.endedTs,r=Xn(Yn(e,ne));return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono ${n?`text-manager`:`text-ok`}`,children:n?Un(v):`✓`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono ${n?`text-ink`:`text-ink-faint`}`,title:e.detail||e.label,children:e.label}),r?(0,X.jsx)(`span`,{className:`shrink-0 font-mono tabular-nums text-ink-faint`,children:r}):null]},e.id)})}):null,(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-faint`,children:h(`chat.stopWaitingHint`)})]}):null,ie?(0,X.jsx)(ga,{query:e,selected:D,onSelect:oe}):null,S.length||w||ee>0?(0,X.jsxs)(`div`,{className:`border-b border-line/30 px-3 py-2`,children:[ee>0?(0,X.jsx)(`div`,{className:`mb-2 text-xs font-medium text-manager`,children:h(`chat.attachDrop`)}):null,S.length?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:S.map(e=>(0,X.jsx)(Aa,{file:e.file,removeLabel:h(`chat.attachRemove`,{name:e.file.name}),onRemove:()=>{C(t=>t.filter(t=>t.id!==e.id)),T(``)}},e.id))}):null,(0,X.jsx)(`div`,{className:`mt-2 text-xs ${w?`text-err`:`text-ink-faint`}`,children:w||h(`chat.attachHint`,{count:5,perFile:di(10485760),total:di(26214400)})})]}):null,(0,X.jsxs)(`div`,{className:`flex items-end gap-2 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`pb-2 font-mono text-lg text-blue`,title:h(`chat.messageArgus`),children:`›`}),(0,X.jsx)(`input`,{ref:_,type:`file`,multiple:!0,accept:ya,onChange:e=>{se(Array.from(e.target.files??[])),e.target.value=``},className:`hidden`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>_.current?.click(),disabled:i||a,title:`${h(`chat.attach`)} · ${h(`chat.attachHint`,{count:5,perFile:di(_a),total:di(va)})}`,"aria-label":h(`chat.attach`),className:`send-control h-9 w-9 shrink-0 rounded-full border-line/70 bg-panel/80 text-base text-ink-faint hover:border-blue/50 hover:bg-blue/10 hover:text-blue disabled:opacity-40`,children:`📎`}),(0,X.jsx)(`textarea`,{ref:g,value:e,onChange:e=>{t(e.target.value),f(0),x(!1)},onPaste:e=>{let t=ka(e.clipboardData);t.length&&(e.preventDefault(),se(t))},onKeyDown:t=>{oa(t)||ja(t,{value:e,disabled:i,pending:a,rewriting:u,onRewrite:l})||(ie?t.key===`ArrowDown`?(t.preventDefault(),f(ma(D+1,re.length))):t.key===`ArrowUp`?(t.preventDefault(),f(ma(D-1,re.length))):t.key===`Tab`||t.key===`Enter`&&!t.shiftKey?(t.preventDefault(),oe(D)):t.key===`Escape`&&(t.preventDefault(),x(!0)):t.key===`Escape`&&a?(t.preventDefault(),r()):t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),O()))},"aria-keyshortcuts":`Control+R Meta+R`,rows:1,disabled:i,"aria-controls":ie?pa:void 0,"aria-expanded":ie,"aria-activedescendant":ae?ha(ae.id):void 0,placeholder:h(i?`chat.selectSession`:`chat.placeholder`),className:`max-h-48 min-h-[38px] min-w-0 flex-1 resize-none bg-transparent py-2 font-sans text-[15px] text-ink outline-none placeholder:text-ink-faint`,style:{fieldSizing:`content`}}),m?(0,X.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),disabled:i||a,title:h(`chat.routeHint`),"aria-label":h(`chat.routeLabel`),className:`send-control h-9 shrink-0 rounded-full border-line bg-transparent px-3 text-xs font-medium text-ink-faint hover:border-blue/70 hover:text-ink disabled:opacity-40`,children:[(0,X.jsx)(`option`,{value:`task`,children:h(`chat.routeTask`)}),(0,X.jsx)(`option`,{value:`auto`,children:h(`chat.routeAuto`)}),(0,X.jsx)(`option`,{value:`chat`,children:h(`chat.routeChat`)})]}):null,l?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e.trim()),disabled:i||a||u||!e.trim(),title:`Ctrl/⌘+R · ${h(`chat.rewriteHint`)}`,"aria-label":h(`chat.rewriteLabel`),"aria-keyshortcuts":`Control+R Meta+R`,className:`send-control h-9 shrink-0 rounded-full border-manager/70 bg-manager/10 px-3 text-xs font-medium text-manager hover:border-manager hover:bg-manager/20 disabled:opacity-40`,children:u?`${Un(v)} ${h(`chat.rewriting`)}`:h(`chat.rewrite`)}):null,(0,X.jsx)(`button`,{type:`button`,onClick:a?r:()=>void O(),disabled:i||!a&&!e.trim(),title:a?h(`chat.stopWaitingTitle`):void 0,"aria-label":h(a?`chat.stopWaiting`:`chat.send`),className:`send-control h-9 w-9 shrink-0 rounded-full text-sm font-medium disabled:opacity-40 ${a?`border-line text-warn hover:border-warn/60 hover:bg-warn/10`:`border-blue/70 bg-blue/10 text-blue hover:border-blue hover:bg-blue/20`}`,children:a?`■`:`↑`})]})]})}function Na({open:e,onClose:t,children:n,label:r,width:i=`max-w-2xl`,align:a=`center`,viewport:o=!1,showClose:s=!0,style:c}){let{t:l}=Z(),u=(0,F.useRef)(null),d=(0,F.useRef)(null),f=(0,F.useRef)(t);return f.current=t,si(u,(t,n)=>{if(!(!e||!u.current||!d.current)){if(n){t.set([d.current,u.current],{clearProps:`all`});return}t.timeline({defaults:{overwrite:`auto`}}).fromTo(d.current,{autoAlpha:0},{autoAlpha:1,duration:.14,ease:`power1.out`},0).fromTo(u.current,{autoAlpha:0,y:a===`top`?-6:8,scale:.992},{autoAlpha:1,y:0,scale:1,duration:.2,ease:`power3.out`,clearProps:`transform,opacity,visibility`},.03)}},[e,a]),(0,F.useEffect)(()=>{if(!e)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>{(u.current?.querySelector(`[data-autofocus]`)??u.current?.querySelector(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)??u.current)?.focus()}),r=e=>{if(e.key===`Escape`){e.preventDefault(),f.current();return}if(e.key!==`Tab`||!u.current)return;let t=Array.from(u.current.querySelectorAll(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`);if(t.length===0){e.preventDefault(),u.current.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||!u.current.contains(document.activeElement))?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,r),()=>{window.cancelAnimationFrame(n),window.removeEventListener(`keydown`,r),t?.isConnected&&t.focus()}},[e]),e?(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex ${a===`top`?`items-start pt-3 sm:pt-14`:`items-center`} justify-center ${o?`p-0`:`p-3 sm:p-4`}`,onPointerDown:t,children:[(0,X.jsx)(`div`,{ref:d,className:`modal-scrim absolute inset-0`}),(0,X.jsxs)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,tabIndex:-1,style:c,className:`brand-modal glass-panel glass-panel--raised relative z-10 w-full overscroll-contain ${i} scroll-thin ${o?`flex h-[100dvh] max-h-[100dvh] flex-col overflow-hidden rounded-none`:`max-h-[calc(100dvh-1.5rem)] overflow-x-hidden overflow-y-auto rounded-2xl sm:max-h-[88dvh]`}`,onPointerDown:e=>e.stopPropagation(),children:[!o&&s?(0,X.jsx)(`button`,{type:`button`,"data-modal-close":!0,onClick:t,"aria-label":l(`common.close`),className:`modal-close`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`m4 4 8 8m0-8-8 8`})})}):null,n]})]}):null}function Pa({title:e,sub:t}){return(0,X.jsxs)(`div`,{className:`px-6 pb-3 pr-14 pt-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold tracking-[-0.01em] text-ink`,children:e}),t&&(0,X.jsx)(`p`,{className:`mt-1 text-sm text-ink-faint`,children:t})]})}function Fa(e,t,n,r=`en`){return e.map(e=>({id:`command-${e.id}`,label:ua(e,r),hint:`${e.name}${e.arg?` ${e.arg}`:``}`,group:da(e,r),keywords:[e.name,...e.aliases??[]].join(` `),run:()=>Ft(e)?n(`${e.name} `):t(e.name)}))}function Ia(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length?e.filter(e=>{let t=`${e.label} ${e.group} ${e.hint??``} ${e.keywords??``}`.toLowerCase();return n.every(e=>t.includes(e))}):e}function La({open:e,onClose:t,items:n}){let{t:r}=Z(),[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(0),c=(0,F.useRef)(null),l=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&(a(``),s(0),setTimeout(()=>c.current?.focus(),0))},[e]);let u=(0,F.useMemo)(()=>Ia(n,i),[i,n]);(0,F.useEffect)(()=>{o>=u.length&&s(Math.max(0,u.length-1))},[u.length,o]),(0,F.useEffect)(()=>{l.current?.scrollIntoView({block:`nearest`})},[e,i,o]);let d=e=>{e&&(t(),e.run())},f=e=>{oa(e)||(e.key===`ArrowDown`?(e.preventDefault(),u.length&&s(e=>Math.min(u.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),d(u[o])))},p=[];for(let e of u){let t=p.find(t=>t.name===e.group);t||(t={name:e.group,items:[]},p.push(t)),t.items.push(e)}let m=-1;return(0,X.jsxs)(Na,{open:e,onClose:t,label:r(`help.palette`),width:`max-w-xl`,align:`top`,children:[(0,X.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,X.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onKeyDown:f,placeholder:r(`palette.placeholder`),role:`combobox`,"aria-expanded":e,"aria-autocomplete":`list`,"aria-controls":`command-palette-results`,"aria-activedescendant":u[o]?`palette-${u[o].id}`:void 0,className:`w-full bg-transparent font-mono text-sm text-ink outline-none placeholder:text-ink-faint`})}),(0,X.jsxs)(`div`,{id:`command-palette-results`,role:`listbox`,className:`max-h-[52vh] overflow-y-auto scroll-thin py-1.5`,children:[u.length===0&&(0,X.jsx)(`div`,{className:`px-4 py-6 text-center text-xs text-ink-faint`,children:r(`palette.noMatches`)}),p.map(e=>(0,X.jsxs)(`div`,{className:`mb-1`,children:[(0,X.jsx)(`div`,{className:`px-4 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.name}),e.items.map(e=>{m++;let t=m===o;return(0,X.jsxs)(`button`,{id:`palette-${e.id}`,ref:t?l:void 0,role:`option`,"aria-selected":t,onMouseEnter:()=>s(u.indexOf(e)),onClick:()=>d(e),className:`flex w-full items-center justify-between px-4 py-1.5 text-left text-sm transition-colors ${t?`bg-blue-deep/20 text-ink`:`text-ink-dim hover:bg-panel/60`}`,children:[(0,X.jsx)(`span`,{children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-ink-faint`,children:e.hint})]},e.id)})]},e.name))]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-line px-4 py-1.5 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{children:r(`palette.navigate`)}),(0,X.jsx)(`span`,{children:r(`palette.run`)}),(0,X.jsx)(`span`,{children:r(`palette.close`)})]})]})}var Ra=[{keys:`⌘K / Ctrl+K`,desc:`help.palette`},{keys:`⌘B / Ctrl+B`,desc:`help.sessions`},{keys:`⌘J / Ctrl+J`,desc:`help.managerChat`},{keys:`⌘R / Ctrl+R`,desc:`help.rewrite`},{keys:`⌘T / Ctrl+T`,desc:`help.reasoning`},{keys:`⌘. / Ctrl+.`,desc:`help.kiosk`},{keys:`/`,desc:`help.composer`},{keys:`↵ Enter`,desc:`help.send`},{keys:`Shift+Enter`,desc:`help.newline`},{keys:`?`,desc:`help.thisHelp`},{keys:`Esc`,desc:`help.escape`}];function za({open:e,onClose:t}){let{locale:n,t:r}=Z(),i=fa(Nt,n);return(0,X.jsxs)(Na,{open:e,onClose:t,label:r(`help.title`),width:`max-w-2xl`,children:[(0,X.jsx)(Pa,{title:r(`help.title`)}),(0,X.jsxs)(`div`,{className:`max-h-[70dvh] overflow-y-auto scroll-thin`,children:[(0,X.jsx)(`div`,{className:`p-4`,children:Ra.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm text-ink-dim`,children:r(e.desc)}),(0,X.jsx)(`kbd`,{className:`rounded border border-line bg-surface px-2 py-0.5 font-mono text-[11px] text-ink`,children:e.keys})]},e.keys))}),(0,X.jsxs)(`div`,{className:`border-t border-line px-4 pb-4 pt-3`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-ink-faint`,children:r(`help.commands`)}),i.map(e=>(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.group}),e.rows.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-1`,children:[(0,X.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-ink`,children:e.label}),(0,X.jsx)(`span`,{className:`text-right text-xs text-ink-dim`,children:e.desc})]},e.label))]},e.group))]})]})]})}function Ba({sid:e,config:t,onSaved:n}){let{locale:r}=Z(),i=r===`zh-CN`,a=t.roles.find(e=>e.role===`engineer`),o=new Map(t.operator_knobs.map(e=>[e.name,e.value])),s=o.get(`ARGUS_SKILL_MAP_MODEL`)||`auto`,c=o.get(`ARGUS_SKILL_MAP_REASONING_EFFORT`)||`auto`,[l,u]=(0,F.useState)(s===`auto`?``:s),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(``);(0,F.useEffect)(()=>u(s===`auto`?``:s),[s]);let h=async(t,r)=>{if(!d){f(!0),m(``);try{await U.setConfig(e,t,r),await n()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}},g=i?`跟随科研设置`:`Follow research settings`;return(0,X.jsxs)(`section`,{className:`map-model-settings rounded-lg border border-line glass-card p-3`,"aria-label":i?`地图模型`:`Map model`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:i?`地图模型`:`Map model`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-dim`,children:i?`沿用科研执行的接入与账号。留空即可跟随科研模型。`:`Uses the research runner and account. Leave the model blank to follow research settings.`}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:[a?.backend_label,` · `,a?.model||(i?`接入默认模型`:`Runner default model`)]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,X.jsxs)(`label`,{className:`min-w-0 flex-1 text-xs text-ink-dim`,children:[i?`摘要模型`:`Summary model`,(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:d,placeholder:g,className:`mt-1 h-9 w-full rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`})]}),(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,l.trim()||`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:i?`应用`:`Apply`}),s!==`auto`&&(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:g})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex items-center gap-3 text-xs text-ink-dim`,children:[i?`思考强度`:`Reasoning effort`,(0,X.jsxs)(`select`,{value:c,disabled:d,onChange:e=>void h(`ARGUS_SKILL_MAP_REASONING_EFFORT`,e.target.value),className:`h-9 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`,children:[(0,X.jsx)(`option`,{value:`auto`,children:g}),[[`low`,`低`],[`medium`,`中`],[`high`,`高`],[`xhigh`,`很高`],[`max`,`最高`]].map(([e,t])=>(0,X.jsx)(`option`,{value:e,children:i?t:e},e))]})]}),p&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-err`,children:p})]})}var Va=[{name:`ARGUS_SKILL_MAX_ACTIVE_DAEMONS`,group:`Limits`,label:`Active daemon limit`,description:`Maximum background sessions running on this host.`},{name:`ARGUS_SKILL_UNPRICED_COST_POLICY`,group:`Safety`,label:`Unpriced calls`,description:`Whether calls with unresolved pricing are blocked or allowed.`},{name:`ARGUS_SKILL_SAFE_MODE`,group:`Safety`,label:`Safe mode`,description:`Enable extra-conservative runtime guardrails.`},{name:`ARGUS_SKILL_ENABLE_TELEGRAM`,group:`Interface`,label:`Telegram`,description:`Enable the Telegram notification bridge.`},{name:`ARGUS_SKILL_SHOW_REASONING`,group:`Interface`,label:`Show reasoning`,description:`Stream role reasoning into the cockpit activity view.`}];function Ha(e){let t=new Map(e.map(e=>[e.name,e]));return Va.flatMap(e=>{let n=t.get(e.name);return n?[{...n,group:e.group,label:e.label,doc:e.description}]:[]})}function Ua(e,t){let n=new URL(e),r=n.protocol===`https:`?`wss:`:`ws:`,i=encodeURIComponent(t);return{webApi:`${n.origin}/api`,eventStream:`${r}//${n.host}/api/projects/${i}/stream`,daemon:`local process · events.jsonl · no TCP port`}}var Wa=[{value:`copilot`,label:`settings.backendLabel.copilot`},{value:`codex`,label:`settings.backendLabel.codex`},{value:`claude`,label:`settings.backendLabel.claude`},{value:`cursor`,label:`settings.backendLabel.cursor`},{value:`opencode`,label:`settings.backendLabel.opencode`},{value:`pi`,label:`settings.backendLabel.pi`},{value:`grok`,label:`settings.backendLabel.grok`},{value:`qoder`,label:`settings.backendLabel.qoder`},{value:`dsh`,label:`settings.backendLabel.dsh`}],Ga={copilot:`copilot`,codex:`codex`,claude:`claude`,cursor:`cursor`,opencode:`opencode`,pi:`pi`,grok:`grok`,qoder:`qoder`,dsh:`dsh`};function Ka(e){return Ga[e]??``}function qa(e,t){let n=Ka(e);return n?t(`settings.backendLabel.${n}`):e}function Ja(e){return e?.operator_knobs.find(e=>e.name===`ARGUS_SKILL_RUNNER_BACKEND`)?.value??e?.roles[0]?.backend??``}var Ya=[{alias:`global_daily_cap`,env:`ARGUS_SKILL_GLOBAL_DAILY_CAP_USD`,label:`settings.budget.global`,unit:`settings.unit.usd`,step:`0.1`},{alias:`codex_daily_requests`,env:`ARGUS_SKILL_CODEX_DAILY_CALL_CAP`,label:`settings.budget.codex`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_requests`,env:`ARGUS_SKILL_COPILOT_DAILY_CALL_CAP`,label:`settings.budget.copilot`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_premium`,env:`ARGUS_SKILL_COPILOT_DAILY_PREMIUM_CAP`,label:`settings.budget.premium`,unit:`settings.unit.requests`,step:`1`}],Xa={ARGUS_SKILL_MAX_ACTIVE_DAEMONS:{label:`settings.knob.activeDaemons`,doc:`settings.knob.activeDaemonsDoc`},ARGUS_SKILL_UNPRICED_COST_POLICY:{label:`settings.knob.unpricedCalls`,doc:`settings.knob.unpricedCallsDoc`},ARGUS_SKILL_SAFE_MODE:{label:`settings.knob.safeMode`,doc:`settings.knob.safeModeDoc`},ARGUS_SKILL_ENABLE_TELEGRAM:{label:`settings.knob.telegram`,doc:`settings.knob.telegramDoc`},ARGUS_SKILL_SHOW_REASONING:{label:`settings.knob.showReasoning`,doc:`settings.knob.showReasoningDoc`}},Za={Limits:`settings.group.limits`,Safety:`settings.group.safety`,Interface:`settings.group.interface`},Qa={manager:`settings.role.managerDoc`,planner:`settings.role.plannerDoc`,engineer:`settings.role.engineerDoc`,reviewer:`settings.role.reviewerDoc`,curator:`settings.role.curatorDoc`};function $a(e,t){let n=e.trim();return n===`not applicable for this model`?t(`settings.source.notApplicable`):n.startsWith(`capability vault`)?t(`settings.source.vaultDefault`):n.startsWith(`default`)?t(`settings.source.default`):n.startsWith(`persisted:`)||n===`persisted`?t(`settings.source.saved`):n.startsWith(`ARGUS_SKILL_`)||n===`env`?t(`settings.source.environment`):n.startsWith(`global:`)?t(`settings.source.hostConfig`):t(`settings.source.other`)}function eo(e,t){let n=e.value.trim().toLowerCase();if(e.name===`ARGUS_SKILL_UNPRICED_COST_POLICY`){if(n===`block`)return t(`settings.value.block`);if(n===`allow`)return t(`settings.value.allow`)}return[`ARGUS_SKILL_SAFE_MODE`,`ARGUS_SKILL_ENABLE_TELEGRAM`,`ARGUS_SKILL_SHOW_REASONING`].includes(e.name)?t([`1`,`true`,`on`,`yes`].includes(n)?`settings.value.enabled`:`settings.value.disabled`):e.value}function to(e,t){let n={low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`}[e.toLowerCase()];return n?t(`settings.effort.${n}`):e}function no({message:e,retrying:t,onRetry:n,t:r}){return(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-center gap-3 px-4 py-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-err`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:t,className:`rounded-md border border-err/40 px-3 py-1.5 text-xs font-medium text-err hover:bg-err/10 disabled:opacity-40`,children:r(t?`common.loading`:`common.retry`)})]})}function ro({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,isError:o,isFetching:s,refetch:c}=xr(e,t),l=!!(i&&(i.recommended||i.checks.length||i.log_tail.trim()));return(0,X.jsxs)(Na,{open:t,onClose:n,label:r(`doctor.title`),width:`max-w-3xl`,children:[(0,X.jsx)(Pa,{title:r(`doctor.title`),sub:r(`doctor.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(yi,{})}),!a&&o&&(0,X.jsx)(no,{message:r(`doctor.loadError`),retrying:s,onRetry:()=>void c(),t:r}),!a&&!o&&!l&&(0,X.jsx)(bi,{children:r(`doctor.empty`)}),!a&&!o&&i?.recommended&&(0,X.jsxs)(`div`,{className:`mb-4 rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`doctor.recommended`)}),(0,X.jsx)(`div`,{className:`mt-1 text-sm text-ink`,children:i.recommended.name}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:i.recommended.detail}),i.recommended.fix&&(0,X.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words rounded bg-bg p-2 font-mono text-xs text-blue-sky`,children:i.recommended.fix})]}),!a&&!o&&(0,X.jsx)(`div`,{className:`space-y-1.5`,children:(i?.checks??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-line/60 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:e.ok?`text-ok`:`text-err`,children:e.ok?`✓`:`✗`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.name}),e.detail&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] text-ink-dim`,children:e.detail}),!e.ok&&e.fix&&(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded bg-bg p-1.5 font-mono text-xs text-ink-dim`,children:e.fix})]})]},t))}),!a&&!o&&i?.log_tail&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`doctor.daemonLog`)}),(0,X.jsx)(`pre`,{className:`max-h-48 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg bg-bg p-3 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:i.log_tail})]})]})]})}function io({sid:e,open:t,onClose:n,themeStyle:r,onThemeStyleChange:i}){let{t:a}=Z(),s=ce(),{data:c,isLoading:l,isError:u,isFetching:d,refetch:f}=Sr(e,t),[p,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(``),[C,w]=(0,F.useState)(!1),[ee,E]=(0,F.useState)(``),[te,ne]=(0,F.useState)(``),[re,ie]=(0,F.useState)(!1),[D,ae]=(0,F.useState)(``),[oe,O]=(0,F.useState)(!1),[k,se]=(0,F.useState)(``),[A,le]=(0,F.useState)({});(0,F.useEffect)(()=>{t||h(!1)},[t]),(0,F.useEffect)(()=>{if(!t||!c)return;_(c.operator_knobs.find(e=>e.name===`ARGUS_SKILL_MODEL`)?.value??``);let e=new Map(c.operator_knobs.map(e=>[e.name,e.value]));le(Object.fromEntries(Ya.map(t=>[t.alias,e.get(t.env)??``])))},[c,t]);let j=async()=>{await f(),await s.invalidateQueries({queryKey:[`map-copy`]})},M=Ja(c),ue=async t=>{if(!v){y(!0),x(``),w(!1);try{await U.setConfig(e,`ARGUS_SKILL_RUNNER_BACKEND`,t),await j(),x(a(`settings.backendSwitched`,{backend:qa(t,a)}))}catch(e){w(!0),x(e instanceof Error?e.message:String(e))}finally{y(!1)}}},de=async()=>{if(!v){y(!0),x(``),w(!1);try{await U.setConfig(e,`ARGUS_SKILL_MODEL`,g.trim()||`auto`),await j(),x(a(`settings.applied`))}catch(e){w(!0),x(e instanceof Error?e.message:String(e))}finally{y(!1)}}},fe=async()=>{if(!oe){O(!0),se(``);try{let t=Object.fromEntries(Ya.map(e=>{let t=String(A[e.alias]??``).trim();if(!t)throw Error(a(`settings.required`,{field:a(e.label)}));return[e.alias,t]}));await U.setBudgets(e,t),await j(),se(a(`settings.budgetSaved`))}catch(e){se(e instanceof Error?e.message:String(e))}finally{O(!1)}}},pe=async t=>{if(t.preventDefault(),!(!ee.trim()||!te.trim()||re)){ie(!0),ae(``);try{await U.setConfig(e,ee.trim(),te.trim()),await j(),ae(a(`settings.applied`))}catch(e){ae(e instanceof Error?e.message:String(e))}finally{ie(!1)}}},N=Ha(c?.operator_knobs??[]).reduce((e,t)=>((e[t.group]??=[]).push(t),e),{}),P=Ua(window.location.origin,e),me=!!(c&&(c.roles.length||c.operator_knobs.length));return(0,X.jsxs)(Na,{open:t,onClose:n,label:a(`common.settings`),width:`max-w-4xl`,children:[(0,X.jsx)(Pa,{title:a(`common.settings`),sub:a(`settings.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[(0,X.jsxs)(`section`,{className:`mb-4 rounded-lg border border-line glass-card p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:a(`settings.appearance`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:a(`settings.appearanceHint`)}),(0,X.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2`,role:`radiogroup`,"aria-label":a(`settings.themeStyle`),children:[`standard`,`gradient`].map(e=>(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,"data-selected":r===e,onClick:()=>i(e),className:`theme-style-option`,children:[(0,X.jsx)(`span`,{className:`theme-style-preview theme-style-preview--${e}`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,X.jsx)(`span`,{className:`block text-xs font-semibold text-ink`,children:a(`settings.themeStyle.${e}`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[10px] leading-relaxed text-ink-faint`,children:a(`settings.themeStyle.${e}Hint`)})]}),(0,X.jsx)(`span`,{className:`theme-style-check`,"aria-hidden":`true`,children:(0,X.jsx)(o,{icon:S})})]},e))})]}),l&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(yi,{})}),!l&&u&&(0,X.jsx)(no,{message:a(`settings.loadError`),retrying:d,onRetry:()=>void f(),t:a}),!l&&!u&&!me&&(0,X.jsx)(bi,{children:a(`settings.empty`)}),!l&&!u&&me&&c&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line glass-card p-3`,children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:a(`settings.quickConfig`)}),(0,X.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:a(`settings.backend`)}),(0,X.jsxs)(`select`,{value:Ka(M),disabled:v,onChange:e=>void ue(e.target.value),className:`h-8 min-w-44 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue disabled:opacity-40`,children:[Ka(M)?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:M?a(`settings.backendUnsupported`,{backend:M}):a(`settings.backendUnavailable`)}),Wa.map(e=>(0,X.jsx)(`option`,{value:e.value,children:a(e.label)},e.value))]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:a(`settings.model`)}),(0,X.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),placeholder:a(`settings.modelPlaceholder`),className:`h-8 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void de(),disabled:v,className:`h-8 shrink-0 rounded border border-line/70 px-2.5 text-xs font-medium text-ink-dim hover:border-blue/50 disabled:opacity-40`,children:a(`settings.applyModel`)})]}),b&&(0,X.jsx)(`div`,{role:C?`alert`:`status`,className:`mt-1.5 text-[10px] ${C?`text-err`:`text-ink-dim`}`,children:b})]}),(0,X.jsx)(Ba,{sid:e,config:c,onSaved:j}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:a(`settings.budgetTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:a(`settings.budgetHint`)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void fe(),disabled:oe,title:a(`settings.saveBudgets`),"aria-label":a(`settings.saveBudgets`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-semibold text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:oe?`…`:(0,X.jsx)(o,{icon:m})})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Ya.map(e=>(0,X.jsxs)(`label`,{className:`rounded border border-line/70 bg-bg/60 p-2`,children:[(0,X.jsx)(`span`,{className:`block text-[10px] text-ink-faint`,children:a(e.label)}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`number`,min:`0`,step:e.step,value:A[e.alias]??``,onChange:t=>le(n=>({...n,[e.alias]:t.target.value})),className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-sm text-ink outline-none`}),(0,X.jsx)(`span`,{className:`text-[9px] text-ink-faint`,children:a(e.unit)})]})]},e.alias))}),k?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:k}):null]}),(0,X.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface/50`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":p,"aria-controls":`config-advanced-settings`,onClick:()=>h(e=>!e),className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-bg/30`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-xs font-semibold text-ink`,children:a(`settings.advanced`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[10px] text-ink-faint`,children:a(`settings.advancedHint`)})]}),(0,X.jsx)(o,{icon:T,className:`text-xs text-ink-faint transition-transform ${p?`rotate-180`:``}`})]}),p&&(0,X.jsxs)(`div`,{id:`config-advanced-settings`,className:`space-y-4 border-t border-line/70 p-3`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:a(`settings.connection`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 text-[10px] sm:grid-cols-[100px_minmax(0,1fr)]`,children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:a(`settings.webApi`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:P.webApi}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:a(`settings.eventStream`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:P.eventStream}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:a(`settings.taskDaemon`)}),(0,X.jsx)(`span`,{className:`text-ink-dim`,children:a(`settings.taskDaemonValue`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:e=>void pe(e),className:`rounded-lg border border-blue/30 bg-blue/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-blue`,children:a(`settings.overrideTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:a(`settings.overrideHint`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,X.jsx)(`input`,{value:ee,onChange:e=>E(e.target.value),placeholder:a(`settings.namePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`input`,{value:te,onChange:e=>ne(e.target.value),placeholder:a(`settings.valuePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{disabled:re||!ee.trim()||!te.trim(),title:a(`settings.applyAdvanced`),"aria-label":a(`settings.applyAdvanced`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:re?`…`:(0,X.jsx)(o,{icon:S})})]}),D?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:D}):null]}),c.roles.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:a(`settings.rolesTitle`)}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:c.roles.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:e.role===`curator`?a(`settings.role.curator`):Bi(e.role,a)}),(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.backend_label})]}),(0,X.jsx)(`div`,{className:`mt-2 truncate font-mono text-[11px] text-ink-dim`,title:e.model,children:e.model}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:$a(e.model_source,a)}),e.reasoning_effort&&(0,X.jsx)(`span`,{className:`ml-auto shrink-0`,style:{color:ft(e.reasoning_effort)},children:to(e.reasoning_effort,a)})]}),Qa[e.role]&&(0,X.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-ink-faint`,children:a(Qa[e.role])})]},e.role))})]}),Object.keys(N).length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:a(`settings.rawConfig`)}),Object.entries(N).map(([e,t])=>(0,X.jsxs)(`div`,{className:`mt-3 first:mt-0`,children:[(0,X.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:a(Za[e])}),(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-line`,children:t.map((e,t)=>{let n=Xa[e.name],r=eo(e,a);return(0,X.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] ${t?`border-t border-line/60`:``}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink-dim`,children:a(n.label)}),(0,X.jsx)(`code`,{className:`mt-0.5 block break-all text-[9px] text-ink-faint`,children:e.name}),(0,X.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-ink-faint`,children:a(n.doc)})]}),(0,X.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,X.jsxs)(`div`,{className:`text-[11px] text-ink`,children:[r,r!==e.value&&(0,X.jsxs)(`code`,{className:`ml-1 text-[9px] text-ink-faint`,children:[`(`,e.value,`)`]})]}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:$a(e.source,a)})]})]},e.name)})})]},e))]}),(0,X.jsxs)(`p`,{className:`text-[10px] text-ink-faint`,children:[a(`settings.footer`),` `,(0,X.jsx)(`code`,{children:`argus-skill --config-help`}),`.`]})]})]})]})]})]})}function ao({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,refetch:s}=Cr(e,t),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(``);(0,F.useEffect)(()=>{t&&i!=null&&l(i)},[i,t]);let h=async()=>{if(!u){d(!0),p(``);try{await U.setIdentity(e,c),await s(),p(r(`identity.saved`))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,X.jsxs)(Na,{open:t,onClose:n,label:r(`identity.title`),width:`max-w-2xl`,children:[(0,X.jsx)(Pa,{title:r(`identity.title`),sub:r(`identity.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-5`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(yi,{})}),a?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),rows:12,className:`w-full resize-y rounded-lg border border-line bg-bg p-3 font-sans text-sm leading-relaxed text-ink outline-none focus:border-blue`,placeholder:r(`identity.placeholder`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:f}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),disabled:u||c===(i??``),title:r(`identity.save`),"aria-label":r(`identity.save`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:u?`…`:(0,X.jsx)(o,{icon:m})})]})]})]})]})}function oo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a}=wr(e,t),o=i??[];return(0,X.jsxs)(Na,{open:t,onClose:n,label:r(`transcript.title`),width:`max-w-2xl`,children:[(0,X.jsx)(Pa,{title:r(`transcript.title`),sub:r(`transcript.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(yi,{})}),!a&&o.length===0&&(0,X.jsx)(bi,{children:r(`transcript.empty`)}),o.map((e,t)=>{let n=e.role===`operator`;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[72px_minmax(0,1fr)] border-b border-line/50 py-2.5 last:border-b-0`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-wide ${n?`text-ink-faint`:`text-blue-sky`}`,children:n?r(`transcript.operator`):`argus`}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:ci(e.ts)})]}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink-dim`,children:e.text})]},t)})]})]})}function so({questions:e,backlog:t,onAnswer:n}){let{t:r}=Z(),i=_t(e,t);if(!i.length)return null;let a=i[0];return(0,X.jsxs)(`div`,{className:`mb-2 flex min-h-11 items-center gap-3 rounded-md border border-gold/40 bg-gold/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs font-medium text-gold`,children:a.title}),(0,X.jsx)(`div`,{className:`truncate text-xs text-ink-dim`,title:a.reason||a.question,children:a.reason||a.question})]}),i.length>1?(0,X.jsxs)(`span`,{className:`font-mono text-xs text-ink-faint`,children:[`+`,i.length-1]}):null,(0,X.jsx)(`button`,{onClick:n,className:`shrink-0 text-xs font-medium text-gold hover:text-gold-soft`,children:r(`pending.reviewRespond`)})]})}function co({reply:e,open:t,busy:n,onClose:r,onSubmit:i}){let{t:a}=Z(),o=(0,F.useMemo)(()=>e?.options[0]?.id??`custom`,[e]),[s,c]=(0,F.useState)(o),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(``);if((0,F.useEffect)(()=>{t&&(c(o),u(``),f(``))},[o,t,e?.id]),!e)return null;let p=e.options.length===0,m=e.options.find(e=>e.id===s),h=p?!!l.trim():!!(m&&(!m.requires_note||l.trim())),g=()=>{if(!n){if(!h){f(a(`decision.noteRequired`));return}f(``),i(p?`custom`:s,l.trim())}};return(0,X.jsxs)(Na,{open:t,onClose:n?()=>void 0:r,label:a(`decision.operator`),width:`max-w-2xl`,children:[(0,X.jsx)(Pa,{title:a(`decision.required`),sub:e.title}),(0,X.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[e.reason?(0,X.jsxs)(`section`,{className:`rounded-md border border-gold/30 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-gold`,children:a(`decision.whyBlocked`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.reason})]}):null,e.evidence.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:a(`decision.evidence`)}),(0,X.jsx)(`div`,{className:`space-y-2`,children:e.evidence.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line/70 bg-bg/40 p-2.5`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.label}),e.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:e.summary}):null,e.path?(0,X.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-blue-sky`,children:e.path}):null]},`${e.path}:${t}`))})]}):null,(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.question}),e.options.length?(0,X.jsx)(`div`,{className:`space-y-2`,children:e.options.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.id),f(``)},disabled:n,className:`w-full rounded-md border p-3 text-left ${s===e.id?`border-blue bg-blue/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-relaxed text-ink-dim`,children:e.description})]},e.id))}):null,p||m?.requires_note||l?(0,X.jsx)(`textarea`,{"data-autofocus":!0,value:l,onChange:e=>{u(e.target.value),f(``)},onKeyDown:e=>{oa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())},rows:3,disabled:n,placeholder:a(`decision.notePlaceholder`),className:`w-full resize-y rounded-lg border border-line bg-bg px-3 py-2 text-sm leading-relaxed text-ink outline-none focus:border-blue disabled:opacity-60`}):null,d?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-err`,children:d}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:a(`decision.resumeHint`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`rounded-md px-3 py-2 text-xs text-ink-dim hover:bg-bg disabled:opacity-50`,children:a(`decision.later`)}),(0,X.jsx)(`button`,{type:`button`,onClick:g,disabled:n,className:`rounded-md border border-blue/35 bg-blue/8 px-3 py-2 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-50`,children:a(n?`decision.applying`:p||s===`custom`?`decision.sendAnswer`:s===`stop`?`decision.stopCampaign`:`decision.useOption`)})]})]})]})]})}function lo({alert:e}){if(!e)return null;let t=e.tone===`block`,n=e.kind===`budget`;return(0,X.jsxs)(`div`,{className:`mx-3 mt-3 flex items-center gap-2.5 rounded-lg border px-3.5 py-2 text-[13px] ${t?`border-err/50 bg-err/10 text-err`:`border-warn/50 bg-warn/10 text-warn`}`,role:t?`alert`:`status`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-bold leading-none`,children:n?`$`:t?`!`:`i`}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-wide`,children:n?`budget alarm`:t?`action required`:`notice`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.text,children:e.text})]})}var uo=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),fo=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),po={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},mo=(0,F.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,F.createElement)(`svg`,{ref:c,...po,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:fo(`lucide`,i),...s},[...o.map(([e,t])=>(0,F.createElement)(e,t)),...Array.isArray(a)?a:[a]])),ho=(e,t)=>{let n=(0,F.forwardRef)(({className:n,...r},i)=>(0,F.createElement)(mo,{ref:i,iconNode:t,className:fo(`lucide-${uo(e)}`,n),...r}));return n.displayName=`${e}`,n},go=ho(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),_o=ho(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),vo=ho(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),yo=ho(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),bo=ho(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),xo=ho(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),So=ho(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),Co=ho(`Minimize2`,[[`polyline`,{points:`4 14 10 14 10 20`,key:`11kfnr`}],[`polyline`,{points:`20 10 14 10 14 4`,key:`rlmsce`}],[`line`,{x1:`14`,x2:`21`,y1:`10`,y2:`3`,key:`o5lafz`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),wo=ho(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),To=ho(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),Eo=ho(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Do=ho(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Oo({html:e,title:t,className:n=``,sid:r,path:i}){return r&&i?(0,X.jsx)(ko,{sid:r,path:i,html:e,title:t,className:n}):(0,X.jsx)(`iframe`,{title:t,srcDoc:e,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white ${n}`})}function ko({html:e,title:t,className:n,sid:r,path:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=M({queryKey:[`artifact-html`,r,i,e],queryFn:({signal:e})=>U.artifactPreview(r,i,e),enabled:!!(r&&i),staleTime:3e4,retry:1});return r&&i&&s.isPending?(0,X.jsx)(`div`,{className:`m-auto p-6 text-sm text-ink-dim`,role:`status`,children:o?`正在加载网页和配套资源…`:`Loading the website and its assets…`}):r&&i&&s.isError?(0,X.jsxs)(`div`,{className:`m-auto p-6 text-sm text-err`,role:`alert`,children:[o?`网页预览加载失败,请重试或下载文件。`:`Preview could not load. Retry or download the file.`,(0,X.jsx)(`button`,{type:`button`,className:`ml-3 underline`,onClick:()=>void s.refetch(),children:o?`重试`:`Retry`})]}):(0,X.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col ${n}`,children:[!!s.data?.warnings.length&&(0,X.jsx)(`p`,{className:`shrink-0 bg-warn/10 px-3 py-2 text-xs text-warn`,role:`status`,children:o?`部分配套资源无法加载,页面可能不完整。`:`Some linked assets are unavailable; the preview may be incomplete.`}),(0,X.jsx)(`iframe`,{title:t,srcDoc:s.data?.html??e,sandbox:`allow-scripts allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`})]})}function Ao(e){let t=e.trim();if(!t)return``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{try{return t.split(/\r?\n/).filter(Boolean).map(e=>JSON.parse(e)).map(e=>JSON.stringify(e,null,2)).join(` `)}catch{return e}}}function jo(e,t){let n=[],r=[],i=``,a=!1;for(let o=0;oe.some(e=>e.length>0))}function Mo({value:e}){return(0,X.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:Ao(e)||`(empty data)`})}function No({value:e,delimiter:t}){let n=jo(e,t).slice(0,200),r=n[0]??[];return(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4 scroll-thin`,children:n.length?(0,X.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:r.slice(0,40).map((e,t)=>(0,X.jsx)(`th`,{className:`border border-line/60 bg-surface px-2 py-1.5 font-semibold text-ink`,children:e},t))})}),(0,X.jsx)(`tbody`,{children:n.slice(1).map((e,t)=>(0,X.jsx)(`tr`,{children:r.slice(0,40).map((t,n)=>(0,X.jsx)(`td`,{className:`border border-line/50 px-2 py-1.5 align-top text-ink-dim`,children:e[n]??``},n))},t))})]}):(0,X.jsx)(`div`,{className:`text-sm text-ink-faint`,children:`(empty table)`})})}var Po=`/assets/pdf.worker.min-CHFwMXne.mjs`;function Fo(e,t,n,r){let i=Math.max(1,n-32)/Math.max(1,e),a=Math.max(1,r-32)/Math.max(1,t);return Math.max(.25,Math.min(2.5,i,a))}function Io({src:e,name:t,className:n=``,onPageOrientation:r}){let{locale:i}=Z(),a=i===`zh-CN`,o=(0,F.useRef)(null),s=(0,F.useRef)(null),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(1),[f,p]=(0,F.useState)(1),[m,h]=(0,F.useState)({width:0,height:0}),[g,_]=(0,F.useState)(!0),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(``);(0,F.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>h({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,F.useEffect)(()=>{let t=!0,n=new AbortController,r=null;return l(null),d(1),p(1),x(``),_(!0),Promise.all([fetch(e,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),ai(()=>import(`./pdf-DN4bD3_L.js`),[])]).then(async([e,n])=>{if(!t)return;n.GlobalWorkerOptions.workerSrc=Po,r=n.getDocument({data:new Uint8Array(e)});let i=await r.promise;t&&(l(i),_(!1))}).catch(e=>{t&&(_(!1),x(e instanceof Error?e.message:String(e)))}),()=>{t=!1,n.abort(),r?.destroy()}},[e]),(0,F.useEffect)(()=>{let e=o.current;if(!c||!e||m.width<=0||m.height<=0)return;let t=!1,n=null;return y(!0),x(``),c.getPage(u).then(e=>{if(t||!o.current)return;let i=e.getViewport({scale:1});r?.(i.width>i.height?`landscape`:`portrait`);let a=Fo(i.width,i.height,m.width,m.height),s=e.getViewport({scale:a*f}),c=o.current,l=c.getContext(`2d`,{alpha:!1});if(!l)throw Error(`Canvas rendering is unavailable`);let u=Math.min(window.devicePixelRatio||1,2);return c.width=Math.max(1,Math.floor(s.width*u)),c.height=Math.max(1,Math.floor(s.height*u)),c.style.width=`${s.width}px`,c.style.height=`${s.height}px`,n=e.render({canvas:c,canvasContext:l,viewport:s,transform:u===1?void 0:[u,0,0,u,0,0]}),n.promise}).then(()=>{t||y(!1)}).catch(e=>{t||e instanceof Error&&e.name===`RenderingCancelledException`||(y(!1),x(e instanceof Error?e.message:String(e)))}),()=>{t=!0,n?.cancel()}},[r,u,c,m.height,m.width,f]);let S=c?.numPages??0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-bg ${n}`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-2 border-b border-line/70 bg-panel px-3 py-1.5 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-ink`,title:t,children:t}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[a?`第`:`Page`,` `,u,` / `,S||`…`]}),(0,X.jsx)(`button`,{type:`button`,disabled:!c||u<=1,onClick:()=>d(e=>Math.max(1,e-1)),className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:a?`上一页`:`Previous`}),(0,X.jsx)(`button`,{type:`button`,disabled:!c||u>=S,onClick:()=>d(e=>Math.min(S,e+1)),className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:a?`下一页`:`Next`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":a?`缩小`:`Zoom out`,onClick:()=>p(e=>Math.max(.6,e-.15)),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`−`}),(0,X.jsxs)(`span`,{className:`w-10 text-center font-mono tabular-nums`,children:[Math.round(f*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":a?`放大`:`Zoom in`,onClick:()=>p(e=>Math.min(2.2,e+.15)),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`+`})]}),(0,X.jsxs)(`div`,{ref:s,className:`relative min-h-0 flex-1 overflow-auto bg-surface/60 p-4 scroll-thin`,children:[g?(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(yi,{})}):null,b?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm rounded border border-err/35 bg-err/5 p-4 text-center text-sm text-err`,children:[a?`PDF 无法渲染`:`Unable to render PDF`,` · `,b]}):null,b?null:(0,X.jsx)(`div`,{className:`flex min-h-full min-w-full items-center justify-center`,children:(0,X.jsx)(`canvas`,{ref:o,role:`img`,"aria-label":`${t} · ${a?`第`:`page`} ${u}`,className:`bg-white shadow-xl transition-opacity ${v||g?`opacity-45`:`opacity-100`}`})})]})]})}function Lo(e,t){return typeof e==`string`?e.trim().slice(0,t):``}function Ro(e,t){return Lo(e,t*2).replace(/!?(?:\[([^\]]+)\])\([^)]+\)/g,`$1`).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim().slice(0,t)}function zo(e){let t=Lo(e.completionId,300);if(!t)return null;let n=Lo(e.path,1e3);return{deliveryId:t,title:Ro(e.title,240)||`已完成的任务`,summary:Ro(e.summary,500),...n?{path:n}:{}}}function Bo(){return typeof window>`u`||window.parent===window?null:window.parent}function Vo(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=Lo(t.deliveryId,300);if(!n)return null;let r=Lo(t.path,1e3);return{deliveryId:n,title:Lo(t.title,240)||`Argus`,summary:Lo(t.summary,1e3),...r?{path:r}:{}}}function Ho(e){let t=Vo(e),n=Bo();return!t||!n?Promise.resolve(!1):(n.postMessage({type:`argus:notify-completion`,payload:t},`*`),Promise.resolve(!0))}function Uo(e){let t=Bo();t&&t.postMessage({type:`argus:large-preview`,payload:e},`*`)}function Wo(e){let t=Bo();if(!t)return()=>void 0;let n=n=>{if(n.source!==t||n.data?.type!==`argus:open-delivery`)return;let r=Vo(n.data.payload);r&&e(r)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function Go(e){let t=Bo();if(!t)return()=>void 0;let n=n=>{n.source===t&&n.data?.type===`argus:new-chat`&&e()};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function Ko(){if(typeof document>`u`)return()=>void 0;let e=Bo();if(!e)return()=>void 0;let t=t=>{if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey)return;let n=t.target?.closest(`a[href]`);if(!n)return;let r;try{r=new URL(n.href,window.location.href)}catch{return}r.origin===window.location.origin||![`http:`,`https:`].includes(r.protocol)||(t.preventDefault(),e.postMessage({type:`argus:open-external`,payload:r.toString()},`*`))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)}function qo(e){return e.kind===`markdown`||e.mime?.split(`;`,1)[0].trim().toLowerCase()===`text/markdown`||/\.(?:md|markdown)$/i.test(e.name||e.path||``)}function Jo({sid:e,path:t,onClose:n,delivery:r,deliveries:i=[],onSelectDelivery:a,onSelectPath:o}){let{t:s,locale:c}=Z(),l=c===`zh-CN`,u=r?Qr(r):[],d=Er(e,t),f=d.data,p=f?qo(f):!1,[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(`portrait`),w=f?.kind===`pdf`||t?.toLowerCase().endsWith(`.pdf`)===!0;(0,F.useEffect)(()=>{if(!(!t||!w))return Uo(!0),()=>Uo(!1)},[t,w]),(0,F.useEffect)(()=>{if(C(`portrait`),h(null),_(``),!e||!t||!f||![`image`,`pdf`,`audio`,`video`].includes(f.kind))return;let n=!0,r=``,i=new AbortController;return U.artifactBlob(e,t,!1,i.signal).then(e=>{n&&(r=URL.createObjectURL(e),h(r))},e=>n&&_(e.message)),()=>{n=!1,i.abort(),r&&URL.revokeObjectURL(r)}},[e,t,f?.kind]);let T=async(n=!1)=>{if(!(!e||!t||!f)){y(!0),_(``);try{let r=n?await U.artifactBundle(e,t):await U.artifactBlob(e,t,!0),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n?`${f.name.replace(/\.html?$/i,``)}-website.zip`:f.name,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}catch(e){_(e.message)}finally{y(!1)}}};return(0,X.jsxs)(Na,{open:!!(t||r),onClose:n,label:r?l?`交付成果`:`Delivery`:s(`artifact.preview`),width:r?b?`max-w-none`:`max-w-6xl`:w?`max-w-none`:`max-w-5xl`,viewport:r?b:w,showClose:!1,style:r?{height:b?`100dvh`:`min(92dvh, 960px)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:w?{maxWidth:S===`portrait`?`min(96vw, 76dvh)`:`min(96vw, 145dvh)`}:void 0,children:[r&&!b&&(0,X.jsxs)(`header`,{className:`delivery-header`,children:[(0,X.jsxs)(`div`,{className:`delivery-heading`,children:[(0,X.jsx)(`span`,{className:`delivery-mark`,children:(0,X.jsx)(wo,{size:22})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`p`,{children:[`DELIVERY · `,l?`交付成果`:`Your results`]}),(0,X.jsx)(`h2`,{children:l?`成果已就绪`:`Ready to explore`})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`delivery-return`,"aria-label":l?`关闭交付弹窗`:`Close delivery`,children:[l?`返回地图`:`Back to map`,` ×`]})]}),i.length>1?(0,X.jsx)(`select`,{"aria-label":l?`选择交付任务`:`Choose delivery`,className:`delivery-task-select`,value:r.delivery_id,onChange:e=>{let t=i.find(t=>t.delivery_id===e.target.value);t&&a?.(t)},children:i.map(e=>(0,X.jsx)(`option`,{value:e.delivery_id,children:e.title},e.delivery_id))}):(0,X.jsx)(`p`,{className:`delivery-task-title`,title:r.title,children:r.title}),(0,X.jsxs)(`div`,{className:`delivery-facts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(yo,{size:13}),[`done`,`passed`,`approved`,`accepted`].includes(r.review_status)?l?`审核通过`:`Review passed`:l?`已交付`:`Delivered`]}),(0,X.jsxs)(`span`,{children:[u.length,` `,l?`个文件`:`files`]})]}),r.summary&&(0,X.jsxs)(`details`,{className:`delivery-summary`,children:[(0,X.jsx)(`summary`,{children:l?`查看成果说明`:`Result summary`}),(0,X.jsx)(`p`,{children:$r(r.summary)})]})]}),!b&&!!u.length&&(0,X.jsx)(`nav`,{className:`delivery-files`,"aria-label":l?`交付文件`:`Delivery files`,children:u.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.path,onClick:()=>o?.(e.path),title:e.path,children:[(0,X.jsx)(`span`,{children:e.path.split(`/`).at(-1)}),r?.primary_target?.path===e.path&&(0,X.jsx)(`small`,{children:l?`主要成果`:`Main result`})]},e.path))}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-line px-4 py-3 sm:px-5 ${t?``:`hidden`}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-mono text-sm font-semibold text-ink`,title:f?.storage_path??f?.path??t??``,children:f?.name??t??s(`artifact.title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-ink-faint`,children:f?`${f.kind} · ${di(f.size)} · ${f.mime}`:s(`artifact.approvedEvidence`)})]}),r&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>x(e=>!e),"aria-label":b?l?`收起预览`:`Exit full screen`:l?`全屏预览`:`Full screen preview`,title:l?`切换全屏预览`:`Toggle full screen preview`,className:`shrink-0 rounded-md border border-line p-2 text-ink-dim`,children:b?(0,X.jsx)(Co,{size:16}):(0,X.jsx)(So,{size:16})}),f?.kind===`html`&&(0,X.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>void T(!0),className:`shrink-0 rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-2 text-xs text-blue-sky disabled:opacity-50`,children:l?`下载完整网页`:`Download website`}),(0,X.jsx)(`button`,{type:`button`,disabled:!f||v,onClick:()=>void T(),className:`rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-1.5 text-xs text-blue-sky transition-colors hover:bg-blue-deep/20 disabled:cursor-wait disabled:opacity-50`,children:s(v?`artifact.downloading`:`artifact.download`)}),(!r||b)&&(0,X.jsx)(`button`,{type:`button`,"aria-label":s(`artifact.close`),onClick:n,className:`rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink`,children:`×`})]}),(0,X.jsxs)(`div`,{className:r?`flex min-h-0 flex-1 flex-col overflow-auto bg-bg/40 p-2 sm:p-3`:w?`flex min-h-0 flex-1 flex-col overflow-hidden bg-bg/40`:`flex min-h-64 max-h-[72vh] flex-col overflow-x-hidden overflow-y-auto bg-bg/40 p-3 scroll-thin sm:p-4`,children:[!t&&r&&(0,X.jsx)(`p`,{className:`m-auto p-6 text-sm text-ink-dim`,children:$r(r.summary)}),d.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(yi,{})}):null,d.isError?(0,X.jsxs)(`div`,{className:`m-auto text-sm text-err`,children:[s(`artifact.unavailable`),` · `,d.error.message]}):null,f?.why&&!w&&!r?(0,X.jsxs)(`div`,{className:`mb-3 rounded-md border border-line bg-surface px-3 py-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-ink-faint`,children:`Reviewer:`}),f.why]}):null,f?.kind===`text`&&!p?(0,X.jsxs)(`pre`,{className:`min-h-52 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:[f.preview||s(`artifact.empty`),f.truncated?`\n\n… ${s(`artifact.truncated`)}`:``]}):null,f&&p?(0,X.jsx)(`div`,{className:`min-h-52 overflow-auto rounded-lg border border-line bg-bg p-4 text-sm text-ink-dim scroll-thin`,children:(0,X.jsx)(Oi,{artifacts:u.map(e=>({path:e.path})),onOpenArtifact:o,children:f.preview||s(`artifact.empty`)})}):null,f?.kind===`json`?(0,X.jsx)(Mo,{value:f.preview||``}):null,f?.kind===`table`?(0,X.jsx)(No,{value:f.preview||``,delimiter:f.name.endsWith(`.tsv`)?` `:`,`}):null,f?.kind===`html`?(0,X.jsx)(`div`,{className:`flex flex-1 overflow-hidden rounded-lg border border-line ${r?`min-h-0`:`min-h-[60vh]`}`,children:(0,X.jsx)(Oo,{sid:e,path:t,html:f.preview||``,title:`HTML preview: ${f.name}`})}):null,f?.kind===`image`&&m?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-bg/50`,children:(0,X.jsx)(`img`,{src:m,alt:f.why||f.name,className:`max-h-[62vh] max-w-full object-contain`})}):null,f?.kind===`pdf`&&m?(0,X.jsx)(Io,{src:m,name:f.name,className:`min-h-0 overflow-hidden`,onPageOrientation:C}):null,f?.kind===`audio`&&m?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:m,className:`w-full`})}):null,f?.kind===`video`&&m?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-black`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:m,className:`max-h-[62vh] max-w-full`})}):null,f&&[`image`,`pdf`,`audio`,`video`].includes(f.kind)&&!m&&!g?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(yi,{})}):null,f?.kind===`binary`?(0,X.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-ink-dim`,children:s(`artifact.noPreview`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:s(`artifact.downloadHint`)})]}):null,g?(0,X.jsx)(`div`,{className:`mt-3 text-center text-xs text-err`,children:g}):null]})]})}var Yo=`__argus_live_progress__`,Xo=new Set([`framed`,`grounding`,`queued`,`running`,`in_progress`,`working`]),Zo=new Set([`complete`,`completed`,`done`,`success`]);function Qo(e){return Zo.has(String(e?.mission.status||``).toLowerCase())}function $o(e){return(e??[]).filter(e=>e.source===`manager_live`)}function es(e){return $o(e).filter(e=>e.exists)[0]??null}function ts(e){let t=e??[],n={markdown:0,pdf:1,html:2,text:3,table:4,json:5,image:6,video:7,audio:8,binary:9},r=t.filter(e=>e.exists&&e.source===`delivery`),i=t.filter(e=>e.exists&&e.source===`manager_live`),a=t.filter(e=>e.exists&&e.source!==`manager_live`&&e.source!==`delivery`);return a.length||r.length?[...r,...[...a].sort((e,t)=>(n[e.kind]??99)-(n[t.kind]??99)),...i]:i}function ns(e){return ts(e).find(e=>e.exists)??null}function rs(e){let t=ts(e);return t.find(e=>e.source===`delivery`)??t.find(e=>e.source!==`manager_live`)??t[0]??null}function is(e){let t=e.path.split(`/`);return t[t.length-1]||e.path}function as(e,t){if(e){let n=String(e.mission.status||``).toLowerCase();if(Xo.has(n))return Yo;let r=e.delivery?.primary_target?.path;if(r)return r;if(Qo(e))return rs(t)?.path??`__argus_live_progress__`;let i=es(t);return i?i.path:Yo}return ns(t)?.path??``}var os={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`};function ss(e){let t=String(e.agent_layer??e.actor??``);if(t===`main`)return`engineer`;if(t)return t;let n=String(e.type??``);return n.startsWith(`round.review`)||n.startsWith(`reviewer`)?`reviewer`:n.startsWith(`life.planner`)?`planner`:n.startsWith(`life.manager`)||n.startsWith(`manager`)?`manager`:n.startsWith(`engineer`)||n.startsWith(`round.`)?`engineer`:``}function cs(e,t=[]){if(Qo(e))return null;let n=String(e?.active_role??``);if(!n)return null;let r=e?.roles.find(e=>e.role===n),i=``;for(let e=t.length-1;e>=0;--e){let r=t[e];if(ss(r)!==n||String(r.kind??``)===`reasoning`)continue;let a=String(r.text??r.action_summary??``).trim();if(!(!a||a.startsWith(`{`))){i=a.split(` +`&&o++,r.push(i),n.push(r),r=[],i=``):i+=s}return(i||r.length)&&(r.push(i),n.push(r)),n.filter(e=>e.some(e=>e.length>0))}function Mo({value:e}){return(0,X.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:Ao(e)||`(empty data)`})}function No({value:e,delimiter:t}){let n=jo(e,t).slice(0,200),r=n[0]??[];return(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4 scroll-thin`,children:n.length?(0,X.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:r.slice(0,40).map((e,t)=>(0,X.jsx)(`th`,{className:`border border-line/60 bg-surface px-2 py-1.5 font-semibold text-ink`,children:e},t))})}),(0,X.jsx)(`tbody`,{children:n.slice(1).map((e,t)=>(0,X.jsx)(`tr`,{children:r.slice(0,40).map((t,n)=>(0,X.jsx)(`td`,{className:`border border-line/50 px-2 py-1.5 align-top text-ink-dim`,children:e[n]??``},n))},t))})]}):(0,X.jsx)(`div`,{className:`text-sm text-ink-faint`,children:`(empty table)`})})}var Po=`/assets/pdf.worker.min-CHFwMXne.mjs`;function Fo(e,t,n,r){let i=Math.max(1,n-32)/Math.max(1,e),a=Math.max(1,r-32)/Math.max(1,t);return Math.max(.25,Math.min(2.5,i,a))}function Io({src:e,name:t,className:n=``,onPageOrientation:r}){let{locale:i}=Z(),a=i===`zh-CN`,o=(0,F.useRef)(null),s=(0,F.useRef)(null),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(1),[f,p]=(0,F.useState)(1),[m,h]=(0,F.useState)({width:0,height:0}),[g,_]=(0,F.useState)(!0),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(``);(0,F.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>h({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,F.useEffect)(()=>{let t=!0,n=new AbortController,r=null;return l(null),d(1),p(1),x(``),_(!0),Promise.all([fetch(e,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),ai(()=>import(`./pdf-Bit9sP4D.js`),[])]).then(async([e,n])=>{if(!t)return;n.GlobalWorkerOptions.workerSrc=Po,r=n.getDocument({data:new Uint8Array(e)});let i=await r.promise;t&&(l(i),_(!1))}).catch(e=>{t&&(_(!1),x(e instanceof Error?e.message:String(e)))}),()=>{t=!1,n.abort(),r?.destroy()}},[e]),(0,F.useEffect)(()=>{let e=o.current;if(!c||!e||m.width<=0||m.height<=0)return;let t=!1,n=null;return y(!0),x(``),c.getPage(u).then(e=>{if(t||!o.current)return;let i=e.getViewport({scale:1});r?.(i.width>i.height?`landscape`:`portrait`);let a=Fo(i.width,i.height,m.width,m.height),s=e.getViewport({scale:a*f}),c=o.current,l=c.getContext(`2d`,{alpha:!1});if(!l)throw Error(`Canvas rendering is unavailable`);let u=Math.min(window.devicePixelRatio||1,2);return c.width=Math.max(1,Math.floor(s.width*u)),c.height=Math.max(1,Math.floor(s.height*u)),c.style.width=`${s.width}px`,c.style.height=`${s.height}px`,n=e.render({canvas:c,canvasContext:l,viewport:s,transform:u===1?void 0:[u,0,0,u,0,0]}),n.promise}).then(()=>{t||y(!1)}).catch(e=>{t||e instanceof Error&&e.name===`RenderingCancelledException`||(y(!1),x(e instanceof Error?e.message:String(e)))}),()=>{t=!0,n?.cancel()}},[r,u,c,m.height,m.width,f]);let S=c?.numPages??0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-bg ${n}`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-2 border-b border-line/70 bg-panel px-3 py-1.5 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-ink`,title:t,children:t}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[a?`第`:`Page`,` `,u,` / `,S||`…`]}),(0,X.jsx)(`button`,{type:`button`,disabled:!c||u<=1,onClick:()=>d(e=>Math.max(1,e-1)),className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:a?`上一页`:`Previous`}),(0,X.jsx)(`button`,{type:`button`,disabled:!c||u>=S,onClick:()=>d(e=>Math.min(S,e+1)),className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:a?`下一页`:`Next`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":a?`缩小`:`Zoom out`,onClick:()=>p(e=>Math.max(.6,e-.15)),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`−`}),(0,X.jsxs)(`span`,{className:`w-10 text-center font-mono tabular-nums`,children:[Math.round(f*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":a?`放大`:`Zoom in`,onClick:()=>p(e=>Math.min(2.2,e+.15)),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`+`})]}),(0,X.jsxs)(`div`,{ref:s,className:`relative min-h-0 flex-1 overflow-auto bg-surface/60 p-4 scroll-thin`,children:[g?(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(yi,{})}):null,b?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm rounded border border-err/35 bg-err/5 p-4 text-center text-sm text-err`,children:[a?`PDF 无法渲染`:`Unable to render PDF`,` · `,b]}):null,b?null:(0,X.jsx)(`div`,{className:`flex min-h-full min-w-full items-center justify-center`,children:(0,X.jsx)(`canvas`,{ref:o,role:`img`,"aria-label":`${t} · ${a?`第`:`page`} ${u}`,className:`bg-white shadow-xl transition-opacity ${v||g?`opacity-45`:`opacity-100`}`})})]})]})}function Lo(e,t){return typeof e==`string`?e.trim().slice(0,t):``}function Ro(e,t){return Lo(e,t*2).replace(/!?(?:\[([^\]]+)\])\([^)]+\)/g,`$1`).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim().slice(0,t)}function zo(e){let t=Lo(e.completionId,300);if(!t)return null;let n=Lo(e.path,1e3);return{deliveryId:t,title:Ro(e.title,240)||`已完成的任务`,summary:Ro(e.summary,500),...n?{path:n}:{}}}function Bo(){return typeof window>`u`||window.parent===window?null:window.parent}function Vo(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=Lo(t.deliveryId,300);if(!n)return null;let r=Lo(t.path,1e3);return{deliveryId:n,title:Lo(t.title,240)||`Argus`,summary:Lo(t.summary,1e3),...r?{path:r}:{}}}function Ho(e){let t=Vo(e),n=Bo();return!t||!n?Promise.resolve(!1):(n.postMessage({type:`argus:notify-completion`,payload:t},`*`),Promise.resolve(!0))}function Uo(e){let t=Bo();t&&t.postMessage({type:`argus:large-preview`,payload:e},`*`)}function Wo(e){let t=Bo();if(!t)return()=>void 0;let n=n=>{if(n.source!==t||n.data?.type!==`argus:open-delivery`)return;let r=Vo(n.data.payload);r&&e(r)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function Go(e){let t=Bo();if(!t)return()=>void 0;let n=n=>{n.source===t&&n.data?.type===`argus:new-chat`&&e()};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function Ko(){if(typeof document>`u`)return()=>void 0;let e=Bo();if(!e)return()=>void 0;let t=t=>{if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey)return;let n=t.target?.closest(`a[href]`);if(!n)return;let r;try{r=new URL(n.href,window.location.href)}catch{return}r.origin===window.location.origin||![`http:`,`https:`].includes(r.protocol)||(t.preventDefault(),e.postMessage({type:`argus:open-external`,payload:r.toString()},`*`))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)}function qo(e){return e.kind===`markdown`||e.mime?.split(`;`,1)[0].trim().toLowerCase()===`text/markdown`||/\.(?:md|markdown)$/i.test(e.name||e.path||``)}function Jo({sid:e,path:t,onClose:n,delivery:r,deliveries:i=[],onSelectDelivery:a,onSelectPath:o}){let{t:s,locale:c}=Z(),l=c===`zh-CN`,u=r?Qr(r):[],d=Er(e,t),f=d.data,p=f?qo(f):!1,[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(`portrait`),w=f?.kind===`pdf`||t?.toLowerCase().endsWith(`.pdf`)===!0;(0,F.useEffect)(()=>{if(!(!t||!w))return Uo(!0),()=>Uo(!1)},[t,w]),(0,F.useEffect)(()=>{if(C(`portrait`),h(null),_(``),!e||!t||!f||![`image`,`pdf`,`audio`,`video`].includes(f.kind))return;let n=!0,r=``,i=new AbortController;return U.artifactBlob(e,t,!1,i.signal).then(e=>{n&&(r=URL.createObjectURL(e),h(r))},e=>n&&_(e.message)),()=>{n=!1,i.abort(),r&&URL.revokeObjectURL(r)}},[e,t,f?.kind]);let T=async(n=!1)=>{if(!(!e||!t||!f)){y(!0),_(``);try{let r=n?await U.artifactBundle(e,t):await U.artifactBlob(e,t,!0),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n?`${f.name.replace(/\.html?$/i,``)}-website.zip`:f.name,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}catch(e){_(e.message)}finally{y(!1)}}};return(0,X.jsxs)(Na,{open:!!(t||r),onClose:n,label:r?l?`交付成果`:`Delivery`:s(`artifact.preview`),width:r?b?`max-w-none`:`max-w-6xl`:w?`max-w-none`:`max-w-5xl`,viewport:r?b:w,showClose:!1,style:r?{height:b?`100dvh`:`min(92dvh, 960px)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:w?{maxWidth:S===`portrait`?`min(96vw, 76dvh)`:`min(96vw, 145dvh)`}:void 0,children:[r&&!b&&(0,X.jsxs)(`header`,{className:`delivery-header`,children:[(0,X.jsxs)(`div`,{className:`delivery-heading`,children:[(0,X.jsx)(`span`,{className:`delivery-mark`,children:(0,X.jsx)(wo,{size:22})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`p`,{children:[`DELIVERY · `,l?`交付成果`:`Your results`]}),(0,X.jsx)(`h2`,{children:l?`成果已就绪`:`Ready to explore`})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`delivery-return`,"aria-label":l?`关闭交付弹窗`:`Close delivery`,children:[l?`返回地图`:`Back to map`,` ×`]})]}),i.length>1?(0,X.jsx)(`select`,{"aria-label":l?`选择交付任务`:`Choose delivery`,className:`delivery-task-select`,value:r.delivery_id,onChange:e=>{let t=i.find(t=>t.delivery_id===e.target.value);t&&a?.(t)},children:i.map(e=>(0,X.jsx)(`option`,{value:e.delivery_id,children:e.title},e.delivery_id))}):(0,X.jsx)(`p`,{className:`delivery-task-title`,title:r.title,children:r.title}),(0,X.jsxs)(`div`,{className:`delivery-facts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(yo,{size:13}),[`done`,`passed`,`approved`,`accepted`].includes(r.review_status)?l?`审核通过`:`Review passed`:l?`已交付`:`Delivered`]}),(0,X.jsxs)(`span`,{children:[u.length,` `,l?`个文件`:`files`]})]}),r.summary&&(0,X.jsxs)(`details`,{className:`delivery-summary`,children:[(0,X.jsx)(`summary`,{children:l?`查看成果说明`:`Result summary`}),(0,X.jsx)(`p`,{children:$r(r.summary)})]})]}),!b&&!!u.length&&(0,X.jsx)(`nav`,{className:`delivery-files`,"aria-label":l?`交付文件`:`Delivery files`,children:u.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.path,onClick:()=>o?.(e.path),title:e.path,children:[(0,X.jsx)(`span`,{children:e.path.split(`/`).at(-1)}),r?.primary_target?.path===e.path&&(0,X.jsx)(`small`,{children:l?`主要成果`:`Main result`})]},e.path))}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-line px-4 py-3 sm:px-5 ${t?``:`hidden`}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-mono text-sm font-semibold text-ink`,title:f?.storage_path??f?.path??t??``,children:f?.name??t??s(`artifact.title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-ink-faint`,children:f?`${f.kind} · ${di(f.size)} · ${f.mime}`:s(`artifact.approvedEvidence`)})]}),r&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>x(e=>!e),"aria-label":b?l?`收起预览`:`Exit full screen`:l?`全屏预览`:`Full screen preview`,title:l?`切换全屏预览`:`Toggle full screen preview`,className:`shrink-0 rounded-md border border-line p-2 text-ink-dim`,children:b?(0,X.jsx)(Co,{size:16}):(0,X.jsx)(So,{size:16})}),f?.kind===`html`&&(0,X.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>void T(!0),className:`shrink-0 rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-2 text-xs text-blue-sky disabled:opacity-50`,children:l?`下载完整网页`:`Download website`}),(0,X.jsx)(`button`,{type:`button`,disabled:!f||v,onClick:()=>void T(),className:`rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-1.5 text-xs text-blue-sky transition-colors hover:bg-blue-deep/20 disabled:cursor-wait disabled:opacity-50`,children:s(v?`artifact.downloading`:`artifact.download`)}),(!r||b)&&(0,X.jsx)(`button`,{type:`button`,"aria-label":s(`artifact.close`),onClick:n,className:`rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink`,children:`×`})]}),(0,X.jsxs)(`div`,{className:r?`flex min-h-0 flex-1 flex-col overflow-auto bg-bg/40 p-2 sm:p-3`:w?`flex min-h-0 flex-1 flex-col overflow-hidden bg-bg/40`:`flex min-h-64 max-h-[72vh] flex-col overflow-x-hidden overflow-y-auto bg-bg/40 p-3 scroll-thin sm:p-4`,children:[!t&&r&&(0,X.jsx)(`p`,{className:`m-auto p-6 text-sm text-ink-dim`,children:$r(r.summary)}),d.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(yi,{})}):null,d.isError?(0,X.jsxs)(`div`,{className:`m-auto text-sm text-err`,children:[s(`artifact.unavailable`),` · `,d.error.message]}):null,f?.why&&!w&&!r?(0,X.jsxs)(`div`,{className:`mb-3 rounded-md border border-line bg-surface px-3 py-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-ink-faint`,children:`Reviewer:`}),f.why]}):null,f?.kind===`text`&&!p?(0,X.jsxs)(`pre`,{className:`min-h-52 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:[f.preview||s(`artifact.empty`),f.truncated?`\n\n… ${s(`artifact.truncated`)}`:``]}):null,f&&p?(0,X.jsx)(`div`,{className:`min-h-52 overflow-auto rounded-lg border border-line bg-bg p-4 text-sm text-ink-dim scroll-thin`,children:(0,X.jsx)(Oi,{artifacts:u.map(e=>({path:e.path})),onOpenArtifact:o,children:f.preview||s(`artifact.empty`)})}):null,f?.kind===`json`?(0,X.jsx)(Mo,{value:f.preview||``}):null,f?.kind===`table`?(0,X.jsx)(No,{value:f.preview||``,delimiter:f.name.endsWith(`.tsv`)?` `:`,`}):null,f?.kind===`html`?(0,X.jsx)(`div`,{className:`flex flex-1 overflow-hidden rounded-lg border border-line ${r?`min-h-0`:`min-h-[60vh]`}`,children:(0,X.jsx)(Oo,{sid:e,path:t,html:f.preview||``,title:`HTML preview: ${f.name}`})}):null,f?.kind===`image`&&m?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-bg/50`,children:(0,X.jsx)(`img`,{src:m,alt:f.why||f.name,className:`max-h-[62vh] max-w-full object-contain`})}):null,f?.kind===`pdf`&&m?(0,X.jsx)(Io,{src:m,name:f.name,className:`min-h-0 overflow-hidden`,onPageOrientation:C}):null,f?.kind===`audio`&&m?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:m,className:`w-full`})}):null,f?.kind===`video`&&m?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-black`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:m,className:`max-h-[62vh] max-w-full`})}):null,f&&[`image`,`pdf`,`audio`,`video`].includes(f.kind)&&!m&&!g?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(yi,{})}):null,f?.kind===`binary`?(0,X.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-ink-dim`,children:s(`artifact.noPreview`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:s(`artifact.downloadHint`)})]}):null,g?(0,X.jsx)(`div`,{className:`mt-3 text-center text-xs text-err`,children:g}):null]})]})}var Yo=`__argus_live_progress__`,Xo=new Set([`framed`,`grounding`,`queued`,`running`,`in_progress`,`working`]),Zo=new Set([`complete`,`completed`,`done`,`success`]);function Qo(e){return Zo.has(String(e?.mission.status||``).toLowerCase())}function $o(e){return(e??[]).filter(e=>e.source===`manager_live`)}function es(e){return $o(e).filter(e=>e.exists)[0]??null}function ts(e){let t=e??[],n={markdown:0,pdf:1,html:2,text:3,table:4,json:5,image:6,video:7,audio:8,binary:9},r=t.filter(e=>e.exists&&e.source===`delivery`),i=t.filter(e=>e.exists&&e.source===`manager_live`),a=t.filter(e=>e.exists&&e.source!==`manager_live`&&e.source!==`delivery`);return a.length||r.length?[...r,...[...a].sort((e,t)=>(n[e.kind]??99)-(n[t.kind]??99)),...i]:i}function ns(e){return ts(e).find(e=>e.exists)??null}function rs(e){let t=ts(e);return t.find(e=>e.source===`delivery`)??t.find(e=>e.source!==`manager_live`)??t[0]??null}function is(e){let t=e.path.split(`/`);return t[t.length-1]||e.path}function as(e,t){if(e){let n=String(e.mission.status||``).toLowerCase();if(Xo.has(n))return Yo;let r=e.delivery?.primary_target?.path;if(r)return r;if(Qo(e))return rs(t)?.path??`__argus_live_progress__`;let i=es(t);return i?i.path:Yo}return ns(t)?.path??``}var os={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`};function ss(e){let t=String(e.agent_layer??e.actor??``);if(t===`main`)return`engineer`;if(t)return t;let n=String(e.type??``);return n.startsWith(`round.review`)||n.startsWith(`reviewer`)?`reviewer`:n.startsWith(`life.planner`)?`planner`:n.startsWith(`life.manager`)||n.startsWith(`manager`)?`manager`:n.startsWith(`engineer`)||n.startsWith(`round.`)?`engineer`:``}function cs(e,t=[]){if(Qo(e))return null;let n=String(e?.active_role??``);if(!n)return null;let r=e?.roles.find(e=>e.role===n),i=``;for(let e=t.length-1;e>=0;--e){let r=t[e];if(ss(r)!==n||String(r.kind??``)===`reasoning`)continue;let a=String(r.text??r.action_summary??``).trim();if(!(!a||a.startsWith(`{`))){i=a.split(` `)[0].slice(0,240);break}}return{role:n,roleLabel:os[n]??n,label:r?.label||`Working`,detail:i}}function ls(e){let t=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),n=e.dag.filter(e=>[`done`,`completed`].includes(e.status)).length,r=e.dag.length,i=`Awaiting Planner`;return e.mission.status===`idle`?i=`Ready for a new mission`:e.mission.status===`complete`&&(i=`Mission complete`),{title:Cn(t?.title||e.mission.title||i),dagProgress:r>0?`${n} / ${r} complete`:`Not planned`}}function us({view:e,liveStatus:t,artifacts:n=[],onOpenArtifact:r}){let{t:i}=Z(),a=ls(e),o=[...n].filter(e=>e.exists&&e.source!==`manager_live`).sort((e,t)=>Number(t.mtime??0)-Number(e.mtime??0)).slice(0,4),s=e.timeline.slice(-6).reverse(),c=e.delivery,l=e=>e===`done`?`text-ok`:[`running`,`in_progress`,`claimed`].includes(e)?`text-blue-sky`:[`failed`,`blocked`,`rejected`].includes(e)?`text-err`:`text-ink-faint`;return(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 text-sm text-ink-dim scroll-thin`,children:[c?(0,X.jsxs)(`section`,{className:`mb-4 rounded-lg border border-ok/35 bg-ok/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:c.kind===`submission_certified`?`交付已认证`:`已完成`}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:c.title}),c.summary?(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-ink-dim`,children:c.summary}):null,c.primary_target?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(c.primary_target.path),title:n.find(e=>e.path===c.primary_target.path)?.storage_path||c.primary_target.path,className:`mt-3 rounded border border-ok/40 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-ok hover:border-ok`,children:[`打开成果 · `,c.primary_target.label||c.primary_target.path]}):null]}):null,(0,X.jsxs)(`section`,{className:`rounded-lg border border-blue-deep/30 bg-blue-deep/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-blue-sky`,children:i(`research.currentWork`)}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:a.title}),t?.detail?(0,X.jsx)(`p`,{className:`mt-2 leading-6 text-ink-dim`,children:t.detail}):null,(0,X.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 text-xs`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.stage`)}),(0,X.jsx)(`div`,{className:`mt-1 font-medium capitalize text-blue-sky`,children:e.stage.label||e.stage.id||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.campaign`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:wn(e.mission.campaign_elapsed_seconds)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.round`)}),(0,X.jsxs)(`div`,{className:`mt-1 font-mono text-ink`,children:[e.round.current||`—`,e.round.max?` / ${e.round.max}`:``]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`research.dagProgress`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:a.dagProgress})]})]})]}),(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`mission.researchDag`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.dag.map(e=>(0,X.jsx)(`div`,{className:`rounded-md border border-line/60 bg-panel px-3 py-2.5`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-xs ${l(e.status)}`,children:e.status===`done`?`✓`:[`running`,`in_progress`,`claimed`].includes(e.status)?`●`:`○`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium leading-5 text-ink`,children:e.title}),(0,X.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] ${l(e.status)}`,children:e.status})]})]})},e.id))})]}),o.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.verifiedOutputs`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),title:e.storage_path||e.path,className:`rounded border border-line/70 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-blue-sky hover:border-blue/60`,children:[is(e),` ↗`]},e.path))})]}):null,s.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.recentMilestones`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-line/70 pl-3`,children:s.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.title}),e.detail?(0,X.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-ink-faint`,children:e.detail}):null]},e.id))})]}):null]})}function ds({sid:e,artifacts:t,error:n=!1,onExpand:r,className:i=``,embedded:a=!1,onCollapse:s,missionView:c,activityEvents:l=[],requestedPath:u,requestedPathToken:d}){let{t:f,locale:p}=Z(),m=(0,F.useMemo)(()=>ts(t),[t]),h=(0,F.useMemo)(()=>ns(t),[t]),g=Qo(c),_=(0,F.useMemo)(()=>{if(!g)return null;let e=c?.delivery?.primary_target?.path;return m.find(t=>t.path===e&&t.exists)??rs(t)},[t,g,c?.delivery?.primary_target?.path,m]),[v,y]=(0,F.useState)(null);(0,F.useEffect)(()=>{y(g&&_?_.path:null)},[g,_?.path,c?.mission.id,e]),(0,F.useEffect)(()=>{if(!u)return;let e=m.find(e=>e.path===u&&e.exists);e&&y(e.path)},[m,u,d]);let b=v??as(c,t),S=b===Yo,C=S?null:m.find(e=>e.path===b)??(g?_:h),w=Er(e,C?.exists?C.path:null,C?.mtime??null),T=w.data,ee=T?qo(T):!1,[E,te]=(0,F.useState)(null),[ne,re]=(0,F.useState)(``),[ie,D]=(0,F.useState)(!1),[ae,oe]=(0,F.useState)(``),O=(0,F.useMemo)(()=>cs(c,l),[l,c]);(0,F.useEffect)(()=>{if(te(null),re(``),!e||!C||!T||![`image`,`pdf`,`audio`,`video`].includes(T.kind))return;let t=!0,n=``,r=new AbortController;return U.artifactBlob(e,C.path,!1,r.signal).then(e=>{t&&(n=URL.createObjectURL(e),te(n))},e=>t&&re(e.message)),()=>{t=!1,r.abort(),n&&URL.revokeObjectURL(n)}},[e,C?.path,T?.kind,T?.mtime]);let k=c?.delivery??null,se=k?.primary_target?.path??``,A=!!(g&&!S&&C&&(C.source===`delivery`||C.path===se)),ce=p===`zh-CN`?k?.kind===`submission_certified`?`交付已认证`:`已完成`:k?.kind===`submission_certified`?`Certified delivery`:`Delivered result`,le=A?ce:S?f(`research.liveProgress`):m[0]?.group_title||f(`research.artifact`),j=async()=>{if(!(!e||!C)){D(!0),oe(``);try{let t=await U.artifactBlob(e,C.path,!0),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=C.name,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),0)}catch(e){oe(e.message)}finally{D(!1)}}};return(0,X.jsxs)(`section`,{className:`glass-panel glass-panel--side flex min-h-0 flex-col overflow-hidden ${a?``:`rounded-lg border`} ${i}`,"aria-label":f(`research.canvas`),children:[(0,X.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-line/50 bg-panel px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${A?`bg-ok`:`animate-pulse bg-blue`}`}),(0,X.jsx)(`h2`,{className:`max-w-24 truncate text-sm font-semibold text-ink sm:max-w-48`,children:le})]}),c||m.length>0?(0,X.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:f(`research.previewArtifact`)}),(0,X.jsxs)(`select`,{value:S?Yo:C?.path??``,onChange:e=>y(e.target.value),title:S?f(`research.liveProgress`):C?.storage_path||C?.path,className:`h-8 w-full min-w-0 max-w-64 truncate rounded-md border border-line/50 bg-bg px-2 font-mono text-xs text-ink-dim outline-none focus:border-blue/60`,children:[c?(0,X.jsx)(`option`,{value:Yo,children:f(`research.liveProgress`)}):null,m.map(e=>(0,X.jsxs)(`option`,{value:e.path,disabled:!e.exists,title:e.storage_path||e.path,children:[e.source===`delivery`?`交付 · `:e.source===`manager_live`?`Checkpoint · `:``,is(e),e.exists?``:` · pending`]},e.path))]})]}):(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`div`,{className:`shrink-0`,children:C?(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:ie||!C.exists,title:f(`artifact.download`),"aria-label":f(`artifact.download`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M8 2.25v7.5M5.25 7.5 8 10.25 10.75 7.5M3 13.25h10`})})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(C.path),title:f(`research.openLarge`),"aria-label":f(`research.openLarge`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M6 3H3v3M10 3h3v3M6 13H3v-3M10 13h3v-3`})})})]}):null}),s?(0,X.jsx)(`button`,{type:`button`,onClick:s,"aria-label":f(`research.collapse`),title:f(`research.collapse`),className:`hidden h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink lg:flex`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})}):null]}),O?(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-line/50 bg-blue-deep/10 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-blue`}),(0,X.jsx)(`span`,{className:`font-semibold text-ink`,children:O.roleLabel}),(0,X.jsx)(`span`,{className:`text-blue-sky`,children:f(`mission.active`)}),(0,X.jsxs)(`span`,{className:`truncate text-ink-faint`,children:[`· `,O.label]})]}),O.detail?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-ink-dim`,children:O.detail}):null]}):null,(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-bg`,children:[S&&c?(0,X.jsx)(us,{view:c,liveStatus:O,artifacts:t,onOpenArtifact:y}):null,!S&&n?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-6 text-center text-sm text-warn`,children:f(`research.unavailable`)}):null,!S&&!n&&m.length===0?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`h3`,{className:`mt-3 text-xs text-ink-faint`,children:f(`research.noPreview`)})]}):null,!S&&!n&&m.length>0&&!C?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(yi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:f(`research.waiting`)})]}):null,C&&!C.exists?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(yi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:f(`research.updating`)})]}):null,C?.exists&&w.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(yi,{})}):null,C?.exists&&w.isError?(0,X.jsxs)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:[f(`artifact.unavailable`),` · `,w.error.message]}):null,T?.kind===`text`&&!ee?(0,X.jsxs)(`pre`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:[T.preview||`(empty file)`,T.truncated?` … live preview truncated · expand to inspect the complete file`:``]}):null,T&&ee?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-5 text-sm text-ink-dim scroll-thin`,children:(0,X.jsx)(Oi,{artifacts:t,onOpenArtifact:y,children:T.preview||`(empty file)`})}):null,T?.kind===`json`?(0,X.jsx)(Mo,{value:T.preview||``}):null,T?.kind===`table`?(0,X.jsx)(No,{value:T.preview||``,delimiter:T.name.endsWith(`.tsv`)?` `:`,`}):null,T?.kind===`html`&&!T.truncated?(0,X.jsx)(Oo,{sid:e,path:T.path,html:T.preview||``,title:`Live HTML preview: ${T.name}`}):null,T?.kind===`html`&&T.truncated?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-warn`,children:f(`artifact.htmlTooLarge`)}):null,T?.kind===`image`&&E?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,X.jsx)(`img`,{src:E,alt:T.why||T.name,className:`max-h-full max-w-full object-contain`})}):null,T?.kind===`pdf`&&E?(0,X.jsx)(Io,{src:E,name:T.name}):null,T?.kind===`audio`&&E?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl px-6`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:E,className:`w-full`})}):null,T?.kind===`video`&&E?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-black p-2`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:E,className:`max-h-full max-w-full`})}):null,T?.kind===`binary`?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-ink-dim`,children:f(`research.fileUnavailable`)}):null,T&&[`image`,`pdf`,`audio`,`video`].includes(T.kind)&&!E&&!ne?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(yi,{})}):null,ne?(0,X.jsx)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:ne}):null]}),S?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:f(`research.eventSourced`)}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:A?ce:f(`common.live`)})]}):T?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:T.storage_path||T.path,children:T.storage_path||T.path}),ae?(0,X.jsx)(`span`,{className:`ml-auto truncate text-err`,title:ae,children:f(`research.downloadFailed`)}):null,(0,X.jsxs)(`span`,{className:`shrink-0`,children:[T.kind,` · `,di(T.size)]}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:A?ce:f(`common.live`)})]}):null]})}function fs({notice:e,onClose:t}){if((0,F.useEffect)(()=>{if(!e)return;let n=window.setTimeout(t,e.tone===`error`?8e3:4e3);return()=>window.clearTimeout(n)},[e,t]),!e)return null;let n=e.tone===`error`?`border-err/60 bg-err/10 text-err`:e.tone===`success`?`border-ok/60 bg-ok/10 text-ok`:`border-blue-deep/60 bg-panel text-blue-sky`;return(0,X.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,"aria-live":e.tone===`error`?`assertive`:`polite`,className:`fixed bottom-4 left-4 right-4 z-[70] flex items-start gap-2 rounded-md border px-3 py-2.5 shadow-glow sm:left-auto sm:max-w-md ${n}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px shrink-0`,children:e.tone===`error`?`!`:e.tone===`success`?`✓`:`i`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-xs leading-relaxed text-ink-dim`,children:e.message}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`dismiss notification`,onClick:t,className:`shrink-0 rounded px-1 text-base leading-none opacity-70 hover:bg-white/5 hover:opacity-100`,children:`×`})]})}function ps({open:e,busy:t,onClose:n,onCreate:r}){let{t:i}=Z(),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``),d=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&(o(``),c(``),u(``))},[e]);let f=()=>{t||n()},p=async e=>{e.preventDefault(),!t&&await r(a.trim(),s.trim(),l.trim())&&n()},m=e=>{oa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d.current?.requestSubmit())},h=!!s.trim();return(0,X.jsx)(Na,{open:e,onClose:f,label:i(`new.createDaemon`),width:`max-w-xl`,showClose:!1,children:(0,X.jsxs)(`form`,{ref:d,onSubmit:e=>void p(e),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-line px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:i(`landing.new`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-faint`,children:i(`new.subtitle`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":i(`new.close`),onClick:f,disabled:t,className:`rounded px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.name`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{"data-autofocus":!0,value:a,onChange:e=>o(e.target.value),maxLength:80,disabled:t,placeholder:i(`new.namePlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.workdir`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:t,placeholder:i(`newDaemon.workdirPlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 font-mono text-xs text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`mt-1 block text-[10px] leading-relaxed text-ink-faint`,children:i(`new.workdirHint`)})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.objective`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:m,maxLength:4e3,disabled:t,rows:4,placeholder:i(`new.objectivePlaceholder`),className:`w-full resize-y rounded border border-line bg-bg/50 px-3 py-2.5 text-sm leading-relaxed text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`div`,{className:`rounded border p-3 ${h?`border-gold/40 bg-gold/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium ${h?`text-gold`:`text-blue-sky`}`,children:i(h?`new.startsAfterCreate`:`new.idleUntilMessage`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:i(h?`new.startsHint`:`new.idleHint`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line px-5 py-3`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:i(`new.shortcut`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:t,className:`rounded border border-line px-3 py-1.5 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:i(`common.cancel`)}),(0,X.jsx)(`button`,{type:`submit`,disabled:t,className:`rounded border border-blue/35 bg-blue/8 px-3 py-1.5 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:cursor-wait disabled:opacity-50`,children:i(t?`new.creating`:h?`new.createAndStart`:`sidebar.create`)})]})]})]})})}function ms({open:e,sid:t,name:n,alive:r,controlAvailable:i=!0,busy:a,onClose:o,onRename:s,onStart:c,onStop:l,onDelete:u}){let{t:d}=Z(),[f,p]=(0,F.useState)(n),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(!1);(0,F.useEffect)(()=>{e&&(p(n),h(!1),_(!1))},[e,n,t]);let v=async e=>{e.preventDefault(),await s(f.trim())},y=r&&!g,b=async()=>{if(y){await l()&&_(!0);return}await c()&&_(!1)};return(0,X.jsxs)(Na,{open:e,onClose:()=>!a&&o(),label:d(`manage.daemon`),width:`max-w-lg`,children:[(0,X.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:d(`topbar.manageSession`)}),(0,X.jsx)(`p`,{className:`mt-0.5 font-mono text-[10px] text-ink-faint`,children:t})]}),(0,X.jsx)(`form`,{onSubmit:e=>void v(e),className:`border-b border-line p-5`,children:(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.displayName`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),maxLength:80,disabled:a,className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`button`,{type:`submit`,disabled:a||f.trim()===n,className:`rounded border border-line px-3 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:d(`common.save`)})]})]})}),(0,X.jsxs)(`div`,{className:`border-b border-line p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.executor`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-between rounded border border-line bg-bg/30 p-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm text-ink`,children:d(y?i?`manage.running`:`manage.runningExternally`:`manage.paused`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] text-ink-faint`,children:d(y?i?`manage.stopNowHint`:`manage.externalHint`:`manage.resumeHint`)})]}),(0,X.jsx)(`button`,{type:`button`,disabled:a||!i,onClick:()=>void b(),className:`rounded border px-3 py-1.5 text-xs disabled:cursor-wait disabled:opacity-50 ${y?`border-warn/50 text-warn hover:bg-warn/10`:`border-blue-deep bg-blue-deep text-white hover:bg-blue-deep/80`}`,children:d(a?`manage.working`:i?y?`manage.stopNow`:`manage.resume`:`common.external`)})]})]}),(0,X.jsxs)(`div`,{className:`p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:d(`manage.deleteSession`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:d(`manage.deleteHint`)}),m?(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded border border-err/40 bg-err/5 p-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-dim`,children:d(`manage.confirmQuestion`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded px-2 py-1 text-xs text-ink-faint hover:bg-surface`,children:d(`common.cancel`)}),(0,X.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>void u(),className:`rounded bg-err px-3 py-1 text-xs font-medium text-bg disabled:opacity-50`,children:d(`manage.confirmDelete`)})]})]}):(0,X.jsx)(`button`,{type:`button`,disabled:a||y,onClick:()=>h(!0),className:`mt-3 rounded border border-err/40 px-3 py-1.5 text-xs text-err hover:bg-err/10 disabled:cursor-not-allowed disabled:opacity-40`,children:d(`manage.delete`)})]})]})}function hs(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||e}function gs(e,t,n){if(e.length===0)return`local`;let r=n.trim(),i=r?e.filter(e=>e.launch_cwd?.trim()===r):[];return i.length===0||t&&!i.some(e=>e.id===t)?`all`:`local`}function _s({projects:e,activeId:t,localCwd:n,onSelect:i,onPrefetch:a,onManage:s,onResume:l,resumingId:u,onOpenPanel:d,onNew:f,loading:p,creating:m=!1,error:h,onRetry:_,mobileOpen:v=!1,collapsed:y=!1,onToggleCollapse:S,themeMode:w,onCycleTheme:te}){let{locale:ne,setLocale:re,t:D}=Z(),[ae,oe]=(0,F.useState)(`local`),O=(0,F.useRef)(!1),[k,se]=(0,F.useState)(``),[A,ce]=(0,F.useState)(()=>new Set),le=y&&!v,j=n.trim(),M=(0,F.useMemo)(()=>j?e.filter(e=>e.launch_cwd?.trim()===j):[],[j,e]);(0,F.useEffect)(()=>{O.current||p||e.length===0||(O.current=!0,oe(gs(e,t,j)))},[t,p,j,e]);let ue=ae===`local`?M:e,de=k.trim()?Mn(ue,k):ue,fe=(0,F.useMemo)(()=>{if(ae===`local`)return de.length>0?[[j||`Local`,de]]:[];let e=new Map;return de.forEach(t=>{let n=t.launch_cwd?.trim()||D(`common.unassigned`),r=e.get(n)??[];r.push(t),e.set(n,r)}),[...e.entries()]},[j,ae,de]),pe=w===`light`?c:ie,N=w===`light`?`dark`:`light`,P=e=>A.has(e)&&!k.trim();return(0,X.jsxs)(`aside`,{"data-state":le?`collapsed`:`expanded`,"data-resizable-panel":`left`,className:`glass-panel glass-panel--side fixed inset-y-0 left-0 z-50 flex h-full shrink-0 flex-col border-r transition-[width,transform,visibility] duration-panel ease-panel lg:visible lg:static lg:z-auto lg:translate-x-0 ${le?`w-14`:`w-64 lg:w-[var(--sidebar-width)]`} ${v?`visible translate-x-0`:`invisible -translate-x-full`}`,children:[(0,X.jsx)(`div`,{className:`chrome-seam-surface flex h-12 shrink-0 items-center border-b border-line/50 ${le?`justify-center`:`justify-between px-4`}`,children:le?(0,X.jsx)(ji,{size:22,compact:!0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ji,{size:24}),(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":D(`sidebar.collapse`),title:`${D(`sidebar.collapse`)} · Ctrl/⌘ B`,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,X.jsx)(o,{icon:ee,className:`h-3.5 w-3.5`})})]})}),le?(0,X.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":D(`sidebar.expand`),title:`${D(`sidebar.expand`)} · Ctrl/⌘ B`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})})}):null,le?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b border-line/50 px-3`,children:[[`local`,`all`].map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>oe(t),className:`h-8 rounded-md px-3 text-xs font-medium capitalize transition-colors ${ae===t?`bg-bg text-ink`:`text-ink-faint hover:text-ink-dim`}`,children:[D(`common.${t}`),(0,X.jsx)(`span`,{className:`ml-1.5 font-mono text-ink-faint`,children:t===`local`?M.length:e.length})]},t)),(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:m,"aria-label":D(`sidebar.create`),title:D(`sidebar.create`),className:`ml-auto flex h-8 w-8 items-center justify-center rounded-md text-lg text-blue hover:bg-bg disabled:opacity-40`,children:m?`…`:`+`})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`daemon-search`,children:D(`sidebar.find`)}),(0,X.jsxs)(`div`,{className:`flex items-center rounded-md border border-line/60 bg-bg/60 px-2 focus-within:border-blue/60`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1.5 text-xs text-ink-faint`,children:`/`}),(0,X.jsx)(`input`,{id:`daemon-search`,value:k,onChange:e=>se(e.target.value),placeholder:D(`sidebar.find`),className:`h-8 min-w-0 flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink-faint`}),k?(0,X.jsx)(`button`,{type:`button`,"aria-label":D(`sidebar.clearSearch`),onClick:()=>se(``),className:`px-1 text-sm text-ink-faint hover:text-ink`,children:`×`}):null]})]}),(0,X.jsxs)(`div`,{className:`mobile-scroll-region min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-3 pb-3 scroll-thin`,children:[p&&e.length===0?(0,X.jsx)(`div`,{className:`px-1 py-3 text-xs text-ink-faint`,children:D(`common.loading`)}):null,h?(0,X.jsx)(`button`,{type:`button`,onClick:_,className:`mb-2 w-full rounded-md bg-err/5 px-3 py-2 text-left text-xs text-err`,children:D(`sidebar.refreshFailed`)}):null,!p&&!h&&de.length===0?(0,X.jsxs)(`div`,{className:`px-1 py-4 text-xs text-ink-faint`,children:[(0,X.jsx)(`div`,{children:k.trim()?D(`sidebar.noMatches`,{query:k.trim()}):D(`sidebar.noSessions`)}),k.trim()?(0,X.jsx)(`button`,{type:`button`,onClick:()=>se(``),className:`mt-2 text-xs text-ink-dim underline underline-offset-2 hover:text-ink`,children:D(`sidebar.clearSearch`)}):null]}):null,fe.map(([e,n])=>(0,X.jsxs)(`section`,{className:`mb-4 last:mb-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":!P(e),title:e,onClick:()=>ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),className:`mb-1 flex h-7 w-full items-center gap-2 rounded-md px-1.5 text-left text-[11px] font-medium text-ink-faint hover:bg-bg/70 hover:text-ink-dim`,children:[(0,X.jsx)(o,{icon:T,className:`h-2.5 w-2.5 transition-transform ${P(e)?`-rotate-90`:``}`}),(0,X.jsx)(o,{icon:C,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:hs(e)}),(0,X.jsx)(`span`,{className:`font-mono text-[10px]`,children:n.length})]}),P(e)?null:n.map(e=>{let n=e.id===t,c=En(e),d=c?(e.label||e.display_name||``).trim():e.objective.trim()||e.id||D(`sidebar.unnamedSession`),f=e.daemon_alive&&e.daemon_protocol_compatible===!1,p=f&&e.daemon_protocol_error===`daemon release is incompatible with WebAPI release`,m=f&&!p,h=!e.daemon_alive&&e.last_active>0&&!!e.workdir?.trim();return(0,X.jsxs)(`div`,{"data-active":n?`true`:`false`,onPointerEnter:()=>{n||a?.(e.id)},className:`session-card group relative mb-0.5 h-14 w-full rounded-md transition-colors duration-150 ease-panel ${n?`text-ink`:`text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-0 transition-colors ${n?`inset-y-1 w-px bg-blue`:`inset-y-2 w-px bg-transparent group-hover:bg-ink-faint/30`}`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),onFocus:()=>{n||a?.(e.id)},"aria-current":n?`page`:void 0,title:`${d}${!c&&d!==e.id?` · ${e.id}`:``}${e.objective&&e.objective!==d?` — ${e.objective}`:``}`,className:`flex h-14 w-full min-w-0 flex-col justify-center px-2.5 text-left ${h?`pr-[4.75rem]`:`pr-10`}`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(hi,{ok:e.daemon_alive&&!m,title:m?D(`sidebar.updateRequired`):e.daemon_alive?D(`sidebar.daemonAlive`):D(`sidebar.stopped`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:d})]}),(0,X.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 pl-3.5 text-[11px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${m?`text-warn`:``}`,children:m?D(`sidebar.updateRequired`):e.daemon_alive?D(`sidebar.runningFor`,{uptime:li(e.uptime_seconds)}):ci(e.last_active)}),p&&(0,X.jsx)(`span`,{title:D(`sidebar.updateAvailableHint`),className:`shrink-0 rounded border border-line px-1 text-[10px] leading-4`,children:D(`sidebar.updateAvailable`)})]})]}),h&&l?(0,X.jsx)(`button`,{type:`button`,disabled:u!=null,onClick:t=>{t.stopPropagation(),l(e.id)},"aria-label":D(`sidebar.resume`),title:D(`sidebar.resumeHint`,{workdir:e.workdir??``}),className:`absolute right-9 top-3 flex h-8 w-8 items-center justify-center rounded-md text-blue opacity-100 hover:bg-blue/10 disabled:opacity-40 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:u===e.id?`…`:(0,X.jsx)(o,{icon:r,className:`h-3 w-3`})}):null,(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.id)},"aria-label":D(`sidebar.manage`,{name:d}),title:D(`sidebar.manageHint`),className:`absolute right-1 top-3 flex h-8 w-8 items-center justify-center rounded-md text-ink-faint opacity-100 transition-opacity hover:bg-panel-raised hover:text-ink sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:(0,X.jsx)(o,{icon:E,className:`h-4 w-4`})})]},e.id)})]},e))]}),(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between border-t border-line/50 px-4 py-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`config`),className:`icon-control flex h-8 w-8 items-center justify-center`,"aria-label":D(`sidebar.openSettings`),title:D(`common.settings`),children:(0,X.jsx)(o,{icon:b,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>re(ne===`zh-CN`?`en`:`zh-CN`),title:D(`language.switchTo`,{language:D(ne===`zh-CN`?`language.english`:`language.chinese`)}),"aria-label":D(`language.switchTo`,{language:D(ne===`zh-CN`?`language.english`:`language.chinese`)}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:g,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:te,title:D(`sidebar.theme`,{current:w,next:N}),"aria-label":D(`sidebar.theme`,{current:w,next:N}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:pe,className:`h-3.5 w-3.5`})})]})]})]})}var vs={in_progress:`rgb(var(--blue))`,running:`rgb(var(--blue))`,pending:`rgb(var(--ink-faint))`,queued:`rgb(var(--ink-faint))`,done:`rgb(var(--blue))`,completed:`rgb(var(--blue))`,blocked:`rgb(var(--err))`,failed:`rgb(var(--err))`};function ys({items:e,onDispose:t,onStop:n,onInspect:r,busy:i,readOnly:a=!1}){let{t:o}=Z(),[s,c]=(0,F.useState)(!1),l=Vn(e,!1),u=Vn(e,!0),d=s?u:l;return(0,X.jsxs)(`section`,{className:`card flex flex-col ${d.length>0?`min-h-0 flex-1`:`shrink-0`}`,children:[(0,X.jsx)(vi,{title:o(`panel.backlog`),right:(0,X.jsx)(`button`,{className:`text-[10px] text-ink-faint transition-colors hover:text-ink`,onClick:()=>c(e=>!e),children:o(s?`backlog.active`:`backlog.history`,{count:s?l.length:u.length})})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[d.length===0&&(0,X.jsx)(bi,{children:o(s?`backlog.noHistory`:`backlog.empty`)}),d.map(e=>{let s=vs[e.status]??`rgb(var(--ink-faint))`,c=e.iterate;return(0,X.jsx)(`div`,{className:`group border-b border-line/60 px-3 py-2 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.id),disabled:!r,className:`block max-w-full truncate text-left text-xs font-medium text-ink enabled:hover:text-blue-sky enabled:focus-visible:outline-none enabled:focus-visible:underline`,title:r?o(`backlog.viewDetails`):void 0,children:e.title||e.objective}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,X.jsx)(gi,{color:s,children:zi(e.status,o)}),typeof e.priority==`number`&&(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:Vi(e.priority,o)}),c&&(0,X.jsxs)(`span`,{className:`text-[10px] text-blue-sky`,children:[`↻ `,o(`backlog.iterating`)]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[!a&&c&&(0,X.jsx)(_i,{variant:`ghost`,onClick:()=>n(e.id),disabled:i,title:o(`backlog.stopIterating`),children:o(`backlog.stop`)}),!a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_i,{variant:`ghost`,onClick:()=>t(e.id,`done`),disabled:i,title:o(`backlog.markDone`),children:`✓`}),(0,X.jsx)(_i,{variant:`ghost`,onClick:()=>t(e.id,`rm`),disabled:i,title:o(`backlog.remove`),children:`✕`})]})]})]})},e.id)})]})]})}var bs={win:`rgb(var(--blue))`,milestone:`rgb(var(--blue))`,insight:`rgb(var(--ink-dim))`,decision:`rgb(var(--ink-dim))`,failure:`rgb(var(--err))`,note:`rgb(var(--ink-faint))`};function xs({entries:e}){let{t}=Z(),n=[...e].reverse();return(0,X.jsxs)(`section`,{className:`card flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(vi,{title:t(`panel.journal`),right:(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.length})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[e.length===0&&(0,X.jsx)(bi,{children:`no journal entries yet`}),n.map(e=>{let t=bs[e.kind]??`rgb(var(--ink-faint))`,n=String(e.extra?.pricing_status??``),r=e.extra&&Object.prototype.hasOwnProperty.call(e.extra,`cost_usd`)?e.extra.cost_usd:e.cost_usd,i=typeof r==`number`&&r>0?`${ui(r)}${n===`partial`||n===`unpriced`?`+`:``}`:n===`partial`||n===`unpriced`?n:``;return(0,X.jsxs)(`div`,{className:`border-b border-line/60 px-3 py-2 last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide`,style:{color:t},children:e.kind}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:ci(e.ts)})]}),(0,X.jsx)(`div`,{className:`mt-1 text-xs font-medium text-ink`,children:e.title}),e.summary&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-snug text-ink-dim`,children:e.summary}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(e.tags??[]).slice(0,4).map(e=>(0,X.jsx)(`span`,{className:`rounded bg-line/60 px-1 text-[9px] text-ink-faint`,children:e},e)),i?(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:i}):null]})]},e.id)})]})]})}var Ss=[`manager`,`planner`,`engineer`,`reviewer`];function Cs(e){return e==null?``:e<3?`now`:e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:`${Math.floor(e/3600)}h`}function ws({roles:e}){let{t}=Z(),n=new Map(e.map(e=>[e.role,e])),r=Ss.map(e=>n.get(e)).filter(Boolean),i=e.filter(e=>!Ss.includes(e.role)),a=[...r,...i];return(0,X.jsxs)(`section`,{className:`card`,children:[(0,X.jsx)(vi,{title:t(`panel.roles`)}),(0,X.jsx)(`div`,{children:a.map(e=>{let t=W.role[e.role]??W.info;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[84px_minmax(0,1fr)_auto] items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{background:e.active?t:`rgb(var(--ink-faint))`}}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium capitalize`,style:{color:e.active?t:W.inkDim},children:e.role})]}),(0,X.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[10px] text-ink-faint`,title:e.model,children:e.model||`—`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-right`,children:[(0,X.jsx)(`span`,{className:`text-[10px]`,style:{color:e.active?W.ink:W.inkFaint},children:e.active?e.status||`active`:`idle`}),e.active&&Cs(e.age_s)&&(0,X.jsxs)(`span`,{className:`text-[10px] tabular-nums text-ink-faint`,children:[`· `,Cs(e.age_s)]}),e.effort&&(0,X.jsxs)(`span`,{className:`text-[10px]`,style:{color:ft(e.effort)},children:[`· `,e.effort]})]})]},e.role)})})]})}function Ts({open:e,snap:t,journal:n,busy:r,onClose:i,onDispose:a,onStop:o,onInspect:s}){let{t:c}=Z();return(0,X.jsxs)(Na,{open:e,onClose:i,label:`Project inspector`,width:`max-w-6xl`,children:[(0,X.jsx)(Pa,{title:c(`panel.project`),sub:t.session.display_name||t.session.id}),(0,X.jsxs)(`div`,{className:`h-[68vh] min-h-0 space-y-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid lg:grid-cols-[minmax(0,1.4fr)_minmax(300px,0.8fr)] lg:gap-3 lg:space-y-0 lg:overflow-hidden`,children:[(0,X.jsx)(ys,{items:t.backlog,onDispose:a,onStop:o,onInspect:s,busy:r}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,X.jsx)(ws,{roles:t.roles}),(0,X.jsx)(xs,{entries:n})]})]})]})}var Es=e=>e?new Date(e*1e3).toLocaleString():`—`;function Ds({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`rounded-md border border-line/70 bg-bg/40 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[9px] font-semibold uppercase tracking-wider text-ink-faint`,children:e}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:t})]})}function Os({sid:e,itemId:t,onClose:n,onDone:r,onSkip:i,onStop:a,busy:o,readOnly:s=!1}){let{t:c}=Z(),l=Or(e,t),u=l.data,d=u?Bn(u):!1,f=Hi(u?.outcome,c);return(0,X.jsxs)(Na,{open:!!t,onClose:n,label:c(`task.details`),width:`max-w-3xl`,showClose:!1,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 border-b border-line px-4 py-3 sm:flex-nowrap sm:px-5`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-ink`,children:u?.title||c(`task.details`)}),u?(0,X.jsx)(gi,{children:zi(u.status,c)}):null]})}),!s&&u&&!d?(0,X.jsxs)(`div`,{className:`order-3 flex w-full shrink-0 items-center justify-end gap-1 sm:order-none sm:w-auto`,children:[u.iterate?(0,X.jsx)(_i,{onClick:()=>a(u.id),disabled:o,children:c(`task.stopLoop`)}):null,(0,X.jsx)(_i,{onClick:()=>r(u.id),disabled:o,children:c(`task.done`)}),(0,X.jsx)(_i,{variant:`danger`,onClick:()=>i(u.id),disabled:o,children:c(`task.skip`)})]}):null,(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`task.close`),onClick:n,className:`order-2 rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink sm:order-none`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto p-4 scroll-thin sm:p-5`,children:[l.isLoading?(0,X.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,X.jsx)(yi,{})}):null,l.isError?(0,X.jsx)(`div`,{className:`rounded-md border border-err/40 bg-err/5 p-3 text-xs text-err`,children:l.error.message}):null,u?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[u.pending_question?(0,X.jsxs)(`div`,{className:`rounded-lg border border-warn/40 bg-warn/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-warn`,children:c(`task.waitingOnYou`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:u.pending_question})]}):null,(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.objective`)}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap rounded-lg border border-line bg-bg/50 p-3 text-sm leading-relaxed text-ink-dim`,children:u.objective||u.original_objective||c(`task.noObjective`)})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,X.jsx)(Ds,{label:c(`task.priority`),value:Vi(u.priority,c)}),(0,X.jsx)(Ds,{label:c(`task.started`),value:Es(u.started_ts)}),(0,X.jsx)(Ds,{label:c(`task.finished`),value:Es(u.finished_ts)})]}),f.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.outcome`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,X.jsx)(gi,{children:e},e))})]}):null,u.iterate||u.iteration_cycles_done||u.iteration_cost_usd?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.iteration`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsx)(Ds,{label:c(`task.mode`),value:u.iterate?c(`task.autoIterate`):c(`task.singlePass`)}),(0,X.jsx)(Ds,{label:c(`task.cycles`),value:`${u.iteration_cycles_done??0}/${u.iteration_max_cycles??`—`}`}),(0,X.jsx)(Ds,{label:c(`task.cost`),value:`$${(u.iteration_cost_usd??0).toFixed(2)}`})]})]}):null,u.last_error?(0,X.jsxs)(`section`,{className:`rounded-lg border border-err/30 bg-err/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:c(`task.lastError`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap font-mono text-xs leading-relaxed text-ink-dim`,children:u.last_error})]}):null,u.notes?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.notes`)}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:u.notes})]}):null,u.tags?.length||u.deps?.length?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(u.tags??[]).map(e=>(0,X.jsxs)(gi,{children:[`#`,e]},`tag-${e}`)),u.deps?.length?(0,X.jsx)(gi,{children:c(`task.dependsOnCount`,{count:u.deps.length})}):null]}):null]}):null]})]})}function ks({onPointerDown:e,onReset:t,onNudge:n,value:r,min:i=240,max:a=600,label:o=`Resize panel`}){return(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":o,"aria-valuenow":r,"aria-valuemin":i,"aria-valuemax":a,tabIndex:0,onPointerDown:e,onDoubleClick:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-16)):e.key===`ArrowRight`?(e.preventDefault(),n(16)):e.key===`Home`&&(e.preventDefault(),t())},className:`group relative hidden w-2 shrink-0 cursor-col-resize items-center justify-center outline-none lg:flex`,children:(0,X.jsx)(`span`,{className:`h-full w-px bg-line/30 transition-colors duration-150 group-hover:bg-blue/70 group-focus:bg-blue/70`})})}var As=[`manager`,`planner`,`engineer`,`reviewer`],js=new Set([`grounding`,`task`,`decision`,`agent_message`,`assistant_message`,`command_execution`,`tool_use`,`handoff`,`review`,`verdict`,`completion`,`plan`,`file_change`,`result`]),Ms=/^(using a tool|running project command|inspecting project state|working|reporting progress|暂无详细记录)$/i;function Ns(e){let t=Et(e).replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/gim,``).trim();return Ms.test(t)||t.startsWith(`{`)?``:t}function Ps(e,t,n=``){if(n){if(/^(?:rg|grep|glob|search)$/.test(n))return t?`检索项目文件`:`Searching project files`;if(/^(?:view|read|read_file)$/.test(n))return t?`读取文件`:`Reading a file`;if(/apply_patch|edit|write/.test(n))return t?`编辑文件`:`Editing a file`;if(/bash|shell|exec|terminal/.test(n))return t?`运行终端命令`:`Running a command`;if(/playwright|browser/.test(n))return t?`检查浏览器交互`:`Checking browser interactions`}return({grounding:[`理解任务与检查项目`,`Understanding the task`],task:[`安排任务`,`Task assignment`],decision:[`确定执行方案`,`Execution decision`],plan:[`制定执行计划`,`Planning the work`],agent_message:[`更新执行进度`,`Progress update`],assistant_message:[`更新执行进度`,`Progress update`],command_execution:[`运行项目命令`,`Running a project command`],tool_use:[`使用工具`,`Using a tool`],file_change:[`更新项目文件`,`Updating project files`],handoff:[`提交结果与交接`,`Results and handoff`],review:[`复核实现与结果`,`Reviewing implementation and results`],verdict:[`给出审查结论`,`Review verdict`],completion:[`完成任务`,`Task completed`],result:[`产出结果`,`Result`]}[e]??[e,e])[+!t]}function Fs(e,t,n){let r=new Map;for(let i of e?.role_work??[]){if(i.role!==t||!js.has(i.kind))continue;let e=i.item_id||i.mission_id;n&&e!==n||r.set(i.id,{...i,detail:Ns(i.detail)})}return[...r.values()].sort((e,t)=>t.ts-e.ts)}function Is(e,t,n){return[...e].reverse().find(e=>e.type===`engineer.progress`&&[`tool_use`,`command_execution`,`file_change`].includes(String(e.kind))&&String(e.agent_layer||e.actor||e.role)===t&&(!n||String(e.item_id||e.mission_id)===n))}function Ls(e,t,n,r,i){return r||[`done`,`completed`,`failed`,`aborted`,`stopped`].includes(e?.mission.status??``)||i&&e?.mission.id!==i?!1:t.length?t.some(e=>e.role===n&&e.active):e?.active_role===n&&[`working`,`grounding`,`framed`,`running`].includes(e?.mission.status??``)}var Rs={manager:[`统筹`,`Manager`],planner:[`规划`,`Planner`],engineer:[`执行`,`Engineer`],reviewer:[`审查`,`Reviewer`]};function zs({view:e,roles:t=[],events:n=[],taskId:r,paused:i=!1,selectedRole:a,onSelectRole:o,onClose:s,showTabs:c=!0}){let{locale:l}=Z(),u=l===`zh-CN`,[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(Date.now),h=a||d||t.find(e=>e.active)?.role||e?.active_role||`manager`,g=Ls(e,t,h,i,r),_=Fs(e,h,r),v=_[0],y=_.find(e=>e.detail&&[`agent_message`,`assistant_message`,`decision`,`verdict`,`handoff`,`review`,`completion`].includes(e.kind)),b=Is(n,h,r),x=b&&Number(b.ts||0)>=(v?.ts??0),S=!x&&v&&[`agent_message`,`assistant_message`].includes(v.kind)&&v.detail?v.detail.split(/[。\n]/)[0].slice(0,70):Ps(x?String(b.kind):v?.kind||`task`,u,x?String(b.tool_name||``):``),C=t.find(e=>e.role===h)?.model||e?.roles.find(e=>e.role===h)?.model,w=v?Math.max(0,Math.floor(p/1e3-v.ts)):0;(0,F.useEffect)(()=>{if(!g)return;let e=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(e)},[g]);let T=e=>Rs[e]?.[+!u]||e;return(0,X.jsxs)(`section`,{className:`agent-activity`,"aria-label":u?`Agent 工作详情`:`Agent work details`,children:[(0,X.jsxs)(`header`,{className:`agent-activity-heading`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(go,{size:15}),u?`Agent 动态`:`Agent activity`]}),s&&(0,X.jsx)(`button`,{type:`button`,onClick:s,"aria-label":u?`关闭 Agent 详情`:`Close Agent details`,children:(0,X.jsx)(Do,{size:17})})]}),c&&(0,X.jsx)(`div`,{className:`agent-activity-tabs`,role:`group`,"aria-label":u?`筛选 Agent`:`Filter agents`,children:As.map(n=>(0,X.jsxs)(`button`,{type:`button`,"data-role":n,"aria-pressed":h===n,onClick:()=>{f(n),o?.(n)},children:[(0,X.jsx)(`i`,{"data-active":Ls(e,t,n,i,r)}),T(n)]},n))}),(0,X.jsxs)(`div`,{className:`agent-current`,"data-active":g,children:[(0,X.jsxs)(`div`,{className:`agent-current-kicker`,children:[(0,X.jsx)(`span`,{children:g?T(h)+(u?` Agent 正在工作`:` is working`):i?u?`会话已暂停`:`Session paused`:u?`最近进度`:`Latest progress`}),g?(0,X.jsxs)(`span`,{className:`agent-live-indicator`,children:[(0,X.jsx)(`i`,{}),`LIVE`]}):(0,X.jsx)(To,{size:12})]}),(0,X.jsx)(`h3`,{children:v||x?S:u?`等待任务分配`:`Waiting for an assignment`}),y?.detail&&(0,X.jsx)(`div`,{className:`agent-current-summary`,children:(0,X.jsx)(Oi,{children:y.detail})}),!y&&v?.detail&&(0,X.jsx)(`p`,{className:`agent-current-summary`,children:v.detail}),v&&(0,X.jsxs)(`div`,{className:`agent-current-meta`,children:[(0,X.jsx)(bo,{size:12}),(0,X.jsx)(`span`,{children:u?`${w<60?w+` 秒`:Math.floor(w/60)+` 分钟`}前更新`:`Updated ${w<60?w+`s`:Math.floor(w/60)+`m`} ago`}),C&&(0,X.jsx)(`span`,{children:C})]})]}),(0,X.jsxs)(`div`,{className:`agent-records-heading`,children:[(0,X.jsx)(`span`,{children:u?`工作记录`:`Work log`}),(0,X.jsxs)(`span`,{children:[_.length,` `,u?`条`:`records`]})]}),(0,X.jsxs)(`div`,{className:`agent-records`,role:`log`,"aria-live":`off`,children:[_.slice(0,24).map((e,t)=>{let n=g&&t===0,r=[`done`,`completed`].includes(e.status),i=[`failed`,`error`,`rejected`].includes(e.status),a=r?_o:[`tool_use`,`command_execution`].includes(e.kind)?Eo:xo;return(0,X.jsxs)(`article`,{className:`agent-record`,"data-active":n,"data-failed":i,children:[(0,X.jsx)(`span`,{className:`agent-record-icon`,children:(0,X.jsx)(a,{size:13})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`agent-record-title`,children:[(0,X.jsx)(`strong`,{children:Ps(e.kind,u)}),(0,X.jsx)(`time`,{children:new Date(e.ts*1e3).toLocaleTimeString(u?`zh-CN`:`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})})]}),(0,X.jsxs)(`small`,{children:[n?u?`进行中`:`In progress`:i?u?`需要处理`:`Needs attention`:r?u?`已完成`:`Completed`:u?`已记录`:`Recorded`,e.round_index==null?``:u?` · 第 ${e.round_index} 轮`:` · Round ${e.round_index}`]}),e.detail&&(0,X.jsxs)(`details`,{open:t===0||e===y,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(`span`,{children:u?`查看详情`:`Read details`}),(0,X.jsx)(vo,{size:12})]}),(0,X.jsx)(`div`,{className:`agent-record-detail`,children:(0,X.jsx)(Oi,{children:e.detail})})]})]})]},e.id)}),!_.length&&(0,X.jsx)(`p`,{className:`agent-records-empty`,children:u?`${T(h)}尚未留下这个任务的工作记录。`:`No work has been recorded for this task by ${T(h)}.`})]})]})}var Bs=[`manager`,`planner`,`engineer`,`reviewer`],Vs=[`active`,`running`,`in_progress`,`claimed`],Hs=[`complete`,`completed`,`done`,`success`,`incomplete`,`stalled`,`blocked`,`ended`],Us=864e5,Ws=300;function Gs(e,t){return Bs.includes(e)?t(`role.${e}`):Bi(e,t)}function Ks(e){let t=e.type.toLowerCase().split(/[._-]/).at(-1);return[`failed`,`failure`,`error`].includes(t??``)||e.tone===`error`&&/\bfailed\b/i.test(e.title)}function qs(e,t,n=new Date){let r=new Date(e*1e3),i=r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),a=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()),o=Date.UTC(r.getFullYear(),r.getMonth(),r.getDate());if(o===a)return i;let s=+(t===`zh-CN`);return o>=a-(n.getDay()-s+7)%7*Us&&ot;(0,F.useEffect)(()=>{if(t!=null||a)return;let e=i.current;if(!e)return;let n=()=>c(e.scrollHeight>e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,a,t]);let u=!a&&t!=null&&l?`${e.slice(0,t)}…`:e;return(0,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(`p`,{ref:i,className:`${t==null&&!a?`line-clamp-3`:``} whitespace-pre-wrap break-words ${n}`,children:u}),l?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`mt-1 text-[11px] text-blue-sky hover:text-ink`,children:r(a?`mission.showLess`:`mission.showMore`)}):null]})}function Ys(e){let t=[...e.dag],n=[],r=new Set;for(;t.length;){let i=t.findIndex(t=>t.deps.every(t=>r.has(t)||!e.dag.some(e=>e.id===t))),[a]=t.splice(i>=0?i:0,1);n.push(a),r.add(a.id)}return n}function Xs(e,t=16){let n=Ys(e);if(n.length<=t)return{nodes:n,hidden:[]};let r=new Set(n.slice(-t).map(e=>e.id)),i=n.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),a=new Map(n.map(e=>[e.id,e])),o=i?[i]:[];for(;o.length;){let e=o.pop();r.has(e.id)||(r.add(e.id),e.deps.forEach(e=>{let t=a.get(e);t&&o.push(t)}))}return{nodes:n.filter(e=>r.has(e.id)),hidden:n.filter(e=>!r.has(e.id))}}function Zs({view:e}){let{t}=Z(),n=e.achievement;return n?(0,X.jsxs)(`section`,{className:`border-b border-ok/35 bg-ok/5 px-5 py-4 animate-appear`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ok`,children:t(`mission.achievement`)}),(0,X.jsx)(`div`,{className:`mt-2 text-sm font-semibold text-ink`,children:n.title}),n.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:n.summary}):null,(0,X.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-ink-faint`,children:[t(`mission.elapsed`),` `]}),(0,X.jsx)(`span`,{className:`font-mono text-ink`,children:wn(n.elapsed_seconds??0)})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-1 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{children:t(`mission.rejectedAttempts`,{count:n.rejected_attempts??0})}),(0,X.jsx)(`span`,{children:t(`mission.skillsLearned`,{count:n.skills_learned??0})}),(0,X.jsx)(`span`,{children:t(`mission.artifacts`,{count:n.artifacts??0})})]})]}):null}function Qs({view:e,sid:t=``,snapshot:n,artifacts:r=[],onOpenArtifact:i,onOpenDelivery:a,gitDiff:o,onNotify:s}){let{locale:c,t:l}=Z(),u=new Map(e.roles.map(e=>[e.role,e])),d=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),f=Xs(e),p=f.nodes,m=Cn(e.mission.objective||e.mission.title||l(`mission.waiting`)),h=e.mission.final_output?.trim()||``,g=!!(h&&h!==e.mission.summary.trim()),[_,v]=(0,F.useState)(Math.max(0,e.timeline.length-1)),[y,b]=(0,F.useState)(e.active_role||`planner`),[x,S]=(0,F.useState)(d?.id||``),[C,w]=(0,F.useState)(!1),T=e.delivery,ee=new Map(r.map(e=>[e.path,e])),E=e.learned_skills.filter(e=>e.status===`active`),te=e.learned_wiki_pages.filter(e=>e.status!==`retired`),ne=!!(e.storage.project_skill_dir||e.storage.global_skill_dir||e.storage.wiki_paths.length||e.storage.skill_history_compressed||e.storage.wiki_retired_compressed),re=!!(E.length||te.length||ne),ie=e.mission.status.toLowerCase(),D=[`working`,`grounding`,`framed`].includes(ie),ae=[`degraded`,`red`,`critical`].includes(e.health?.toLowerCase()??``),oe=[`failed`,`error`].includes(e.mission.status.toLowerCase()),O=e.dag.some(t=>t.status.toLowerCase()===`failed`&&(t.id===e.mission.id||!D&&!d)),k=[`hold`,`paused`].includes(e.stage.id.toLowerCase()),se=e.outcome.execution_status?.toLowerCase()===`failed`&&e.stage.id.toLowerCase()===`delivery`,A=ae||se||oe||O||k,ce=ae?`mission.attentionHealth`:se?`mission.deliveryFailed`:oe?`mission.attentionFailed`:O?`mission.attentionStepFailed`:`mission.attentionPaused`,le=e.role_work.filter(e=>Vs.includes(e.status.toLowerCase())).sort((e,t)=>t.ts-e.ts),j=le.find(t=>t.role===e.active_role)??le[0],M=Hs.includes(ie),ue=Hi(e.outcome,l)[0]??zi(e.mission.status,l),de=A?l(ce):M?l(`mission.statusDone`,{outcome:ue,elapsed:wn(e.mission.elapsed_seconds)}):D&&j?l(`mission.statusActive`,{role:Bi(e.active_role||j.role,l),work:j.title}):l(`mission.statusWaiting`),fe=ae||se||oe||O?`error`:k?`waiting`:M?`done`:D&&j?`active`:`waiting`;(0,F.useEffect)(()=>v(Math.max(0,e.timeline.length-1)),[e.timeline.length]),(0,F.useEffect)(()=>{d?.id&&S(d.id)},[d?.id]);let pe=async()=>{if(!C){w(!0);try{await U.setContinuous(t,!0,n?.continuous?.objective??``),s?.(`success`,l(`sidebar.resumeSuccess`))}catch(e){s?.(`error`,l(`sidebar.resumeFailed`,{error:pi(e)}))}finally{w(!1)}}},N=e.timeline.slice(0,_+1).slice(-12).reverse(),P=e.dag.find(e=>e.id===x);return(0,X.jsxs)(`section`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto bg-panel scroll-thin`,"aria-label":l(`mission.control`),children:[(0,X.jsxs)(`header`,{className:`border-b border-line/60 px-5 py-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mobile.mission`)}),(0,X.jsx)(`div`,{role:`heading`,"aria-level":1,className:`mt-1 line-clamp-4 max-w-4xl text-lg font-semibold leading-snug text-ink`,title:m,children:(0,X.jsx)(Oi,{artifacts:r,onOpenArtifact:i,children:m})}),m.length>600?(0,X.jsxs)(`details`,{className:`mt-2 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink`,children:l(`mission.showObjective`)}),(0,X.jsx)(`div`,{className:`mt-2 text-ink-dim`,children:(0,X.jsx)(Oi,{artifacts:r,onOpenArtifact:i,children:m})})]}):null,(0,X.jsxs)(`div`,{className:`mission-status-line`,"data-tone":fe,role:A?`alert`:`status`,children:[(0,X.jsxs)(`div`,{className:`mission-status-line__signal`,children:[(0,X.jsx)(`span`,{className:`mission-status-line__marker`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:de})]}),e.frontier.change?(0,X.jsx)(`div`,{className:`mission-status-line__subtitle`,children:e.frontier.change}):null]}),e.mission.summary||g?(0,X.jsxs)(`div`,{className:`mt-3 rounded border border-ok/25 bg-ok/5 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(`mission.summary`)}),(0,X.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:(0,X.jsx)(Oi,{artifacts:r,onOpenArtifact:i,children:e.mission.summary})}),g?(0,X.jsxs)(`details`,{className:`mt-2 border-t border-ok/20 pt-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-ok hover:text-ink`,children:l(`mission.showFullOutput`)}),(0,X.jsx)(`div`,{className:`mt-3 break-words text-sm leading-relaxed text-ink`,children:(0,X.jsx)(Oi,{artifacts:r,onOpenArtifact:i,children:h})})]}):null]}):null,T?(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 rounded border border-ok/30 bg-ok/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(T.kind===`submission_certified`?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs text-ink-dim`,title:T.summary||T.title,children:T.summary||T.title})]}),a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(T),title:T.primary_target?ee.get(T.primary_target.path)?.storage_path||T.primary_target.path:T.title,className:`shrink-0 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok`,children:l(T.primary_target?`mission.openResult`:`mission.viewTask`)}):null]}):null]}),n?.continuous?.done_at&&(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded-lg border-l-2 border-blue bg-blue/5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-base`,children:`↩`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-ink-dim`,children:[l(`mission.continuousDone`),n.continuous.objective?` · ${n.continuous.objective}`:``]}),(0,X.jsx)(`button`,{type:`button`,disabled:C,onClick:()=>void pe(),className:`compact-control shrink-0 px-3`,children:C?`…`:l(`mission.resumeContinuous`)})]}),(0,X.jsx)(Zs,{view:e}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.team`)}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:Bs.map(e=>{let t=u.get(e),n=t?.status===`active`,r=t?.status===`rejected`||t?.status===`error`,i=W.role[e]??W.inkFaint;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":y===e,className:`min-w-0 border-l-2 pl-3 text-left ${y===e?`bg-white/[0.03]`:``}`,style:{borderColor:n||t?.status===`done`?i:`rgb(var(--line))`},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:r?W.error:n||t?.status===`done`?i:W.inkFaint}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:i},children:Bi(e,l)})]}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs ${r?`text-err`:`text-ink-dim`}`,children:t?.label||l(`mission.waitingShort`)})]},e)})})]}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:[l(`mission.roleWork`),` · `,(0,X.jsx)(`span`,{className:`text-blue-sky`,children:Bi(y,l)})]}),P?(0,X.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`text-[10px] text-ink-faint hover:text-ink`,children:l(`mission.filteredBy`,{task:P.title||P.objective||l(`task.untitled`)})}):(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(`mission.allVisible`)})]}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(zs,{view:e,roles:n?.roles,events:n?.recent_events,taskId:x||void 0,selectedRole:y,showTabs:!1,paused:n?!n.daemon.alive:!1})})]}),(0,X.jsxs)(`div`,{className:`grid min-h-[320px] border-b border-line/60 lg:grid-cols-[minmax(0,1.15fr)_minmax(260px,0.85fr)]`,children:[(0,X.jsxs)(`section`,{className:`min-w-0 border-b border-line/60 px-5 py-4 lg:border-b-0 lg:border-r`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.researchDag`)}),d?(0,X.jsxs)(`span`,{className:`max-w-48 truncate text-[10px] text-blue-sky`,children:[l(`mission.active`),` · `,d.title]}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-0`,children:[f.hidden.length?(0,X.jsx)(`div`,{className:`mb-3 rounded border border-line/60 bg-bg/50 px-3 py-2 text-[10px] text-ink-faint`,children:l(`mission.hiddenTasks`,{count:f.hidden.length,failed:f.hidden.filter(e=>[`failed`,`blocked`].includes(e.status)).length,skipped:f.hidden.filter(e=>e.status===`skipped`).length})}):null,p.length?p.map((e,t)=>{let n=e.id===d?.id,r=[`done`,`completed`].includes(e.status),i=[`failed`,`blocked`].includes(e.status);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>S(e.id),className:`relative flex w-full min-w-0 gap-3 pb-3 text-left last:pb-0 ${x===e.id?`bg-white/[0.03]`:``}`,children:[t(0,X.jsx)(`li`,{children:e},e))})]}):null]}):null]}),(0,X.jsxs)(`section`,{className:`min-w-0 px-5 py-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.capabilities`)}),E.length?(0,X.jsxs)(`div`,{className:`mt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ok`,children:l(`mission.capabilitiesUnlocked`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:E.slice(-8).map(e=>(0,X.jsxs)(`details`,{className:`rounded border border-ok/35 bg-ok/5 px-2 py-1.5`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[10px] text-ok`,children:String(e.name||l(`mission.learnedCapability`))}),e.mission_title?(0,X.jsx)(`div`,{className:`mt-2 text-[9px] text-ink-faint`,children:l(`mission.learnedDuring`,{mission:e.mission_title})}):null,e.content?(0,X.jsxs)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap border-t border-ok/20 pt-2 font-mono text-[10px] leading-5 text-ink-dim scroll-thin`,children:[e.content,e.content_truncated?`\n… ${l(`mission.contentTruncated`)}`:``]}):(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-faint`,children:l(`mission.skillUnavailable`)})]},String(e.id)))})]}):null,te.length?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-blue-sky`,children:l(`mission.knowledgeRetained`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:te.slice(-6).map(e=>(0,X.jsx)(`span`,{className:`rounded border border-blue/35 bg-blue/5 px-2 py-1 text-[10px] text-blue-sky`,children:String(e.title||e.id)},String(e.id)))})]}):null,ne?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ink-faint`,children:l(`mission.selfEvolution`)}),(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-dim`,children:l(`mission.knowledgeSaved`)})]}):null,re?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.noCapabilities`)})]})]}),(0,X.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.replay`)}),e.timeline.length>1?(0,X.jsx)(`input`,{type:`range`,min:0,max:e.timeline.length-1,value:_,onChange:e=>v(Number(e.target.value)),"aria-label":l(`mission.replayTimeline`),className:`h-1 min-w-32 flex-1 accent-blue`}):null,N.length?(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(N.length===1?`mission.showingLatestEvent`:`mission.showingLastEvents`,{count:N.length})}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[N.map(e=>{let t=new Date(e.ts*1e3),n=W.role[e.role]??W.inkFaint,r=Ks(e)?l(`mission.roleFailed`,{role:Gs(e.role,l)}):e.title;return(0,X.jsxs)(`article`,{className:`rounded border border-line/60 bg-bg/35 px-3 py-2.5 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${e.tone===`error`?`bg-err`:e.tone===`success`||e.tone===`metric`||e.tone===`skill`?`bg-ok`:`bg-blue`}`}),(0,X.jsx)(`span`,{className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium`,style:{borderColor:n,color:n},children:Gs(e.role,l)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium leading-5 text-ink`,children:r}),(0,X.jsx)(`time`,{dateTime:t.toISOString(),title:t.toLocaleString(c,{dateStyle:`medium`,timeStyle:`short`}),className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:qs(e.ts,c)})]}),e.detail?(0,X.jsx)(Js,{detail:e.detail,previewLength:Ws,textClassName:`leading-5 text-ink-dim`}):null]},e.id)}),e.timeline.length?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.waitingEvents`)})]}),e.artifacts.length?(0,X.jsx)(`div`,{className:`mt-5 flex flex-wrap gap-2 border-t border-line/50 pt-4`,children:e.artifacts.slice(-8).map(e=>{let t=String(e.path||``),n=ee.get(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!t||!i||n?.exists===!1,onClick:()=>t&&i?.(t),title:n?.storage_path||t,className:`rounded border border-line px-2 py-1 font-mono text-[10px] text-blue-sky hover:border-blue-sky/50 disabled:text-ink-faint`,children:String(e.title||l(`research.artifact`))},String(e.id||t))})}):null,o?.available&&(o.status||o.diff)?(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/50 pt-4 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`font-semibold uppercase tracking-[0.14em]`,children:l(`mission.projectFilesChanged`)}),(0,X.jsxs)(`span`,{children:[` · `,l(`mission.reviewInIde`)]})]}):null]})]})}var $s={available:`bg-ok/10 text-ok`,absent:`bg-bg text-ink-faint`,inaccessible:`bg-warn/10 text-warn`,degraded:`bg-warn/10 text-warn`};function ec({status:e,error:t}){let{t:n}=Z();return(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:n(`resource.title`)}),e?(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-[10px] font-semibold uppercase ${e.enforcement===`strict`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:Wi(e.enforcement,n)}):null]}),t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-err`,children:t}):null,!e&&!t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:n(`resource.loading`)}):null,e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.accelerators.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:Ui(e.kind,n)}),(0,X.jsxs)(`span`,{className:`rounded px-2 py-0.5 text-[10px] font-medium ${$s[e.status]}`,children:[zi(e.status,n),` · `,n(`resource.devices`,{count:e.device_count})]})]}),e.detail?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-ink-faint`,children:e.detail}):null]},e.kind))}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 md:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.inUse`,{count:e.holders.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.holders.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.holders.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.devices`,{count:e.device_count})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)}),e.yield_requests.map((e,t)=>(0,X.jsxs)(`div`,{className:`mt-2 border-l-2 border-warn/50 pl-2 text-ink-faint`,children:[(0,X.jsx)(`div`,{children:n(`resource.yieldRequest`,{reason:e.reason})}),e.response?(0,X.jsxs)(`div`,{children:[Gi(e.response.decision,n),` · `,e.response.reason]}):null]},t))]},`${e.project}:${e.task_id}:${t}`))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.queue`,{count:e.queue.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.queue.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.queue.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.queuePosition`,{position:e.position})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)})]},e.position))})]})]})]}):null]})}var tc=e=>e instanceof Error?e.message:String(e||`Unknown error`);async function nc(e){let t=await e,n=t&&typeof t==`object`?t:{},r=String(n.command_status??``);if(Number(n.rc??0)!==0||r===`failed`||r===`rejected`)throw Error(String(n.error||`daemon command ${r||`failed`}`));return t}function rc({open:e,sid:t,snap:n,onClose:i,onChanged:s,onRestored:c}){let{t:l}=Z(),[p,m]=(0,F.useState)(`task`),[g,_]=(0,F.useState)(``),[v,x]=(0,F.useState)(n.session.workdir??n.session.cwd??``),[C,T]=(0,F.useState)(`ls`),[ee,E]=(0,F.useState)(``),[ie,D]=(0,F.useState)(``),[ae,oe]=(0,F.useState)(null),[O,k]=(0,F.useState)(null),[se,A]=(0,F.useState)(null),[ce,le]=(0,F.useState)(``),[j,M]=(0,F.useState)([]),[ue,de]=(0,F.useState)(0),[fe,pe]=(0,F.useState)(``),[N,P]=(0,F.useState)(``),[me,he]=(0,F.useState)(`work`);(0,F.useEffect)(()=>{e&&(x(n.session.workdir??n.session.cwd??``),Promise.all([U.metrics(),U.trash()]).then(([e,t])=>{oe(e),M(t.entries),de(t.total)},e=>E(tc(e))))},[e,n.session.cwd,n.session.workdir]),(0,F.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{try{let e=await U.sourceUpdateStatus();t||k(e)}catch(e){t||E(tc(e))}};U.sourceUpdateStatus().then(async e=>{if(!t&&(k(e),!e.running)){let e=await U.checkSourceUpdate();t||k(e)}}).catch(e=>{t||E(tc(e))});let r=window.setInterval(()=>void n(),1500);return()=>{t=!0,window.clearInterval(r)}},[e]),(0,F.useEffect)(()=>{!e||me!==`system`||(A(null),le(``),U.resources().then(A,e=>le(tc(e))))},[e,me]);let ge=async(e,t,n)=>{if(!N){P(e),E(``);try{let e=await t();n!==null&&E(n||JSON.stringify(e,null,2)),s()}catch(e){E(tc(e))}finally{P(``)}}},_e=async()=>{let e=g.trim();if(e){if(p===`plan`){await ge(`quick`,async()=>{let n=await U.previewPlan(t,e);return E([...n.steps.map((e,t)=>`${t+1}. ${e.title}${e.detail?` — ${e.detail}`:``}`),...n.notes.map(e=>`Note: ${e}`),...n.error?[`Error: ${n.error}`]:[]].join(` `)),n},null);return}await ge(`quick`,p===`task`?()=>U.addTask(t,e):p===`nudge`?()=>U.nudge(t,e):()=>U.note(t,e),`${p} submitted.`),_(``)}},ve=async e=>{await ge(`restore:${e.trash_id}`,async()=>{let t=await U.restoreTrash(e.trash_id);return M(t=>t.filter(t=>t.trash_id!==e.trash_id)),de(e=>Math.max(0,e-1)),await c(t.sid),t},`Restored ${e.label}.`)},ye=n.daemon.alive&&n.daemon.protocol_compatible===!1,be=n.daemon.alive&&n.daemon.control_available===!1,xe=n.daemon_admission?.running_daemons??[],Se=p===`task`?h:p===`nudge`?re:p===`note`?d:y,Ce=l(`operations.action.${p}`),we=async()=>{await ge(`trash-search`,async()=>{let e=await U.trash(fe);return M(e.entries),de(e.total),e},null)};return(0,X.jsxs)(Na,{open:e,onClose:()=>!N&&i(),label:l(`operations.title`),width:`max-w-5xl`,children:[(0,X.jsx)(Pa,{title:l(`operations.title`),sub:n.session.display_name||t}),(0,X.jsx)(`div`,{className:`flex gap-1 overflow-x-auto border-b border-line bg-panel px-4 py-2 scroll-thin`,children:[[`work`,l(`operations.work`),h],[`runtime`,l(`operations.runtime`),b],[`system`,l(`operations.system`),u],[`recovery`,l(`operations.recovery`),a]].map(([e,t,n])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{he(e),E(``)},"aria-current":me===e?`page`:void 0,className:`flex h-8 shrink-0 items-center justify-center gap-2 rounded-md px-3 text-xs font-medium ${me===e?`bg-blue/10 text-blue`:`text-ink-faint hover:bg-bg hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:n}),(0,X.jsx)(`span`,{children:t})]},e))}),(0,X.jsxs)(`div`,{className:`grid max-h-[76vh] gap-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid-cols-2`,children:[me===`work`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.workInput`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.workHint`)}),(0,X.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-1 sm:grid-cols-4`,children:[[`task`,h],[`nudge`,re],[`note`,d],[`plan`,y]].map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m(e),"aria-pressed":p===e,className:`flex h-9 items-center justify-center gap-2 rounded px-2 text-xs font-medium ${p===e?`bg-blue/10 text-blue`:`bg-bg text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:t}),(0,X.jsx)(`span`,{children:l(`operations.action.${e}`)})]},e))}),(0,X.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),rows:5,placeholder:p===`plan`?l(`operations.planPlaceholder`):l(`operations.actionPlaceholder`,{action:p}),className:`mt-3 w-full resize-y rounded border border-line bg-bg p-3 text-sm text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void _e(),disabled:!!N||!g.trim(),className:`mt-2 flex h-9 items-center justify-center gap-2 rounded border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:N===`quick`?`…`:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{icon:Se}),(0,X.jsx)(`span`,{children:p===`plan`?l(`operations.previewPlan`):l(`operations.submitAction`,{action:Ce})})]})})]}):null,me===`runtime`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.runtime`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.runtimeHint`)}),(0,X.jsx)(`label`,{className:`mt-3 block text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.workdir`)}),(0,X.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,X.jsx)(`input`,{value:v,onChange:e=>x(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ge(`cwd`,()=>U.setWorkdir(t,v),l(`operations.workdirUpdated`)),disabled:!!N||!v.trim(),title:l(`operations.applyWorkdir`),"aria-label":l(`operations.applyWorkdir`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:S})})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ge(`reset`,()=>U.resetManager(t),`Manager context reset.`),disabled:!!N,title:l(`operations.resetManager`),"aria-label":l(`operations.resetManager`),className:`flex h-9 w-9 items-center justify-center rounded border border-line text-xs text-ink-dim disabled:opacity-40`,children:(0,X.jsx)(o,{icon:ne})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ge(`upgrade`,()=>nc(U.upgradeDaemon(t,n.daemon_commands?.revision)),`Current-release daemon started after safely draining active work.`),disabled:!!N||be,title:be?`Externally supervised daemon cannot be restarted from this Web host`:ye?`Upgrade incompatible daemon`:`Restart on current release`,"aria-label":be?`Externally supervised daemon`:ye?`Upgrade incompatible daemon`:`Restart on current release`,className:`flex h-9 w-9 items-center justify-center rounded border text-xs disabled:opacity-40 ${ye?`border-err/60 bg-err/10 text-err`:`border-line text-ink-dim`}`,children:(0,X.jsx)(o,{icon:w})})]}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-lg border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:l(`operations.sourceUpdate`)}),(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${O?.state===`failed`?`bg-err/10 text-err`:O?.update_available?`bg-warn/10 text-warn`:O?.update_available===!1?`bg-ok/10 text-ok`:`bg-line text-ink-dim`}`,children:O?.running?l(`operations.updateRunning`):O?.update_available?l(`operations.updateAvailable`):O?.update_available===!1?l(`operations.updateCurrent`):l(`operations.updateChecking`)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:O?.error||O?.message||l(`operations.updateChecking`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 font-mono text-[10px] text-ink-dim`,children:[(0,X.jsxs)(`span`,{children:[l(`operations.currentRevision`),`: `,O?.current_revision?.slice(0,12)||`—`]}),(0,X.jsxs)(`span`,{children:[l(`operations.latestRevision`),`: `,O?.upstream_revision?.slice(0,12)||`—`]}),O?.phase&&O.phase!==`complete`&&O.phase!==`idle`?(0,X.jsxs)(`span`,{children:[l(`operations.updatePhase`),`: `,O.phase]}):null]}),O?.running?(0,X.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded bg-line`,children:(0,X.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded bg-blue`})}):null]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void ge(`source-update`,async()=>{let e=await U.applySourceUpdate();return k(e),e},null),disabled:!!N||!!O?.running||O?.can_update===!1,title:O?.can_update===!1?O.error||l(`operations.updateUnavailable`):l(`operations.pullLatest`),"aria-label":l(`operations.pullLatest`),className:`flex h-9 items-center gap-2 rounded border border-blue/50 px-3 text-xs font-medium text-blue disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:f}),(0,X.jsx)(`span`,{children:O?.running?l(`operations.updateRunning`):l(`operations.pullLatest`)})]})]}),O?.restart_required?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-warn`,children:l(`operations.updateRestart`)}):null]}),n.daemon.protocol_error?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-err`,children:n.daemon.protocol_error}):null,xe.length?(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.replaceSlot`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-1`,children:xe.map(e=>(0,X.jsxs)(`button`,{type:`button`,disabled:!!N,onClick:()=>void ge(`replace:${e.id}`,()=>nc(U.replaceDaemon(t,e.id,!!n.continuous?.enabled,n.daemon_commands?.revision)),`Parked ${e.label||e.id} and started this session.`),title:`Replace ${e.label||e.id}`,"aria-label":`Replace ${e.label||e.id}`,className:`flex w-full items-center justify-between rounded border border-line bg-bg px-2 py-1.5 text-left text-xs text-ink-dim disabled:opacity-40`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.label||e.id}),(0,X.jsx)(o,{icon:w,className:`ml-2 text-warn`})]},e.id))})]}):null]}):null,me===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.skills`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>T(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`,placeholder:`ls, stats, show NAME…`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!N,onClick:()=>void ge(`skills`,async()=>{let e=await U.skills(t,C);return D(e),e},null),title:l(`operations.runSkill`),"aria-label":l(`operations.runSkill`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:r})})]}),ie?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-xs text-ink-dim scroll-thin`,children:ie}):null]}):null,me===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.metrics`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-xs font-semibold ${ae?.slo?.status===`healthy`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:ae?.slo?.status??`loading`}),(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`event validation failures: `,ae?.event_validation_failures??`—`]})]}),ae?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-[10px] text-ink-dim scroll-thin`,children:JSON.stringify({web:ae.web,provider:ae.provider,cost_control:ae.cost_control},null,2)}):null]}):null,me===`system`?(0,X.jsx)(ec,{status:se,error:ce}):null,me===`recovery`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h3`,{className:`mr-auto text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:[l(`operations.trash`),` · `,ue]}),(0,X.jsx)(`input`,{value:fe,onChange:e=>pe(e.target.value),onKeyDown:e=>{!oa(e)&&e.key===`Enter`&&we()},placeholder:l(`operations.searchTrash`),className:`h-8 min-w-52 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!N,onClick:()=>void we(),title:l(`operations.searchTrash`),"aria-label":l(`operations.searchTrash`),className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:te})})]}),j.length?(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:j.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded border border-line bg-bg p-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-ink-faint`,children:e.trash_path})]}),(0,X.jsx)(`button`,{type:`button`,disabled:!!N,onClick:()=>void ve(e),title:`Restore ${e.label}`,"aria-label":`Restore ${e.label}`,className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:a})})]},e.trash_id))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:l(`operations.trashEmpty`)}),ue>j.length?(0,X.jsxs)(`p`,{className:`mt-2 text-[10px] text-ink-faint`,children:[`Showing the newest `,j.length,` matches. Narrow the search to find older sessions.`]}):null]}):null,ee?(0,X.jsx)(`pre`,{className:`rounded-lg border border-line bg-panel p-3 font-mono text-xs whitespace-pre-wrap text-ink-dim lg:col-span-2`,children:ee}):null]})]})}var ic=[`handshake.service`,`handshake.project`,`handshake.ready`];function ac(){let{t:e}=Z(),t=(0,F.useRef)(null);return si(t,(e,t)=>{if(t){e.set(`[data-handshake-line], [data-handshake-node]`,{opacity:1,scale:1,clearProps:`transform`});return}e.to(`[data-handshake-mark]`,{scale:1.055,duration:.75,ease:`sine.inOut`,repeat:-1,yoyo:!0,transformOrigin:`50% 50%`}),e.timeline({repeat:-1,repeatDelay:.25}).fromTo(`[data-handshake-line]`,{scaleX:0,opacity:.25,transformOrigin:`0% 50%`},{scaleX:1,opacity:.8,duration:.9,ease:`power2.inOut`}).fromTo(`[data-handshake-node]`,{autoAlpha:.25,scale:.72},{autoAlpha:1,scale:1,duration:.28,stagger:.16,ease:`back.out(1.8)`},.12).to(`[data-handshake-node]`,{autoAlpha:.35,duration:.3,stagger:.08},`+=0.35`)}),(0,X.jsxs)(`div`,{ref:t,role:`status`,"aria-label":e(`handshake.connecting`),className:`w-full max-w-xl px-6 text-center`,children:[(0,X.jsx)(`div`,{"data-handshake-mark":!0,className:`handshake-mark glass-card mx-auto flex h-16 w-16 items-center justify-center rounded-3xl text-blue shadow-glow sm:h-20 sm:w-20`,children:(0,X.jsx)(ki,{size:48,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative mx-auto mt-8 h-10 max-w-sm sm:max-w-md`,children:[(0,X.jsx)(`div`,{className:`absolute left-[10%] right-[10%] top-3 h-px bg-line/80`}),(0,X.jsx)(`div`,{"data-handshake-line":!0,className:`handshake-line absolute left-[10%] right-[10%] top-3 h-px`}),(0,X.jsx)(`div`,{className:`relative flex justify-between`,children:ic.map(t=>(0,X.jsxs)(`div`,{className:`flex w-20 flex-col items-center gap-2.5`,children:[(0,X.jsx)(`span`,{"data-handshake-node":!0,className:`handshake-node h-6 w-6 rounded-full border ring-4 ring-bg`,children:(0,X.jsx)(`span`,{className:`m-auto mt-[7px] block h-2 w-2 rounded-full bg-blue`})}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-ink-faint`,children:e(t)})]},t))})]}),(0,X.jsx)(`p`,{className:`mt-9 text-base font-medium text-ink-dim`,children:e(`handshake.title`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-ink-faint`,children:e(`handshake.detail`)})]})}function oc({loading:e,hasProjects:t,error:n,onRetry:r,onNew:i,onChoose:a,canCreate:o}){let{t:s}=Z();return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 text-center`,children:[e?(0,X.jsx)(ac,{}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ji,{size:32,tag:sa}),(0,X.jsx)(`p`,{className:`max-w-md text-sm leading-relaxed ${n?`text-err`:`text-ink-faint`}`,children:n||s(t?`landing.selectOrCreate`:`landing.noSessions`)})]}),!e&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[n?(0,X.jsx)(_i,{onClick:r,variant:`danger`,children:s(`common.retry`)}):null,t?(0,X.jsx)(_i,{onClick:a,children:s(`landing.select`)}):o?(0,X.jsx)(_i,{onClick:i,variant:`primary`,children:s(`landing.new`)}):null]})]})}function sc({active:e,onSelect:t,onOpenSessions:n,sidebarOpen:r=!1}){let{t:a}=Z(),s=[{id:`mission`,label:a(`mobile.mission`),icon:y},{id:`activity`,label:a(`mobile.activity`),icon:l},{id:`workbench`,label:a(`mobile.workbench`),icon:p},{id:`map`,label:a(`mobile.map`),icon:y},{id:`preview`,label:a(`mobile.preview`),icon:i}];return(0,X.jsxs)(`nav`,{"aria-label":a(`mobile.views`),className:`mobile-tabbar glass-panel glass-panel--raised fixed inset-x-0 bottom-0 z-40 items-stretch border-t border-line/60 lg:hidden ${r?`hidden`:`flex`}`,children:[n?(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":a(`topbar.openSessions`),className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 text-ink-faint active:bg-panel-raised`,children:[(0,X.jsx)(o,{icon:_,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:a(`mobile.sessions`)})]}):null,s.map(n=>{let r=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),"aria-current":r?`page`:void 0,className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 active:bg-panel-raised ${r?`text-blue`:`text-ink-faint`}`,children:[(0,X.jsx)(o,{icon:n.icon,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:n.label})]},n.id)})]})}function cc(){(0,F.useEffect)(()=>{let e=window.visualViewport,t=document.documentElement;if(!e)return;let n=null,r=()=>{n!=null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let n=window.innerHeight-e.height-e.offsetTop,r=n>24?Math.round(n):0;t.style.setProperty(`--keyboard-inset`,`${r}px`)})};return r(),e.addEventListener(`resize`,r),e.addEventListener(`scroll`,r),()=>{n!=null&&window.cancelAnimationFrame(n),e.removeEventListener(`resize`,r),e.removeEventListener(`scroll`,r),t.style.removeProperty(`--keyboard-inset`)}},[])}async function lc(e,t){let n=Ht(e.trim());if(!n)return{kind:`not-command`};if(!n.cmd){let e=Ut(n.name);return{kind:`error`,message:e?`Unknown command ${n.name}. Did you mean ${e}?`:`Unknown command ${n.name}. Use /help for the full list.`}}if(n.cmd.id===`ask`)return{kind:`not-command`};if(Ft(n.cmd)&&!n.rest)return{kind:`error`,message:`Usage: ${n.cmd.name}${n.cmd.arg?` ${n.cmd.arg}`:``}`};try{await t[n.cmd.id](n.rest)}catch(e){return{kind:`error`,message:e instanceof Error?e.message:String(e??`Command failed`)}}return{kind:`handled`}}function uc({activeSid:e,activityEventsRef:t,notify:n,onClearEvents:r,onDispose:i,onOpenConfig:a,onOpenDoctor:o,onOpenHelp:s,onOpenIdentity:c,onOpenInspector:l,onOpenNewDaemon:u,onOpenOperations:d,onOpenSidebar:f,onReconnectEvents:p,onRenameProject:m,onRewriteDraft:h,onSelectProject:g,onSetArtifactPath:_,onSetEventFilter:v,onSetEventQuery:y,onSetTaskItemId:b,onSetWorkspaceView:x,onShowArtifacts:S,onStopIteration:C,onStopWaiting:w,refetchSnapshot:T}){return{status:async()=>l(),roles:async()=>d(),journal:async()=>l(),backlog:async()=>x(`mission`),item:async e=>{e&&b(e)},artifacts:async()=>S(),artifact:async e=>{e&&_(e)},events:async e=>{x(`activity`);let{filter:t,query:n}=Vt(e);v(t),y(n)},find:async e=>{x(`activity`),v(`all`),y(e)},run:async()=>x(`activity`),clear:async()=>{x(`activity`),v(`all`),y(``),r(t.current.length)},cancel:async()=>w(),task:async t=>{e&&(await U.addTask(e,t),T(),n(`success`,`Task queued.`))},rewrite:async e=>{let t=e.trim();if(!t){n(`info`,`Type your prompt in the composer and press Rewrite, or use /rewrite .`);return}h(t)},plan:async t=>{if(!e)return;let r=await U.previewPlan(e,t);r.error?n(`error`,r.error):n(`info`,r.steps.map(e=>e.title).join(` -`)||`Plan preview ready.`)},nudge:async t=>{e&&(await U.nudge(e,t),n(`success`,`Guidance injected.`))},abort:async t=>{e&&(await U.abortMission(e,t||`operator abort`),n(`info`,`Abort requested.`))},note:async t=>{e&&(await U.note(e,t),n(`success`,`Note appended to timeline.`))},done:async e=>{e&&i(e,`done`)},skip:async e=>{e&&i(e,`rm`)},stop:async e=>{e&&C(e)},new:async()=>u(),daemons:async()=>f(),resume:async e=>{e&&e!==`list`?g(e):f()},attach:async e=>{e&&g(e)},rename:async t=>{!e||!t||await m(t)},doctor:async()=>o(),backend:async t=>{if(!e||!t){a();return}await U.setConfig(e,`runner_backend`,t),n(`success`,`Backend set to ${t}.`)},config:async t=>{if(!e||!t){a();return}let r=t.indexOf(`=`);r>0?(await U.setConfig(e,t.slice(0,r).trim(),t.slice(r+1).trim()),n(`success`,`Config updated.`)):a()},identity:async()=>c(),reset:async()=>{e&&(await U.resetManager(e),n(`success`,`Manager context reset.`))},skills:async t=>{e&&n(`info`,(await U.skills(e,t||`ls`)).slice(0,400))},reconnect:async()=>p(),help:async()=>s(),quit:async()=>n(`info`,`Background work continues; close this browser tab when ready.`)}}function dc(e){return e.kind===`error`?(typeof e.reply==`string`?e.reply.trim():``)||`Manager could not handle this message.`:null}function Q(e,t){e.kind===`task`&&t.dispatchTask(e);let n=dc(e);n&&t.notifyError(n),t.refetchTranscript()}var fc={skipFirst:0,reconnectKey:0};function pc(e,t){return t.kind===`clear`?{...e,skipFirst:Math.max(0,t.offset)}:t.kind===`reconnect`?{skipFirst:0,reconnectKey:e.reconnectKey+1}:{...e,skipFirst:0}}var mc=`local_request_id`;function hc(e,t,n,r=Date.now()){return{type:`ui.operator`,agent_layer:`operator`,text:n,ts:r/1e3,event_id:`local-${e}-${t}-operator`,message_id:`local-${t}-operator`,[mc]:t}}function gc(e,t,n,r,i,a=Date.now(),o=`auto`){let s=r.trim();if(!s)return e;let c=e.findIndex(e=>e.type===`ui.argus`&&Number(e[mc])===n),l=i.endsWith(`-argus`)?`${i.slice(0,-6)}-operator`:``,u=l?e.map(e=>e.type===`ui.operator`&&Number(e[mc])===n?{...e,message_id:l}:e):e,d=u.find(e=>e.type===`ui.operator`&&Number(e[mc])===n),f=d?Math.max(0,a-Number(d.ts??a/1e3)*1e3):0;if(c<0)return[...u,{type:`ui.argus`,agent_layer:`manager`,text:s,ts:a/1e3,event_id:`local-${t}-${n}-argus`,message_id:i||`local-${n}-argus`,fragment_mode:o,response_latency_ms:f,[mc]:n}];let p=u[c],m=[...u];return m[c]={...p,text:kt(String(p.text??``),s,o),message_id:i||p.message_id,fragment_mode:o},m}function _c(e,t,n){let r=new Map;e.forEach(e=>{let t=String(e.type??``);if(t!==`ui.operator`&&t!==`ui.argus`)return;let n=`${t}\u0000${String(e.text??``)}`;r.set(n,(r.get(n)??0)+1)});let i=t.map(e=>({type:e.role===`operator`?`ui.operator`:`ui.argus`,agent_layer:e.role===`operator`?`operator`:`manager`,text:e.text,ts:e.ts,message_id:e.message_id||`transcript-${e.ts}-${e.role}`,...e.mission_result===!0?{mission_result:!0}:{},...typeof e.item_id==`string`?{item_id:e.item_id}:{},...typeof e.success==`boolean`?{success:e.success}:{},...typeof e.summary==`string`?{summary:e.summary}:{},...typeof e.delivery_id==`string`?{delivery_id:e.delivery_id}:{},...e.delivery&&typeof e.delivery==`object`?{delivery:e.delivery}:{}})),a=Array(i.length).fill(!0);for(let e=i.length-1;e>=0;--e){let t=i[e],n=`${String(t.type)}\u0000${String(t.text??``)}`,o=r.get(n)??0;o>0&&(a[e]=!1,r.set(n,o-1))}let o=[...i.filter((e,t)=>a[t]),...e],s=Array(o.length).fill(!0),c=new Set,l=n.map(e=>{let t=String(e.message_id??``),n=t?o.findIndex((e,n)=>!c.has(n)&&String(e.message_id??``)===t):-1,r=Number(e.ts??0);if(n<0&&(n=o.findIndex((t,n)=>{if(c.has(n)||t.type!==e.type||t.text!==e.text)return!1;let i=Number(t.ts??0);return Math.abs(i-r)<=5})),n>=0){c.add(n),s[n]=!1;let t=o[n];return{...e,...t.mission_result===!0?{mission_result:!0}:{},...typeof t.item_id==`string`?{item_id:t.item_id}:{},...typeof t.success==`boolean`?{success:t.success}:{},...typeof t.summary==`string`?{summary:t.summary}:{},...typeof t.delivery_id==`string`?{delivery_id:t.delivery_id}:{},...t.delivery&&typeof t.delivery==`object`?{delivery:t.delivery}:{}}}return e});return[...o.filter((e,t)=>s[t]),...l].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0))}function vc(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,spend_usd:t.spend_usd,known_cost_usd:t.known_cost_usd,spend_status:t.spend_status,usage_calls:t.usage_calls,premium_requests:t.premium_requests,cost_updated_at:t.updated_at}:e})}async function yc(e,t,n,r=``){let i=await e.createDaemon(``,t,r),a=n.trim();return{created:i,startCampaign:a?()=>e.setContinuous(i.sid,!0,a):null}}var bc=e=>e instanceof Error?e.message:String(e||`Unknown error`);function xc({localCwd:e,notify:t,onFocusComposer:n,queryClient:r,refetchProjects:i,selectProject:a}){let[o,s]=(0,F.useState)(!1),c=(0,F.useRef)(!1);return{createDaemon:async(o,l,u)=>{if(c.current)return!1;c.current=!0,s(!0);try{let{created:s,startCampaign:c}=await yc(U,o,l,u),d=String(s.workdir||u||``);return r.setQueryData([`projects`],t=>({local_cwd:t?.local_cwd??e,projects:[{id:s.sid,label:o||s.sid,display_name:o,objective:``,launch_cwd:d,workdir:d,last_active:Date.now()/1e3,daemon_alive:!1,daemon_pid:null,uptime_seconds:null},...(t?.projects??[]).filter(e=>e.id!==s.sid)]})),a(s.sid),i(),window.setTimeout(n,0),t(c?`info`:`success`,c?`Session created and selected. Campaign is starting in the background.`:`Session created and selected.`),c&&c().then(()=>{r.invalidateQueries({queryKey:[`snapshot`,s.sid]}),i(),t(`success`,`Campaign started.`)}).catch(e=>{t(`error`,`Session was created, but the campaign could not start: ${bc(e)}`)}),!0}catch(e){return t(`error`,`Could not create session: ${bc(e)}`),!1}finally{c.current=!1,s(!1)}},creatingDaemon:o}}var Sc=e=>e instanceof Error?e.message:String(e||`Unknown error`);function Cc({actions:e,manageActions:t,manageTargetSid:n,setManageTargetSid:r,activeSid:i,clearProjectSelection:a,continuous:o,notify:s,refetchProjects:c,selectProject:l,setDaemonManageOpen:u}){let d=e.startDaemon.isPending||e.stopDaemon.isPending||e.forceStopDaemon.isPending||t.startDaemon.isPending||t.forceStopDaemon.isPending||t.updateProject.isPending||t.deleteProject.isPending,f=(0,F.useCallback)(e=>({onSuccess:()=>s(`success`,e),onError:e=>s(`error`,Sc(e))}),[s]),p=(0,F.useCallback)(()=>e.startDaemon.mutate(void 0,f(`Daemon start requested.`)),[f,e.startDaemon]),m=(0,F.useCallback)(()=>e.forceStopDaemon.mutate(void 0,f(`Stop requested; the verified daemon process is being interrupted.`)),[f,e.forceStopDaemon]),h=(0,F.useCallback)(async()=>{try{return await t.startDaemon.mutateAsync(),s(`success`,`Daemon resumed.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[t.startDaemon,s]),g=(0,F.useCallback)(async()=>{try{return await t.forceStopDaemon.mutateAsync(),await c(),s(`success`,`Daemon stopped. This session can now be deleted.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[t.forceStopDaemon,s,c]),_=(0,F.useCallback)(async e=>{if(!n)return!1;try{return await t.updateProject.mutateAsync({sid:n,name:e}),s(`success`,`Session name updated.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[t.updateProject,n,s]),v=(0,F.useCallback)(async()=>{if(!n)return!1;try{let e=n,o=await t.deleteProject.mutateAsync();u(!1),r(null);let d=await c();if(e===i){a(`replace`);let e=Dn(d.data?.projects??[])[0];e&&l(e.id,`replace`)}return s(`success`,o.workdir_preserved?`Session moved to recoverable trash. Files remain in ${o.workdir}.`:`Session moved to recoverable trash.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[i,a,t.deleteProject,n,s,c,l,u,r]),y=(0,F.useCallback)(e=>{r(e),u(!0)},[u,r]);return{daemonBusy:d,manageDeleteProject:v,manageStopDaemon:g,manageRenameProject:_,manageStartDaemon:h,requestDispose:(0,F.useCallback)((t,n)=>e.disposeBacklog.mutate({id:t,op:n},{onSuccess:()=>s(`success`,n===`done`?`Work marked done.`:`Work removed.`),onError:e=>s(`error`,Sc(e))}),[e.disposeBacklog,s]),requestManageSession:y,requestStartDaemon:p,requestStopDaemon:m,requestStopIteration:(0,F.useCallback)(t=>e.stopBacklog.mutate(t,{onSuccess:()=>s(`success`,`Iteration stopped.`),onError:e=>s(`error`,Sc(e))}),[e.stopBacklog,s]),toggleContinuous:(0,F.useCallback)(()=>{if(!o)return;let t=!o.enabled;e.setContinuous.mutate({enabled:t,objective:o.objective},f(t?`Continuous campaign enabled.`:`Continuous campaign stopped.`))},[f,e.setContinuous,o])}}function wc({focusComposer:e,openHelp:t,toggleKiosk:n,togglePalette:r,toggleReasoning:i,toggleSidebarCollapse:a}){(0,F.useEffect)(()=>{let o=o=>{let s=o.target,c=s?.tagName===`INPUT`||s?.tagName===`TEXTAREA`,l=o.metaKey||o.ctrlKey;l&&o.key.toLowerCase()===`k`?(o.preventDefault(),r()):l&&o.key.toLowerCase()===`t`?(o.preventDefault(),i()):l&&o.key===`.`?(o.preventDefault(),n()):l&&o.key.toLowerCase()===`b`?(o.preventDefault(),a()):l&&o.key.toLowerCase()===`j`?(o.preventDefault(),e()):!c&&o.key===`?`?(o.preventDefault(),t()):!c&&o.key===`/`&&(o.preventDefault(),e())};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[e,t,n,r,i,a])}var Tc=e=>e instanceof Error?e.message:String(e||`Unknown error`);function Ec({activeSid:e,backlog:t,notify:n,pendingQuestions:r,refetchSnapshot:i}){let[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(``),u=(0,F.useMemo)(()=>{let e=(t??[]).map(e=>({...e,operator_decision:e.operator_decision}));return _t(r??[],e)[0]??null},[t,r]);return(0,F.useEffect)(()=>{if(!u||!e){o(!1);return}let t=`${e}:${u.id}`;l.current!==t&&(l.current=t,o(!0))},[e,u]),{answerPendingReply:async(t,r)=>{if(!(!e||!u||s)){c(!0);try{let a=u.legacy?await U.answerPending(e,u.item_id,r):await U.resolveDecision(e,u.id,t,r);if(a.resolved===!1){n(`info`,String(a.reply||`Manager needs a more specific answer.`));return}o(!1),await i(),a.daemon&&Number(a.daemon.rc??0)!==0?n(`error`,`Answer queued, but the daemon did not start: ${a.daemon.error||`operator action required`}`):n(`success`,String(a.reply||`Manager delivered your answer to the team.`))}catch(e){await i(),n(`error`,`Could not send answer: ${Tc(e)}`)}finally{c(!1)}}},pendingReply:u,pendingReplyBusy:s,pendingReplyOpen:a,setPendingReplyOpen:o}}var Dc=`argus.browser.project.v1`;function Oc(){try{return window.sessionStorage.getItem(Dc)}catch{return null}}function kc(e){try{e?window.sessionStorage.setItem(Dc,e):window.sessionStorage.removeItem(Dc)}catch{}}function Ac(e,t){let n=new URL(window.location.href);e?n.searchParams.set(`project`,e):n.searchParams.delete(`project`);let r=t===`push`?`pushState`:`replaceState`;window.history[r](window.history.state,``,n.toString())}function jc({cancelActiveMessage:e,notify:t,projects:n,projectsError:r,projectsReady:i,queryClient:a,setArtifactPath:o,setSidebarOpen:s,setTaskItemId:c}){let l=new URLSearchParams(window.location.search),[u,d]=(0,F.useState)(l.get(`project`)||Oc()),f=(0,F.useRef)(u),p=(0,F.useRef)(!1);f.current=u;let m=(0,F.useCallback)(t=>{t!==f.current&&(e(),o(null),c(null)),f.current=t,d(t),kc(t)},[e,o,c]),h=(0,F.useCallback)((e,t=`push`)=>{let n=new URLSearchParams(window.location.search).get(`project`);m(e),n!==e&&Ac(e,t)},[m]),g=(0,F.useCallback)((e=`replace`)=>{let t=new URLSearchParams(window.location.search).get(`project`);m(null),t!=null&&Ac(null,e)},[m]),_=(0,F.useCallback)(e=>{a.prefetchQuery({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.prefetchSnapshot(e,t),staleTime:3e3})},[a]);return(0,F.useEffect)(()=>{if(!i)return;let e=p.current,r=An(n,f.current,e);if(!e&&(p.current=!0,r.id===f.current?kc(r.id):m(r.id),new URLSearchParams(window.location.search).get(`project`)!==r.id&&Ac(r.id,`replace`),r.recovered)){let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}},[m,t,n,i]),(0,F.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get(`project`);if(s(!1),!e){m(null);return}if(!i){m(e);return}let r=kn(n,e);if(m(r.id),r.recovered){Ac(r.id,`replace`);let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,t,n,i,s]),{activateProject:m,activeSid:i?u&&n.some(e=>e.id===u)?u:null:r?u:null,clearProjectSelection:g,prefetchProject:_,selectProject:h,sid:u,sidRef:f}}function Mc(e){try{return globalThis.localStorage?.getItem(e)??null}catch{return null}}function Nc(e,t){try{return globalThis.localStorage?.setItem(e,t),!!globalThis.localStorage}catch{return!1}}var Pc=`argus.themeStyle`;function Fc(){return Mc(`argus.themeStyle`)===`gradient`?`gradient`:`standard`}function Ic(e,t){let n=Mc(e);return n==null?t:n===`true`}function Lc(e){document.documentElement.dataset.theme=e,window.parent!==window&&window.parent.postMessage({type:`argus:theme-changed`,payload:e},`*`)}function Rc(){let e=new URLSearchParams(window.location.search),[t,n]=(0,F.useState)(e.get(`kiosk`)===`1`),[r,i]=(0,F.useState)(()=>Ic(`argus.reasoning.visible.v1`,!1)),[a,o]=(0,F.useState)(()=>{let t=e.get(`view`);if(t===`mission`||t===`activity`||t===`workbench`||t===`map`)return t;let n=Mc(`argus.workspace.view`);return n===`mission`||n===`activity`||n===`workbench`||n===`map`?n:`map`}),[s,c]=(0,F.useState)(`activity`),[l,u]=(0,F.useState)(()=>Ic(`argus.preview.expanded.v5`,!0)),[d,f]=(0,F.useState)(()=>{let e=Number(Mc(`argus.sidebar.width.v2`)||256);return Number.isFinite(e)?Math.max(220,Math.min(400,e)):256}),[p,m]=(0,F.useState)(()=>{let e=Number(Mc(`argus.preview.width.v2`)||440);return Number.isFinite(e)?Math.max(320,Math.min(600,e)):440}),[h,g]=(0,F.useState)(!1),[_,v]=(0,F.useState)(()=>Ic(`argus.sidebar.expanded.v4`,!0)),[y,b]=(0,F.useState)(()=>{let e=Mc(`argus.theme`);return e===`light`||e===`dark`?e:null}),[x,S]=(0,F.useState)(Fc),[C,w]=(0,F.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches),T=y??(C?`dark`:`light`),ee=(0,F.useRef)(T),E=(0,F.useRef)(null),te=(0,F.useRef)(null);(0,F.useEffect)(()=>{Nc(`argus.sidebar.expanded.v4`,String(_)),Nc(`argus.preview.expanded.v5`,String(l)),Nc(`argus.sidebar.width.v2`,String(d)),Nc(`argus.preview.width.v2`,String(p))},[_,d,l,p]),(0,F.useEffect)(()=>{Nc(`argus.workspace.view`,a)},[a]),(0,F.useEffect)(()=>{Nc(`argus.reasoning.visible.v1`,String(r))},[r]),(0,F.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>w(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,F.useEffect)(()=>{ee.current=T,Lc(T)},[T]),(0,F.useEffect)(()=>{document.documentElement.dataset.themeStyle=x},[x]);let ne=(0,F.useCallback)(()=>{let e=ee.current===`light`?`dark`:`light`;ee.current=e,Lc(e),Nc(`argus.theme`,e),(0,F.startTransition)(()=>b(e))},[]),re=(0,F.useCallback)(e=>{S(e),Nc(Pc,e)},[]),ie=(0,F.useCallback)((e,t)=>{let n=E.current;if(!n)return;t.preventDefault();let r=n.getBoundingClientRect(),i=e===`left`?d:p;n.dataset.resizing=e,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let a=t=>{if(e===`left`){let e=l?p+8:56,n=Math.max(220,Math.min(400,r.width-e-360-8));i=Math.max(220,Math.min(n,t.clientX-r.left))}else{let e=_?d+8:56,n=Math.max(320,Math.min(600,r.width-e-360-8));i=Math.max(320,Math.min(n,r.right-t.clientX))}te.current??=window.requestAnimationFrame(()=>{n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),te.current=null})},o=()=>{te.current!=null&&window.cancelAnimationFrame(te.current),te.current=null,n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),e===`left`?f(i):m(i),delete n.dataset.resizing,document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})},[_,d,l,p]);return(0,F.useEffect)(()=>{let e=()=>{if(window.innerWidth<1024||!E.current)return;let e=E.current.clientWidth,t=_?d:56,n=l?p:56,r=(_?8:0)+(l?8:0),i=Math.max(540,e-360-r);if(t+n<=i)return;let a=l?Math.max(320,Math.min(p,i-t)):n,o=_?Math.max(220,Math.min(d,i-a)):t;o+a>i&&l&&(a=Math.max(320,i-o)),_&&f(o),l&&m(a)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_,d,l,p]),{cycleTheme:ne,kiosk:t,leftPanelOpen:_,leftWidth:d,mobileView:s,resizeSidebar:ie,rightPanelOpen:l,rightWidth:p,setKiosk:n,setLeftPanelOpen:v,setLeftWidth:f,setMobileView:c,setRightPanelOpen:u,setRightWidth:m,setShowReasoning:i,setSidebarOpen:g,setThemeStyle:re,setWorkspaceView:o,shellRef:E,showReasoning:r,sidebarOpen:h,themeMode:T,themeStyle:x,workspaceView:a}}function zc(e){let t=e.trim();if(!t||/\s/.test(t))return``;if(!t.includes(`?`)&&!t.includes(`://`))return t;try{return new URL(t,window.location.href).searchParams.get(`token`)?.trim()??``}catch{return``}}function Bc({error:e,onRetry:t}){let{t:n}=Z(),r=Qe(e),i=e instanceof Ze,[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``);return!r&&!i?null:(0,X.jsxs)(`div`,{role:`alert`,className:`fixed left-1/2 top-3 z-[100] flex w-[min(92vw,42rem)] -translate-x-1/2 flex-wrap items-start gap-3 rounded-xl border border-err/50 bg-panel/95 px-4 py-3 text-left text-sm text-ink shadow-xl backdrop-blur`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 font-mono font-bold text-err`,children:`!`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`strong`,{className:`block text-err`,children:n(r?`connection.pairingTitle`:`connection.unreachableTitle`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-ink-dim`,children:n(r?`connection.pairingDetail`:`connection.unreachableDetail`)})]}),r&&!a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`shrink-0 rounded-md border border-blue/45 bg-blue/10 px-2.5 py-1 text-xs font-medium text-blue hover:bg-blue/15`,children:n(`connection.pairAgain`)}):r?null:(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-md border border-err/40 px-2.5 py-1 text-xs text-err hover:bg-err/10`,children:n(`common.retry`)}),r&&a?(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=zc(s);if(!t){u(n(`connection.pairingInvalid`));return}let r=new URL(window.location.href);r.searchParams.set(`token`,t),window.location.replace(r.toString())},className:`flex w-full basis-full flex-wrap gap-2 pl-7`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`pairing-link`,children:n(`connection.pairingInput`)}),(0,X.jsx)(`input`,{id:`pairing-link`,"data-autofocus":!0,type:`password`,autoComplete:`off`,value:s,onChange:e=>{c(e.target.value),u(``)},placeholder:n(`connection.pairingPlaceholder`),className:`h-9 min-w-0 flex-1 rounded-md border border-line bg-bg px-3 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`submit`,className:`h-9 rounded-md border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white`,children:n(`connection.connect`)}),l?(0,X.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-err`,children:l}):null]}):null]})}function $(e){try{let t=JSON.parse(Mc(e)||`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Vc(e,t,n,r=!0){let i=(0,F.useRef)(),[a,o]=(0,F.useState)(null),s=(0,F.useCallback)(t=>{if(!e)return;let n=`argus.delivery.seen.v1:${e}`;Nc(n,JSON.stringify([...new Set([...$(n),t])].slice(-80)))},[e]),c=(0,F.useCallback)(t=>{e&&(s(t.delivery_id),o({sid:e,receipt:t,path:Qr(t)[0]?.path||null}))},[e,s]);return(0,F.useEffect)(()=>{if(!e||!t)return;let a=n?.delivery_id;if(i.current?.sid!==e){i.current={sid:e,ids:new Set(a?[a]:[])},o(null);return}!a||i.current.ids.has(a)||!r||(i.current.ids.add(a),n&&Qr(n).length&&!$(`argus.delivery.seen.v1:${e}`).includes(a)&&c(n))},[e,t,n,c,r]),{selection:a?.sid===e?a:null,open:c,close:(0,F.useCallback)(()=>o(null),[]),selectPath:(0,F.useCallback)(e=>o(t=>t&&{...t,path:e}),[])}}var Hc=0,Uc=(0,F.lazy)(async()=>({default:(await ai(()=>import(`./ResearchWorkbenchPanel-BemKoueL.js`),__vite__mapDeps([2,1,3,4,5,6,7,8]))).ResearchWorkbenchPanel})),Wc=(0,F.lazy)(async()=>({default:(await ai(()=>import(`./MapPanel-aVcW4FvE.js`),__vite__mapDeps([9,1,3,4,5,6,7,10]))).MapPanel}));function Gc(){let{locale:e,t}=Z(),n=ce(),r=_r(),i=vr(),a=(0,F.useMemo)(()=>Dn(vc(r.data?.projects??[],i.data?.projects??[])),[i.data?.projects,r.data?.projects]),s=r.data?.local_cwd??``,c=[r.error,i.error].find(e=>$e(e)),[l,u]=(0,F.useState)(`none`),{cycleTheme:d,kiosk:f,leftPanelOpen:p,leftWidth:m,mobileView:h,resizeSidebar:g,rightPanelOpen:_,rightWidth:v,setKiosk:y,setLeftPanelOpen:b,setLeftWidth:x,setMobileView:S,setRightPanelOpen:C,setRightWidth:w,setShowReasoning:T,setSidebarOpen:E,setThemeStyle:te,setWorkspaceView:ne,shellRef:re,showReasoning:ie,sidebarOpen:D,themeMode:ae,themeStyle:oe,workspaceView:O}=Rc(),[k,se]=(0,F.useState)(()=>O===`mission`?`mission`:`activity`),[A,le]=(0,F.useState)(O===`workbench`);(0,F.useEffect)(()=>{if(O===`workbench`){le(!0);return}O!==`map`&&se(O)},[O]),cc();let[j,M]=(0,F.useState)(0),[ue,de]=(0,F.useState)(``),[fe,pe]=(0,F.useState)(!1),[N,P]=(0,F.useState)(0),[me,he]=(0,F.useState)(Rr),[ge,_e]=(0,F.useState)(!1),[ve,ye]=(0,F.useState)([]),[be,xe]=(0,F.useState)([]),[Se,Ce]=(0,F.useState)(null),[we,Te]=(0,F.useState)({path:``,token:0}),[Ee,De]=(0,F.useState)(null),[Oe,ke]=(0,F.useState)(!1),[Ae,je]=(0,F.useState)(!1),[Me,Ne]=(0,F.useState)(null),[Pe,Fe]=(0,F.useState)(null),Ie=(0,F.useRef)(!1),Le=(0,F.useRef)(null),Re=(0,F.useRef)(0),ze=(0,F.useRef)(),Be=(0,F.useRef)({sid:``,completionId:``,view:null,artifacts:[]}),Ve=(0,F.useRef)(null),[He,Ue]=(0,F.useState)(null),[We,Ge]=(0,F.useReducer)(pc,fc),[Ke,qe]=(0,F.useState)(`all`),[Je,Ye]=(0,F.useState)(``),Xe=(0,F.useCallback)(()=>Ue(null),[]);(0,F.useEffect)(()=>{try{localStorage.setItem(Lr,me)}catch{}},[me]);let I=(0,F.useCallback)((e,t)=>{Ue({id:++Hc,tone:e,message:t})},[]),Ze=(0,F.useCallback)(()=>{let e=!!Le.current;return Re.current+=1,Le.current?.controller.abort(),Le.current=null,_e(!1),xe([]),e},[]),Qe=(0,F.useCallback)(()=>{Ze()&&I(`info`,`Stopped waiting for this reply. Server-side work may still finish in the project timeline.`)},[Ze,I]),{activeSid:L,clearProjectSelection:et,prefetchProject:R,selectProject:z,sidRef:tt}=jc({cancelActiveMessage:Ze,notify:I,projects:a,projectsError:r.isError,projectsReady:r.isSuccess,queryClient:n,setArtifactPath:Ce,setSidebarOpen:E,setTaskItemId:De});(0,F.useEffect)(()=>()=>{Re.current+=1,Le.current?.controller.abort(),Le.current=null},[]),(0,F.useEffect)(()=>Ko(),[]);let nt=(0,F.useCallback)(e=>{let t=(e||``).trim(),n=tt.current;!t||!n||fe||(pe(!0),U.rewritePrompt(n,t).then(e=>{if(pe(!1),e.error||!e.rewritten.trim()){I(`error`,`Rewrite failed: ${e.error||`empty rewrite`} — your prompt is unchanged`);return}de(e.rewritten),M(e=>e+1);let t=e.questions.length?` Manager asks: ${e.questions.join(` · `)}`:``;I(`success`,`Prompt rewritten — review it, then send.${t}`)},e=>{pe(!1),I(`error`,`Rewrite failed: ${pi(e)} — your prompt is unchanged`)}))},[I,fe,tt]),{createDaemon:rt,creatingDaemon:it}=xc({localCwd:s,notify:I,onFocusComposer:()=>M(e=>e+1),queryClient:n,refetchProjects:r.refetch,selectProject:z});(0,F.useEffect)(()=>Go(()=>ke(!0)),[]);let B=yr(L),at=yr(Me),V=B.data,H=V?.session.id===L?L:null,ot=V?.continuous,st=Tr(H,!0),ct=Dr(H,k===`mission`),{events:lt,connected:ut}=Ir(H,We.reconnectKey),dt=(0,F.useMemo)(()=>Nr(lt),[lt]),W=(0,F.useMemo)(()=>Fr(lt),[lt]);(0,F.useEffect)(()=>{if(!H||!dt)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},180);return()=>window.clearTimeout(e)},[dt,H,n]),(0,F.useEffect)(()=>{if(!H||!W)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`snapshot`,H],exact:!0})},80);return()=>window.clearTimeout(e)},[H,n,W]);let ft=(0,F.useMemo)(()=>Rn(lt),[lt]),pt=wr(H,k===`activity`,120),mt=br(L,20,l===`inspector`),{answerPendingReply:ht,pendingReply:gt,pendingReplyBusy:_t,pendingReplyOpen:G,setPendingReplyOpen:vt}=Ec({activeSid:L,backlog:V?.backlog,notify:I,pendingQuestions:V?.pending_questions,refetchSnapshot:B.refetch}),yt=(0,F.useMemo)(()=>_c(lt,pt.data??[],ve),[lt,ve,pt.data]),bt=(0,F.useMemo)(()=>V?xn(V,yt,st.data??[]):null,[yt,st.data,V]),xt=ei((0,F.useMemo)(()=>na(yt),[yt]),bt?.delivery??null,yt),St=V?.backlog.some(e=>[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))??!1,Ct=Qo(bt)&&!St&&!V?.continuous?.enabled,wt=H&&Ct&&bt?.mission.id?`completion:${H}:${bt.mission.id}`:``;Ve.current=xt,Be.current={sid:H||``,completionId:wt,view:bt,artifacts:st.data??[]};let Tt=(0,F.useCallback)(e=>{let t=e.trim();if(!t){ne(`mission`);return}if(O===`map`){Ce(t);return}C(!0),S(`preview`),Te(e=>({path:t,token:e.token+1}))},[S,C,ne,O]),Et=Vc(H,!!V&&!pt.isPending,xt,!Se&&!ti(V?.backlog??[],xt?.item_id)),Dt=Et.open,Ot=(0,F.useMemo)(()=>{let e=new Map;for(let t of yt){let n=t.delivery;n?.delivery_id&&Array.isArray(n.targets)&&e.set(n.delivery_id,n)}for(let t of[bt?.delivery,xt])t&&e.set(t.delivery_id,t);return[...e.values()].filter(e=>Qr(e).length).sort((e,t)=>t.delivered_at-e.delivered_at)},[yt,bt?.delivery,xt]);(0,F.useEffect)(()=>{H&&xt?.delivery_id&&n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},[H,xt?.delivery_id,n]),(0,F.useEffect)(()=>{if(!H)return;let e=ze.current;if(!e||e.sid!==H){ze.current={sid:H,id:wt||null};return}if(!wt){ze.current={sid:H,id:null};return}if(e.id===wt)return;let n=window.setTimeout(()=>{let e=Be.current;if(e.sid!==H||e.completionId!==wt||!e.view)return;let n=e.view.delivery,r=rs(e.artifacts),i=zo({completionId:wt,title:n?.title||e.view.mission.title||t(`mission.taskCompleted`),summary:n?.summary||e.view.mission.summary,path:n?.primary_target?.path||r?.path});i&&Ho(i),ze.current={sid:H,id:wt}},500);return()=>window.clearTimeout(n)},[wt,H,t]),(0,F.useEffect)(()=>Wo(e=>{let t=Ve.current;t&&t.delivery_id===e.deliveryId?Dt(t):e.path?Tt(e.path):(S(`activity`),ne(`mission`))}),[Tt,Dt,S,ne]);let kt=(0,F.useRef)(yt);kt.current=yt,(0,F.useEffect)(()=>{qe(`all`),Ye(``),ye([]),Ge({kind:`reset`})},[H]);let At=kr(L,V?.daemon_commands?.revision),jt=kr(Me,at.data?.daemon_commands?.revision),Mt=(0,F.useCallback)(async e=>{Fe(e);try{await U.startDaemon(e),await r.refetch(),I(`success`,t(`sidebar.resumeSuccess`))}catch(e){I(`error`,t(`sidebar.resumeFailed`,{error:pi(e)}))}finally{Fe(null)}},[I,r,t]),{daemonBusy:Pt,manageDeleteProject:Ft,manageStopDaemon:K,manageRenameProject:It,manageStartDaemon:Lt,requestDispose:Rt,requestManageSession:zt,requestStartDaemon:Bt,requestStopDaemon:Vt,requestStopIteration:Ht,toggleContinuous:Ut}=Cc({actions:At,manageActions:jt,manageTargetSid:Me,setManageTargetSid:Ne,activeSid:L,clearProjectSelection:et,continuous:ot,notify:I,refetchProjects:r.refetch,selectProject:z,setDaemonManageOpen:je}),Wt=(0,F.useCallback)(async e=>{if(!L)return;let t=await At.updateProject.mutateAsync({sid:L,name:e});I(`success`,`Renamed to "${t.name}".`)},[At.updateProject,L,I]),Gt=(0,F.useMemo)(()=>uc({activeSid:L,activityEventsRef:kt,notify:I,onClearEvents:e=>Ge({kind:`clear`,offset:e}),onDispose:Rt,onOpenConfig:()=>u(`config`),onOpenDoctor:()=>u(`doctor`),onOpenHelp:()=>u(`help`),onOpenIdentity:()=>u(`identity`),onOpenInspector:()=>u(`inspector`),onOpenNewDaemon:()=>ke(!0),onOpenOperations:()=>u(`operations`),onOpenSidebar:()=>E(!0),onReconnectEvents:()=>Ge({kind:`reconnect`}),onRenameProject:Wt,onRewriteDraft:nt,onSelectProject:z,onSetArtifactPath:Ce,onSetEventFilter:qe,onSetEventQuery:Ye,onSetTaskItemId:De,onSetWorkspaceView:ne,onShowArtifacts:()=>C(!0),onStopIteration:Ht,onStopWaiting:Qe,refetchSnapshot:B.refetch}),[L,I,Wt,Rt,Ht,z,B.refetch,Qe,ne]);wc({focusComposer:()=>M(e=>e+1),openHelp:()=>u(`help`),toggleKiosk:()=>y(e=>!e),togglePalette:()=>u(e=>e===`palette`?`none`:`palette`),toggleReasoning:()=>T(e=>!e),toggleSidebarCollapse:()=>b(e=>!e)});let Kt=async(e,n=[],r)=>{let i=L;if(!i||Ie.current||Le.current)return!1;Ie.current=!0;let a,o;try{if(!n.length){let t=await lc(e,Gt);if(t.kind===`handled`)return r?.({type:`settled`,outcome:`message`}),!0;if(t.kind===`error`)return I(`error`,t.message),!1}a=++Re.current,o=new AbortController,Le.current={id:a,sid:i,controller:o}}finally{Ie.current=!1}let s=()=>{let e=Le.current;return!!(e&&e.id===a&&e.sid===i&&tt.current===i&&!o.signal.aborted)},c=()=>{Le.current?.id===a&&(Le.current=null,_e(!1),xe([]))};_e(!0),xe([]);let l=[];if(n.length)try{let e=await U.uploadAttachments(i,n,o.signal);if(!s())return!1;l=e.attachments.map(e=>({attachment_id:e.attachment_id}))}catch(e){return s()&&(I(`error`,t(`chat.attachmentUploadFailed`,{error:pi(e)})),c()),!1}ye(t=>[...t,hc(i,a,e)]);let u=(e,t=``,n=`auto`)=>{!s()||typeof e!=`string`||!e.trim()||ye(r=>gc(r,i,a,e,t,Date.now(),n))},d=e=>{if(!s())return;let t=e.item;typeof t?.id==`string`&&r?.({type:`task`,taskId:t.id});let n=e.daemon&&typeof e.daemon==`object`?e.daemon:null,i=typeof e.reply==`string`?e.reply:null;n?.admission_required?I(`error`,i||`Task queued, but all daemon slots are busy: ${String(n.error||`operator action required`)}`):n&&Number(n.rc??0)!==0?I(`error`,i||`Task queued, but executor did not start: ${String(n.error||`unknown error`)}`):i&&!r&&I(`success`,i),B.refetch?.()},f=e=>{s()&&Q(e,{dispatchTask:d,notifyError:e=>I(`error`,e),refetchTranscript:()=>{pt.refetch()}})};return(async()=>{let t=!1,n=null,a=[];try{try{await U.messageStream(i,e,{onPhase:(e,t,n)=>{!s()||n.heartbeat||(a=Kn(a,{label:e,role:t,kind:n.kind,detail:n.detail,heartbeat:n.heartbeat,quietS:n.quietS}),xe(a))},onDelta:(e,n,r)=>{s()&&(t=!0,a=qn(a),xe(a),u(e,n,r===`append`||r===`snapshot`?r:`auto`))},onDone:e=>{if(!s())return;u(e.reply,``,`snapshot`),f(e);let t=e.item;(e.kind!==`task`||typeof t?.id!=`string`)&&r?.({type:`settled`,outcome:e.kind===`error`?`error`:`message`})},onError:e=>{s()&&(n=e)}},{signal:o.signal,attachments:l,routeOverride:me})}catch(e){s()&&(n=e)}if(!s())return;n&&(I(`error`,mi(n,t)),r?.({type:`settled`,outcome:`error`}))}finally{o.signal.aborted&&r?.({type:`settled`,outcome:`cancelled`}),c()}})(),!0},qt=(0,F.useRef)(Kt);qt.current=Kt;let Jt=(0,F.useMemo)(()=>{let n=Fa(Nt,e=>{qt.current(e)},e=>{de(e),M(e=>e+1)},e),r=[...f?[]:[{id:`new`,label:t(`palette.newDaemon`),hint:`+`,group:t(`palette.view`),run:()=>ke(!0)}],{id:`transcript`,label:t(`palette.openTranscript`),hint:`/transcript`,group:t(`palette.view`),run:()=>u(`transcript`)},{id:`inspector`,label:t(`palette.openProject`),hint:t(`palette.projectHint`),group:t(`palette.view`),run:()=>u(`inspector`)},{id:`operations`,label:t(`palette.openOperations`),hint:t(`palette.operationsHint`),group:t(`palette.view`),run:()=>u(`operations`)},{id:`help`,label:t(`help.title`),hint:`?`,group:t(`palette.view`),run:()=>u(`help`)},{id:`reasoning`,label:t(ie?`palette.hideReasoning`:`palette.showReasoning`),hint:`⌘T`,group:t(`palette.view`),run:()=>T(e=>!e)},{id:`kiosk`,label:t(f?`palette.exitKiosk`:`palette.enterKiosk`),hint:`⌘.`,group:t(`palette.view`),run:()=>y(e=>!e)}],i=f?[]:[{id:`message`,label:t(`palette.messageArgus`),hint:`/`,group:t(`palette.action`),run:()=>M(e=>e+1)},...ge?[{id:`cancel-message`,label:t(`palette.stopWaiting`),hint:`Esc`,group:t(`palette.action`),run:Qe}]:[],...ot?[{id:`continuous`,label:ot.enabled?t(`palette.stopContinuous`):t(`palette.startContinuous`),group:t(`palette.action`),run:Ut}]:[],...V?.daemon.control_available===!1?[]:[V?.daemon.alive?{id:`stop`,label:t(`palette.stopDaemon`),group:t(`palette.action`),run:Vt}:{id:`start`,label:t(`palette.startDaemon`),group:t(`palette.action`),run:Bt}]],o=a.map(e=>({id:`p-${e.id}`,label:e.label||e.id,hint:e.daemon_alive?`● ${t(`common.live`)}`:`○`,keywords:`${e.id} ${e.display_name??``} ${e.objective} ${e.daemon_alive?`live running`:`stopped idle`}`,group:t(`palette.project`),run:()=>z(e.id)}));return[...r,...i,...n,...o]},[a,V?.daemon.alive,f,ie,ot?.enabled,ge,Qe,e,t]);return(0,X.jsxs)(`div`,{ref:re,style:{"--sidebar-width":`${m}px`,"--preview-width":`${v}px`},className:`workbench-shell ambient-canvas flex w-screen max-w-full overflow-hidden text-ink`,children:[(0,X.jsx)(Bc,{error:c,onRetry:()=>{r.refetch(),i.refetch()}}),Et.selection&&(0,X.jsx)(Jo,{sid:Et.selection.sid,path:Et.selection.path,delivery:Et.selection.receipt,deliveries:Ot,onSelectDelivery:Dt,onSelectPath:Et.selectPath,onClose:Et.close},`${Et.selection.sid}:${Et.selection.receipt.delivery_id}`),!f&&D?(0,X.jsx)(`button`,{type:`button`,"aria-label":t(`common.closeSessions`),onClick:()=>E(!1),className:`fixed inset-0 z-30 bg-black/40 lg:hidden`}):null,f?null:(0,X.jsx)(_s,{projects:a,activeId:L,localCwd:s,onSelect:e=>{z(e),E(!1)},onPrefetch:R,onManage:zt,onResume:e=>void Mt(e),resumingId:Pe,onOpenPanel:e=>u(e),onNew:()=>ke(!0),loading:r.isLoading,creating:it,error:r.isError?pi(r.error):void 0,onRetry:()=>void r.refetch(),mobileOpen:D,collapsed:!p,onToggleCollapse:()=>b(e=>!e),themeMode:ae,onCycleTheme:d}),!f&&p?(0,X.jsx)(ks,{label:t(`common.resizeSessions`),value:m,min:220,max:400,onPointerDown:e=>g(`left`,e),onReset:()=>x(256),onNudge:e=>x(t=>Math.max(220,Math.min(400,t+e)))}):null,(0,X.jsx)(`main`,{className:`flex min-w-0 flex-1 overflow-x-hidden`,children:V?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`${h===`activity`?`flex`:`hidden`} glass-panel glass-panel--main h-full min-w-0 flex-1 flex-col lg:flex`,children:[O!==`map`&&(0,X.jsx)(Zr,{snap:V,streamOk:ut,onStart:Bt,onStop:Vt,onManage:()=>L&&zt(L),busy:Pt,snapshotStale:B.isError,readOnly:f,missionView:bt}),(0,X.jsxs)(`div`,{className:`hidden h-10 shrink-0 items-center gap-1 border-b border-line/60 px-3 lg:flex`,children:[(0,X.jsxs)(`div`,{className:`workspace-tabs`,"data-active":O,children:[(0,X.jsx)(`span`,{className:`workspace-tab-indicator`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`mission`),className:`workspace-tab`,"data-selected":O===`mission`,children:t(`mobile.mission`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`activity`),className:`workspace-tab`,"data-selected":O===`activity`,children:t(`mobile.activity`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`workbench`),className:`workspace-tab`,"data-selected":O===`workbench`,children:t(`mobile.workbench`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`map`),className:`workspace-tab`,"data-selected":O===`map`,children:t(`mobile.map`)})]}),O===`mission`?(0,X.jsx)(`span`,{className:`ml-auto hidden max-w-72 truncate text-[10px] text-ink-faint sm:block`,children:bt?.active_role?t(`mission.roleActive`,{role:bt.active_role}):t(`mission.overview`)}):(0,X.jsx)(`span`,{className:`ml-auto`}),!f&&O!==`map`?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(`operations`),className:`rounded border border-line/60 px-2 py-1 text-[10px] text-ink-faint hover:border-blue/50 hover:text-blue`,children:t(`mission.operations`)}):null]}),O===`map`&&(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`m-auto text-sm text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Wc,{snapshot:V,events:lt,managerSteps:be,draft:ue,onDraftChange:de,onSend:Kt,pending:ge,onCancel:Qe,focusSignal:j,readOnly:f,onOpenSettings:()=>u(`config`),routeOverride:me,onRouteOverrideChange:he,conversationEvents:yt,connected:ut,artifacts:st.data??[],deliveryCount:Ot.length,onOpenDelivery:()=>{Ot[0]&&Dt(Ot[0])},onOpenReceipt:Dt,onOpenArtifact:Ce,onAnswer:()=>vt(!0)},V.session.id)}),(0,X.jsxs)(`div`,{className:`${O===`workbench`||O===`map`?`hidden`:`flex`} min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(lo,{alert:ft}),k===`mission`&&bt?(0,X.jsx)(Qs,{view:bt,sid:V.session.id,snapshot:V,gitDiff:ct.data,artifacts:st.data,onOpenArtifact:Tt,onOpenDelivery:Dt,onNotify:I}):(0,X.jsx)(aa,{events:yt,connected:ut,showReasoning:ie,onToggleReasoning:()=>T(e=>!e),embedded:!0,filter:Ke,query:Je,skipFirst:We.skipFirst,artifacts:st.data,onOpenArtifact:Tt,onOpenDelivery:Dt}),f?null:(0,X.jsx)(`div`,{className:`composer-dock shrink-0 px-4 pt-3`,children:(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-full lg:max-w-[61.8vw]`,children:[(0,X.jsx)(so,{questions:V.pending_questions??[],backlog:V.backlog,onAnswer:()=>vt(!0)}),(0,X.jsx)(Ma,{value:ue,onChange:de,onSend:Kt,onCancel:Qe,disabled:!L,pending:ge,focusSignal:j,embedded:!0,steps:be,onRewrite:nt,rewriting:fe,slashSelection:N,onSlashSelectionChange:P,routeOverride:me,onRouteOverrideChange:he},L||`no-session`)]})})]}),A&&L?(0,X.jsx)(`div`,{className:`${O===`workbench`?`flex`:`hidden`} min-h-0 flex-1`,children:(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-xs text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Uc,{sid:L,active:O===`workbench`})})}):null]}),_&&O!==`map`?(0,X.jsx)(ks,{label:t(`common.resizePreview`),value:v,min:320,max:600,onPointerDown:e=>g(`right`,e),onReset:()=>w(440),onNudge:e=>w(t=>Math.max(320,Math.min(600,t-e)))}):null,(O!==`map`||h===`preview`)&&(0,X.jsxs)(`aside`,{"data-resizable-panel":`right`,className:`${h===`preview`?`flex`:`hidden`} relative min-w-0 flex-1 flex-col overflow-hidden border-l border-line/60 bg-panel transition-[width] duration-[250ms] ease-panel lg:flex lg:flex-none ${_?`lg:w-[var(--preview-width)]`:`lg:w-14`}`,children:[(0,X.jsx)(`div`,{className:`lg:hidden`,children:(0,X.jsx)(Zr,{snap:V,streamOk:ut,onStart:Bt,onStop:Vt,onManage:()=>L&&zt(L),busy:Pt,snapshotStale:B.isError,readOnly:f,missionView:bt})}),(0,X.jsx)(ds,{sid:H,artifacts:st.data,error:st.isError,onExpand:Ce,className:`min-h-0 flex-1 mobile-scroll-region ${_?`lg:flex`:`lg:hidden`}`,embedded:!0,onCollapse:()=>C(!1),missionView:bt,activityEvents:yt,requestedPath:we.path,requestedPathToken:we.token}),_?null:(0,X.jsx)(`div`,{className:`hidden h-12 items-center justify-center border-b border-line/50 text-ink-faint lg:flex`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>C(!0),"aria-label":t(`common.expandPreview`),title:t(`common.expandPreview`),className:`flex h-8 w-8 items-center justify-center rounded-md border border-line/50 bg-bg/40 hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:ee,className:`h-3.5 w-3.5`})})})]})]}):(0,X.jsx)(oc,{loading:r.isLoading||!!(L&&B.isLoading),hasProjects:a.length>0,error:r.isError&&a.length===0?pi(r.error):B.isError&&!V?pi(B.error):void 0,onRetry:()=>{r.refetch(),L&&B.refetch()},onNew:()=>ke(!0),onChoose:()=>E(!0),canCreate:!f})}),(0,X.jsx)(La,{open:l===`palette`,onClose:()=>u(`none`),items:Jt}),(0,X.jsx)(za,{open:l===`help`,onClose:()=>u(`none`)}),L&&(0,X.jsx)(ro,{sid:L,open:l===`doctor`,onClose:()=>u(`none`)}),L&&(0,X.jsx)(io,{sid:L,open:l===`config`,onClose:()=>u(`none`),themeStyle:oe,onThemeStyleChange:te}),L&&(0,X.jsx)(ao,{sid:L,open:l===`identity`,onClose:()=>u(`none`)}),L&&(0,X.jsx)(oo,{sid:L,open:l===`transcript`,onClose:()=>u(`none`)}),L&&V?(0,X.jsx)(Ts,{open:l===`inspector`,snap:V,journal:mt.data??[],busy:At.disposeBacklog.isPending||At.stopBacklog.isPending,onClose:()=>u(`none`),onDispose:Rt,onStop:Ht,onInspect:De}):null,L&&V?(0,X.jsx)(rc,{open:l===`operations`,sid:L,snap:V,onClose:()=>u(`none`),onChanged:()=>{B.refetch(),r.refetch()},onRestored:async e=>{await r.refetch(),z(e)}}):null,(0,X.jsx)(Jo,{sid:L,path:Se,onClose:()=>Ce(null)}),(0,X.jsx)(Os,{sid:L,itemId:Ee,onClose:()=>De(null),onDone:e=>Rt(e,`done`),onSkip:e=>Rt(e,`rm`),onStop:Ht,busy:At.disposeBacklog.isPending||At.stopBacklog.isPending,readOnly:f}),(0,X.jsx)(ps,{open:Oe,busy:it,onClose:()=>ke(!1),onCreate:rt}),(0,X.jsx)(co,{reply:gt,open:G,busy:_t,onClose:()=>vt(!1),onSubmit:ht}),Me?(0,X.jsx)(ms,{open:Ae,sid:Me,name:at.data?.session.display_name||a.find(e=>e.id===Me)?.display_name||a.find(e=>e.id===Me)?.label||``,alive:at.data?.daemon.alive??!!a.find(e=>e.id===Me)?.daemon_alive,controlAvailable:at.data?.daemon.control_available!==!1,busy:Pt,onClose:()=>{je(!1),Ne(null)},onRename:It,onStart:Lt,onStop:K,onDelete:Ft}):null,(0,X.jsx)(fs,{notice:He,onClose:Xe}),V&&!f?(0,X.jsx)(sc,{active:h===`preview`?`preview`:O,sidebarOpen:D,onSelect:e=>{if(e===`preview`){S(`preview`);return}S(`activity`),ne(e)},onOpenSessions:()=>E(!0)}):null]})}function Kc({onDone:e}){let{t}=Z(),n=(0,F.useRef)(!1),r=(0,F.useCallback)(()=>{n.current||(n.current=!0,e())},[e]);return(0,F.useEffect)(()=>{let e=window.setTimeout(r,970),t=()=>r();return window.addEventListener(`keydown`,t,{once:!0}),()=>{window.clearTimeout(e),window.removeEventListener(`keydown`,t)}},[r]),(0,X.jsx)(`div`,{role:`status`,"aria-label":t(`splash.starting`),onClick:r,onAnimationEnd:e=>{e.currentTarget===e.target&&r()},className:`argus-web-splash`,children:(0,X.jsx)(`div`,{className:`argus-web-splash-logo`,"aria-hidden":`true`,children:(0,X.jsx)(ki,{size:168})})})}function qc(e,t){let n=!1;e.addEventListener(`vite:preloadError`,e=>{e.preventDefault(),!n&&(n=!0,t())})}qc(window,()=>window.location.reload()),Ge();var Jc=window.parent!==window;document.documentElement.dataset.argusEmbedded=String(Jc);var Yc=new Oe({defaultOptions:{queries:{staleTime:3e3,retry:pr,refetchOnWindowFocus:!1}}});function Xc(){let[e,t]=(0,F.useState)(!Jc);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Gc,{}),e?(0,X.jsx)(Kc,{onDone:()=>t(!1)}):null]})}ke.createRoot(document.getElementById(`root`)).render((0,X.jsx)(F.StrictMode,{children:(0,X.jsx)(fe,{client:Yc,children:(0,X.jsx)(Jr,{children:(0,X.jsx)(Xc,{})})})}));export{Z as A,oa as C,di as D,Oi as E,et as F,Ce as I,qe as M,Je as N,ai as O,st as P,ka as S,ki as T,so as _,Po as a,ya as b,wo as c,bo as d,yo as f,ho as g,go as h,Io as i,U as j,$r as k,So as l,_o as m,Nc as n,Do as o,vo as p,zs as r,To as s,Mc as t,xo as u,Na as v,aa as w,Ea as x,Aa as y}; \ No newline at end of file +`)||`Plan preview ready.`)},nudge:async t=>{e&&(await U.nudge(e,t),n(`success`,`Guidance injected.`))},abort:async t=>{e&&(await U.abortMission(e,t||`operator abort`),n(`info`,`Abort requested.`))},note:async t=>{e&&(await U.note(e,t),n(`success`,`Note appended to timeline.`))},done:async e=>{e&&i(e,`done`)},skip:async e=>{e&&i(e,`rm`)},stop:async e=>{e&&C(e)},new:async()=>u(),daemons:async()=>f(),resume:async e=>{e&&e!==`list`?g(e):f()},attach:async e=>{e&&g(e)},rename:async t=>{!e||!t||await m(t)},doctor:async()=>o(),backend:async t=>{if(!e||!t){a();return}await U.setConfig(e,`runner_backend`,t),n(`success`,`Backend set to ${t}.`)},config:async t=>{if(!e||!t){a();return}let r=t.indexOf(`=`);r>0?(await U.setConfig(e,t.slice(0,r).trim(),t.slice(r+1).trim()),n(`success`,`Config updated.`)):a()},identity:async()=>c(),reset:async()=>{e&&(await U.resetManager(e),n(`success`,`Manager context reset.`))},skills:async t=>{e&&n(`info`,(await U.skills(e,t||`ls`)).slice(0,400))},reconnect:async()=>p(),help:async()=>s(),quit:async()=>n(`info`,`Background work continues; close this browser tab when ready.`)}}function dc(e){return e.kind===`error`?(typeof e.reply==`string`?e.reply.trim():``)||`Manager could not handle this message.`:null}function Q(e,t){e.kind===`task`&&t.dispatchTask(e);let n=dc(e);n&&t.notifyError(n),t.refetchTranscript()}var fc={skipFirst:0,reconnectKey:0};function pc(e,t){return t.kind===`clear`?{...e,skipFirst:Math.max(0,t.offset)}:t.kind===`reconnect`?{skipFirst:0,reconnectKey:e.reconnectKey+1}:{...e,skipFirst:0}}var mc=`local_request_id`;function hc(e,t,n,r=Date.now()){return{type:`ui.operator`,agent_layer:`operator`,text:n,ts:r/1e3,event_id:`local-${e}-${t}-operator`,message_id:`local-${t}-operator`,[mc]:t}}function gc(e,t,n,r,i,a=Date.now(),o=`auto`){let s=r.trim();if(!s)return e;let c=e.findIndex(e=>e.type===`ui.argus`&&Number(e[mc])===n),l=i.endsWith(`-argus`)?`${i.slice(0,-6)}-operator`:``,u=l?e.map(e=>e.type===`ui.operator`&&Number(e[mc])===n?{...e,message_id:l}:e):e,d=u.find(e=>e.type===`ui.operator`&&Number(e[mc])===n),f=d?Math.max(0,a-Number(d.ts??a/1e3)*1e3):0;if(c<0)return[...u,{type:`ui.argus`,agent_layer:`manager`,text:s,ts:a/1e3,event_id:`local-${t}-${n}-argus`,message_id:i||`local-${n}-argus`,fragment_mode:o,response_latency_ms:f,[mc]:n}];let p=u[c],m=[...u];return m[c]={...p,text:kt(String(p.text??``),s,o),message_id:i||p.message_id,fragment_mode:o},m}function _c(e,t,n){let r=new Map;e.forEach(e=>{let t=String(e.type??``);if(t!==`ui.operator`&&t!==`ui.argus`)return;let n=`${t}\u0000${String(e.text??``)}`;r.set(n,(r.get(n)??0)+1)});let i=t.map(e=>({type:e.role===`operator`?`ui.operator`:`ui.argus`,agent_layer:e.role===`operator`?`operator`:`manager`,text:e.text,ts:e.ts,message_id:e.message_id||`transcript-${e.ts}-${e.role}`,...e.mission_result===!0?{mission_result:!0}:{},...typeof e.item_id==`string`?{item_id:e.item_id}:{},...typeof e.success==`boolean`?{success:e.success}:{},...typeof e.summary==`string`?{summary:e.summary}:{},...typeof e.delivery_id==`string`?{delivery_id:e.delivery_id}:{},...e.delivery&&typeof e.delivery==`object`?{delivery:e.delivery}:{}})),a=Array(i.length).fill(!0);for(let e=i.length-1;e>=0;--e){let t=i[e],n=`${String(t.type)}\u0000${String(t.text??``)}`,o=r.get(n)??0;o>0&&(a[e]=!1,r.set(n,o-1))}let o=[...i.filter((e,t)=>a[t]),...e],s=Array(o.length).fill(!0),c=new Set,l=n.map(e=>{let t=String(e.message_id??``),n=t?o.findIndex((e,n)=>!c.has(n)&&String(e.message_id??``)===t):-1,r=Number(e.ts??0);if(n<0&&(n=o.findIndex((t,n)=>{if(c.has(n)||t.type!==e.type||t.text!==e.text)return!1;let i=Number(t.ts??0);return Math.abs(i-r)<=5})),n>=0){c.add(n),s[n]=!1;let t=o[n];return{...e,...t.mission_result===!0?{mission_result:!0}:{},...typeof t.item_id==`string`?{item_id:t.item_id}:{},...typeof t.success==`boolean`?{success:t.success}:{},...typeof t.summary==`string`?{summary:t.summary}:{},...typeof t.delivery_id==`string`?{delivery_id:t.delivery_id}:{},...t.delivery&&typeof t.delivery==`object`?{delivery:t.delivery}:{}}}return e});return[...o.filter((e,t)=>s[t]),...l].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0))}function vc(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,spend_usd:t.spend_usd,known_cost_usd:t.known_cost_usd,spend_status:t.spend_status,usage_calls:t.usage_calls,premium_requests:t.premium_requests,cost_updated_at:t.updated_at}:e})}async function yc(e,t,n,r=``){let i=await e.createDaemon(``,t,r),a=n.trim();return{created:i,startCampaign:a?()=>e.setContinuous(i.sid,!0,a):null}}var bc=e=>e instanceof Error?e.message:String(e||`Unknown error`);function xc({localCwd:e,notify:t,onFocusComposer:n,queryClient:r,refetchProjects:i,selectProject:a}){let[o,s]=(0,F.useState)(!1),c=(0,F.useRef)(!1);return{createDaemon:async(o,l,u)=>{if(c.current)return!1;c.current=!0,s(!0);try{let{created:s,startCampaign:c}=await yc(U,o,l,u),d=String(s.workdir||u||``);return r.setQueryData([`projects`],t=>({local_cwd:t?.local_cwd??e,projects:[{id:s.sid,label:o||s.sid,display_name:o,objective:``,launch_cwd:d,workdir:d,last_active:Date.now()/1e3,daemon_alive:!1,daemon_pid:null,uptime_seconds:null},...(t?.projects??[]).filter(e=>e.id!==s.sid)]})),a(s.sid),i(),window.setTimeout(n,0),t(c?`info`:`success`,c?`Session created and selected. Campaign is starting in the background.`:`Session created and selected.`),c&&c().then(()=>{r.invalidateQueries({queryKey:[`snapshot`,s.sid]}),i(),t(`success`,`Campaign started.`)}).catch(e=>{t(`error`,`Session was created, but the campaign could not start: ${bc(e)}`)}),!0}catch(e){return t(`error`,`Could not create session: ${bc(e)}`),!1}finally{c.current=!1,s(!1)}},creatingDaemon:o}}var Sc=e=>e instanceof Error?e.message:String(e||`Unknown error`);function Cc({actions:e,manageActions:t,manageTargetSid:n,setManageTargetSid:r,activeSid:i,clearProjectSelection:a,continuous:o,notify:s,refetchProjects:c,selectProject:l,setDaemonManageOpen:u}){let d=e.startDaemon.isPending||e.stopDaemon.isPending||e.forceStopDaemon.isPending||t.startDaemon.isPending||t.forceStopDaemon.isPending||t.updateProject.isPending||t.deleteProject.isPending,f=(0,F.useCallback)(e=>({onSuccess:()=>s(`success`,e),onError:e=>s(`error`,Sc(e))}),[s]),p=(0,F.useCallback)(()=>e.startDaemon.mutate(void 0,f(`Daemon start requested.`)),[f,e.startDaemon]),m=(0,F.useCallback)(()=>e.forceStopDaemon.mutate(void 0,f(`Stop requested; the verified daemon process is being interrupted.`)),[f,e.forceStopDaemon]),h=(0,F.useCallback)(async()=>{try{return await t.startDaemon.mutateAsync(),s(`success`,`Daemon resumed.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[t.startDaemon,s]),g=(0,F.useCallback)(async()=>{try{return await t.forceStopDaemon.mutateAsync(),await c(),s(`success`,`Daemon stopped. This session can now be deleted.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[t.forceStopDaemon,s,c]),_=(0,F.useCallback)(async e=>{if(!n)return!1;try{return await t.updateProject.mutateAsync({sid:n,name:e}),s(`success`,`Session name updated.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[t.updateProject,n,s]),v=(0,F.useCallback)(async()=>{if(!n)return!1;try{let e=n,o=await t.deleteProject.mutateAsync();u(!1),r(null);let d=await c();if(e===i){a(`replace`);let e=Dn(d.data?.projects??[])[0];e&&l(e.id,`replace`)}return s(`success`,o.workdir_preserved?`Session moved to recoverable trash. Files remain in ${o.workdir}.`:`Session moved to recoverable trash.`),!0}catch(e){return s(`error`,Sc(e)),!1}},[i,a,t.deleteProject,n,s,c,l,u,r]),y=(0,F.useCallback)(e=>{r(e),u(!0)},[u,r]);return{daemonBusy:d,manageDeleteProject:v,manageStopDaemon:g,manageRenameProject:_,manageStartDaemon:h,requestDispose:(0,F.useCallback)((t,n)=>e.disposeBacklog.mutate({id:t,op:n},{onSuccess:()=>s(`success`,n===`done`?`Work marked done.`:`Work removed.`),onError:e=>s(`error`,Sc(e))}),[e.disposeBacklog,s]),requestManageSession:y,requestStartDaemon:p,requestStopDaemon:m,requestStopIteration:(0,F.useCallback)(t=>e.stopBacklog.mutate(t,{onSuccess:()=>s(`success`,`Iteration stopped.`),onError:e=>s(`error`,Sc(e))}),[e.stopBacklog,s]),toggleContinuous:(0,F.useCallback)(()=>{if(!o)return;let t=!o.enabled;e.setContinuous.mutate({enabled:t,objective:o.objective},f(t?`Continuous campaign enabled.`:`Continuous campaign stopped.`))},[f,e.setContinuous,o])}}function wc({focusComposer:e,openHelp:t,toggleKiosk:n,togglePalette:r,toggleReasoning:i,toggleSidebarCollapse:a}){(0,F.useEffect)(()=>{let o=o=>{let s=o.target,c=s?.tagName===`INPUT`||s?.tagName===`TEXTAREA`,l=o.metaKey||o.ctrlKey;l&&o.key.toLowerCase()===`k`?(o.preventDefault(),r()):l&&o.key.toLowerCase()===`t`?(o.preventDefault(),i()):l&&o.key===`.`?(o.preventDefault(),n()):l&&o.key.toLowerCase()===`b`?(o.preventDefault(),a()):l&&o.key.toLowerCase()===`j`?(o.preventDefault(),e()):!c&&o.key===`?`?(o.preventDefault(),t()):!c&&o.key===`/`&&(o.preventDefault(),e())};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[e,t,n,r,i,a])}var Tc=e=>e instanceof Error?e.message:String(e||`Unknown error`);function Ec({activeSid:e,backlog:t,notify:n,pendingQuestions:r,refetchSnapshot:i}){let[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(``),u=(0,F.useMemo)(()=>{let e=(t??[]).map(e=>({...e,operator_decision:e.operator_decision}));return _t(r??[],e)[0]??null},[t,r]);return(0,F.useEffect)(()=>{if(!u||!e){o(!1);return}let t=`${e}:${u.id}`;l.current!==t&&(l.current=t,o(!0))},[e,u]),{answerPendingReply:async(t,r)=>{if(!(!e||!u||s)){c(!0);try{let a=u.legacy?await U.answerPending(e,u.item_id,r):await U.resolveDecision(e,u.id,t,r);if(a.resolved===!1){n(`info`,String(a.reply||`Manager needs a more specific answer.`));return}o(!1),await i(),a.daemon&&Number(a.daemon.rc??0)!==0?n(`error`,`Answer queued, but the daemon did not start: ${a.daemon.error||`operator action required`}`):n(`success`,String(a.reply||`Manager delivered your answer to the team.`))}catch(e){await i(),n(`error`,`Could not send answer: ${Tc(e)}`)}finally{c(!1)}}},pendingReply:u,pendingReplyBusy:s,pendingReplyOpen:a,setPendingReplyOpen:o}}var Dc=`argus.browser.project.v1`;function Oc(){try{return window.sessionStorage.getItem(Dc)}catch{return null}}function kc(e){try{e?window.sessionStorage.setItem(Dc,e):window.sessionStorage.removeItem(Dc)}catch{}}function Ac(e,t){let n=new URL(window.location.href);e?n.searchParams.set(`project`,e):n.searchParams.delete(`project`);let r=t===`push`?`pushState`:`replaceState`;window.history[r](window.history.state,``,n.toString())}function jc({cancelActiveMessage:e,notify:t,projects:n,projectsError:r,projectsReady:i,queryClient:a,setArtifactPath:o,setSidebarOpen:s,setTaskItemId:c}){let l=new URLSearchParams(window.location.search),[u,d]=(0,F.useState)(l.get(`project`)||Oc()),f=(0,F.useRef)(u),p=(0,F.useRef)(!1);f.current=u;let m=(0,F.useCallback)(t=>{t!==f.current&&(e(),o(null),c(null)),f.current=t,d(t),kc(t)},[e,o,c]),h=(0,F.useCallback)((e,t=`push`)=>{let n=new URLSearchParams(window.location.search).get(`project`);m(e),n!==e&&Ac(e,t)},[m]),g=(0,F.useCallback)((e=`replace`)=>{let t=new URLSearchParams(window.location.search).get(`project`);m(null),t!=null&&Ac(null,e)},[m]),_=(0,F.useCallback)(e=>{a.prefetchQuery({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.prefetchSnapshot(e,t),staleTime:3e3})},[a]);return(0,F.useEffect)(()=>{if(!i)return;let e=p.current,r=An(n,f.current,e);if(!e&&(p.current=!0,r.id===f.current?kc(r.id):m(r.id),new URLSearchParams(window.location.search).get(`project`)!==r.id&&Ac(r.id,`replace`),r.recovered)){let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}},[m,t,n,i]),(0,F.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get(`project`);if(s(!1),!e){m(null);return}if(!i){m(e);return}let r=kn(n,e);if(m(r.id),r.recovered){Ac(r.id,`replace`);let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,t,n,i,s]),{activateProject:m,activeSid:i?u&&n.some(e=>e.id===u)?u:null:r?u:null,clearProjectSelection:g,prefetchProject:_,selectProject:h,sid:u,sidRef:f}}function Mc(e){try{return globalThis.localStorage?.getItem(e)??null}catch{return null}}function Nc(e,t){try{return globalThis.localStorage?.setItem(e,t),!!globalThis.localStorage}catch{return!1}}var Pc=`argus.themeStyle`;function Fc(){return Mc(`argus.themeStyle`)===`gradient`?`gradient`:`standard`}function Ic(e,t){let n=Mc(e);return n==null?t:n===`true`}function Lc(e){document.documentElement.dataset.theme=e,window.parent!==window&&window.parent.postMessage({type:`argus:theme-changed`,payload:e},`*`)}function Rc(){let e=new URLSearchParams(window.location.search),[t,n]=(0,F.useState)(e.get(`kiosk`)===`1`),[r,i]=(0,F.useState)(()=>Ic(`argus.reasoning.visible.v1`,!1)),[a,o]=(0,F.useState)(()=>{let t=e.get(`view`);if(t===`mission`||t===`activity`||t===`workbench`||t===`map`)return t;let n=Mc(`argus.workspace.view`);return n===`mission`||n===`activity`||n===`workbench`||n===`map`?n:`map`}),[s,c]=(0,F.useState)(`activity`),[l,u]=(0,F.useState)(()=>Ic(`argus.preview.expanded.v5`,!0)),[d,f]=(0,F.useState)(()=>{let e=Number(Mc(`argus.sidebar.width.v2`)||256);return Number.isFinite(e)?Math.max(220,Math.min(400,e)):256}),[p,m]=(0,F.useState)(()=>{let e=Number(Mc(`argus.preview.width.v2`)||440);return Number.isFinite(e)?Math.max(320,Math.min(600,e)):440}),[h,g]=(0,F.useState)(!1),[_,v]=(0,F.useState)(()=>Ic(`argus.sidebar.expanded.v4`,!0)),[y,b]=(0,F.useState)(()=>{let e=Mc(`argus.theme`);return e===`light`||e===`dark`?e:null}),[x,S]=(0,F.useState)(Fc),[C,w]=(0,F.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches),T=y??(C?`dark`:`light`),ee=(0,F.useRef)(T),E=(0,F.useRef)(null),te=(0,F.useRef)(null);(0,F.useEffect)(()=>{Nc(`argus.sidebar.expanded.v4`,String(_)),Nc(`argus.preview.expanded.v5`,String(l)),Nc(`argus.sidebar.width.v2`,String(d)),Nc(`argus.preview.width.v2`,String(p))},[_,d,l,p]),(0,F.useEffect)(()=>{Nc(`argus.workspace.view`,a)},[a]),(0,F.useEffect)(()=>{Nc(`argus.reasoning.visible.v1`,String(r))},[r]),(0,F.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>w(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,F.useEffect)(()=>{ee.current=T,Lc(T)},[T]),(0,F.useEffect)(()=>{document.documentElement.dataset.themeStyle=x},[x]);let ne=(0,F.useCallback)(()=>{let e=ee.current===`light`?`dark`:`light`;ee.current=e,Lc(e),Nc(`argus.theme`,e),(0,F.startTransition)(()=>b(e))},[]),re=(0,F.useCallback)(e=>{S(e),Nc(Pc,e)},[]),ie=(0,F.useCallback)((e,t)=>{let n=E.current;if(!n)return;t.preventDefault();let r=n.getBoundingClientRect(),i=e===`left`?d:p;n.dataset.resizing=e,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let a=t=>{if(e===`left`){let e=l?p+8:56,n=Math.max(220,Math.min(400,r.width-e-360-8));i=Math.max(220,Math.min(n,t.clientX-r.left))}else{let e=_?d+8:56,n=Math.max(320,Math.min(600,r.width-e-360-8));i=Math.max(320,Math.min(n,r.right-t.clientX))}te.current??=window.requestAnimationFrame(()=>{n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),te.current=null})},o=()=>{te.current!=null&&window.cancelAnimationFrame(te.current),te.current=null,n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),e===`left`?f(i):m(i),delete n.dataset.resizing,document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})},[_,d,l,p]);return(0,F.useEffect)(()=>{let e=()=>{if(window.innerWidth<1024||!E.current)return;let e=E.current.clientWidth,t=_?d:56,n=l?p:56,r=(_?8:0)+(l?8:0),i=Math.max(540,e-360-r);if(t+n<=i)return;let a=l?Math.max(320,Math.min(p,i-t)):n,o=_?Math.max(220,Math.min(d,i-a)):t;o+a>i&&l&&(a=Math.max(320,i-o)),_&&f(o),l&&m(a)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_,d,l,p]),{cycleTheme:ne,kiosk:t,leftPanelOpen:_,leftWidth:d,mobileView:s,resizeSidebar:ie,rightPanelOpen:l,rightWidth:p,setKiosk:n,setLeftPanelOpen:v,setLeftWidth:f,setMobileView:c,setRightPanelOpen:u,setRightWidth:m,setShowReasoning:i,setSidebarOpen:g,setThemeStyle:re,setWorkspaceView:o,shellRef:E,showReasoning:r,sidebarOpen:h,themeMode:T,themeStyle:x,workspaceView:a}}function zc(e){let t=e.trim();if(!t||/\s/.test(t))return``;if(!t.includes(`?`)&&!t.includes(`://`))return t;try{return new URL(t,window.location.href).searchParams.get(`token`)?.trim()??``}catch{return``}}function Bc({error:e,onRetry:t}){let{t:n}=Z(),r=Qe(e),i=e instanceof Ze,[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``);return!r&&!i?null:(0,X.jsxs)(`div`,{role:`alert`,className:`fixed left-1/2 top-3 z-[100] flex w-[min(92vw,42rem)] -translate-x-1/2 flex-wrap items-start gap-3 rounded-xl border border-err/50 bg-panel/95 px-4 py-3 text-left text-sm text-ink shadow-xl backdrop-blur`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 font-mono font-bold text-err`,children:`!`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`strong`,{className:`block text-err`,children:n(r?`connection.pairingTitle`:`connection.unreachableTitle`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-ink-dim`,children:n(r?`connection.pairingDetail`:`connection.unreachableDetail`)})]}),r&&!a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`shrink-0 rounded-md border border-blue/45 bg-blue/10 px-2.5 py-1 text-xs font-medium text-blue hover:bg-blue/15`,children:n(`connection.pairAgain`)}):r?null:(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-md border border-err/40 px-2.5 py-1 text-xs text-err hover:bg-err/10`,children:n(`common.retry`)}),r&&a?(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=zc(s);if(!t){u(n(`connection.pairingInvalid`));return}let r=new URL(window.location.href);r.searchParams.set(`token`,t),window.location.replace(r.toString())},className:`flex w-full basis-full flex-wrap gap-2 pl-7`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`pairing-link`,children:n(`connection.pairingInput`)}),(0,X.jsx)(`input`,{id:`pairing-link`,"data-autofocus":!0,type:`password`,autoComplete:`off`,value:s,onChange:e=>{c(e.target.value),u(``)},placeholder:n(`connection.pairingPlaceholder`),className:`h-9 min-w-0 flex-1 rounded-md border border-line bg-bg px-3 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`submit`,className:`h-9 rounded-md border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white`,children:n(`connection.connect`)}),l?(0,X.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-err`,children:l}):null]}):null]})}function $(e){try{let t=JSON.parse(Mc(e)||`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Vc(e,t,n,r=!0){let i=(0,F.useRef)(),[a,o]=(0,F.useState)(null),s=(0,F.useCallback)(t=>{if(!e)return;let n=`argus.delivery.seen.v1:${e}`;Nc(n,JSON.stringify([...new Set([...$(n),t])].slice(-80)))},[e]),c=(0,F.useCallback)(t=>{e&&(s(t.delivery_id),o({sid:e,receipt:t,path:Qr(t)[0]?.path||null}))},[e,s]);return(0,F.useEffect)(()=>{if(!e||!t)return;let a=n?.delivery_id;if(i.current?.sid!==e){i.current={sid:e,ids:new Set(a?[a]:[])},o(null);return}!a||i.current.ids.has(a)||!r||(i.current.ids.add(a),n&&Qr(n).length&&!$(`argus.delivery.seen.v1:${e}`).includes(a)&&c(n))},[e,t,n,c,r]),{selection:a?.sid===e?a:null,open:c,close:(0,F.useCallback)(()=>o(null),[]),selectPath:(0,F.useCallback)(e=>o(t=>t&&{...t,path:e}),[])}}var Hc=0,Uc=(0,F.lazy)(async()=>({default:(await ai(()=>import(`./ResearchWorkbenchPanel-CWXTxKbh.js`),__vite__mapDeps([2,1,3,4,5,6,7,8]))).ResearchWorkbenchPanel})),Wc=(0,F.lazy)(async()=>({default:(await ai(()=>import(`./MapPanel-psIb5IiP.js`),__vite__mapDeps([9,1,3,4,5,6,7,10]))).MapPanel}));function Gc(){let{locale:e,t}=Z(),n=ce(),r=_r(),i=vr(),a=(0,F.useMemo)(()=>Dn(vc(r.data?.projects??[],i.data?.projects??[])),[i.data?.projects,r.data?.projects]),s=r.data?.local_cwd??``,c=[r.error,i.error].find(e=>$e(e)),[l,u]=(0,F.useState)(`none`),{cycleTheme:d,kiosk:f,leftPanelOpen:p,leftWidth:m,mobileView:h,resizeSidebar:g,rightPanelOpen:_,rightWidth:v,setKiosk:y,setLeftPanelOpen:b,setLeftWidth:x,setMobileView:S,setRightPanelOpen:C,setRightWidth:w,setShowReasoning:T,setSidebarOpen:E,setThemeStyle:te,setWorkspaceView:ne,shellRef:re,showReasoning:ie,sidebarOpen:D,themeMode:ae,themeStyle:oe,workspaceView:O}=Rc(),[k,se]=(0,F.useState)(()=>O===`mission`?`mission`:`activity`),[A,le]=(0,F.useState)(O===`workbench`);(0,F.useEffect)(()=>{if(O===`workbench`){le(!0);return}O!==`map`&&se(O)},[O]),cc();let[j,M]=(0,F.useState)(0),[ue,de]=(0,F.useState)(``),[fe,pe]=(0,F.useState)(!1),[N,P]=(0,F.useState)(0),[me,he]=(0,F.useState)(Rr),[ge,_e]=(0,F.useState)(!1),[ve,ye]=(0,F.useState)([]),[be,xe]=(0,F.useState)([]),[Se,Ce]=(0,F.useState)(null),[we,Te]=(0,F.useState)({path:``,token:0}),[Ee,De]=(0,F.useState)(null),[Oe,ke]=(0,F.useState)(!1),[Ae,je]=(0,F.useState)(!1),[Me,Ne]=(0,F.useState)(null),[Pe,Fe]=(0,F.useState)(null),Ie=(0,F.useRef)(!1),Le=(0,F.useRef)(null),Re=(0,F.useRef)(0),ze=(0,F.useRef)(),Be=(0,F.useRef)({sid:``,completionId:``,view:null,artifacts:[]}),Ve=(0,F.useRef)(null),[He,Ue]=(0,F.useState)(null),[We,Ge]=(0,F.useReducer)(pc,fc),[Ke,qe]=(0,F.useState)(`all`),[Je,Ye]=(0,F.useState)(``),Xe=(0,F.useCallback)(()=>Ue(null),[]);(0,F.useEffect)(()=>{try{localStorage.setItem(Lr,me)}catch{}},[me]);let I=(0,F.useCallback)((e,t)=>{Ue({id:++Hc,tone:e,message:t})},[]),Ze=(0,F.useCallback)(()=>{let e=!!Le.current;return Re.current+=1,Le.current?.controller.abort(),Le.current=null,_e(!1),xe([]),e},[]),Qe=(0,F.useCallback)(()=>{Ze()&&I(`info`,`Stopped waiting for this reply. Server-side work may still finish in the project timeline.`)},[Ze,I]),{activeSid:L,clearProjectSelection:et,prefetchProject:R,selectProject:z,sidRef:tt}=jc({cancelActiveMessage:Ze,notify:I,projects:a,projectsError:r.isError,projectsReady:r.isSuccess,queryClient:n,setArtifactPath:Ce,setSidebarOpen:E,setTaskItemId:De});(0,F.useEffect)(()=>()=>{Re.current+=1,Le.current?.controller.abort(),Le.current=null},[]),(0,F.useEffect)(()=>Ko(),[]);let nt=(0,F.useCallback)(e=>{let t=(e||``).trim(),n=tt.current;!t||!n||fe||(pe(!0),U.rewritePrompt(n,t).then(e=>{if(pe(!1),e.error||!e.rewritten.trim()){I(`error`,`Rewrite failed: ${e.error||`empty rewrite`} — your prompt is unchanged`);return}de(e.rewritten),M(e=>e+1);let t=e.questions.length?` Manager asks: ${e.questions.join(` · `)}`:``;I(`success`,`Prompt rewritten — review it, then send.${t}`)},e=>{pe(!1),I(`error`,`Rewrite failed: ${pi(e)} — your prompt is unchanged`)}))},[I,fe,tt]),{createDaemon:rt,creatingDaemon:it}=xc({localCwd:s,notify:I,onFocusComposer:()=>M(e=>e+1),queryClient:n,refetchProjects:r.refetch,selectProject:z});(0,F.useEffect)(()=>Go(()=>ke(!0)),[]);let B=yr(L),at=yr(Me),V=B.data,H=V?.session.id===L?L:null,ot=V?.continuous,st=Tr(H,!0),ct=Dr(H,k===`mission`),{events:lt,connected:ut}=Ir(H,We.reconnectKey),dt=(0,F.useMemo)(()=>Nr(lt),[lt]),W=(0,F.useMemo)(()=>Fr(lt),[lt]);(0,F.useEffect)(()=>{if(!H||!dt)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},180);return()=>window.clearTimeout(e)},[dt,H,n]),(0,F.useEffect)(()=>{if(!H||!W)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`snapshot`,H],exact:!0})},80);return()=>window.clearTimeout(e)},[H,n,W]);let ft=(0,F.useMemo)(()=>Rn(lt),[lt]),pt=wr(H,k===`activity`,120),mt=br(L,20,l===`inspector`),{answerPendingReply:ht,pendingReply:gt,pendingReplyBusy:_t,pendingReplyOpen:G,setPendingReplyOpen:vt}=Ec({activeSid:L,backlog:V?.backlog,notify:I,pendingQuestions:V?.pending_questions,refetchSnapshot:B.refetch}),yt=(0,F.useMemo)(()=>_c(lt,pt.data??[],ve),[lt,ve,pt.data]),bt=(0,F.useMemo)(()=>V?xn(V,yt,st.data??[]):null,[yt,st.data,V]),xt=ei((0,F.useMemo)(()=>na(yt),[yt]),bt?.delivery??null,yt),St=V?.backlog.some(e=>[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))??!1,Ct=Qo(bt)&&!St&&!V?.continuous?.enabled,wt=H&&Ct&&bt?.mission.id?`completion:${H}:${bt.mission.id}`:``;Ve.current=xt,Be.current={sid:H||``,completionId:wt,view:bt,artifacts:st.data??[]};let Tt=(0,F.useCallback)(e=>{let t=e.trim();if(!t){ne(`mission`);return}if(O===`map`){Ce(t);return}C(!0),S(`preview`),Te(e=>({path:t,token:e.token+1}))},[S,C,ne,O]),Et=Vc(H,!!V&&!pt.isPending,xt,!Se&&!ti(V?.backlog??[],xt?.item_id)),Dt=Et.open,Ot=(0,F.useMemo)(()=>{let e=new Map;for(let t of yt){let n=t.delivery;n?.delivery_id&&Array.isArray(n.targets)&&e.set(n.delivery_id,n)}for(let t of[bt?.delivery,xt])t&&e.set(t.delivery_id,t);return[...e.values()].filter(e=>Qr(e).length).sort((e,t)=>t.delivered_at-e.delivered_at)},[yt,bt?.delivery,xt]);(0,F.useEffect)(()=>{H&&xt?.delivery_id&&n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},[H,xt?.delivery_id,n]),(0,F.useEffect)(()=>{if(!H)return;let e=ze.current;if(!e||e.sid!==H){ze.current={sid:H,id:wt||null};return}if(!wt){ze.current={sid:H,id:null};return}if(e.id===wt)return;let n=window.setTimeout(()=>{let e=Be.current;if(e.sid!==H||e.completionId!==wt||!e.view)return;let n=e.view.delivery,r=rs(e.artifacts),i=zo({completionId:wt,title:n?.title||e.view.mission.title||t(`mission.taskCompleted`),summary:n?.summary||e.view.mission.summary,path:n?.primary_target?.path||r?.path});i&&Ho(i),ze.current={sid:H,id:wt}},500);return()=>window.clearTimeout(n)},[wt,H,t]),(0,F.useEffect)(()=>Wo(e=>{let t=Ve.current;t&&t.delivery_id===e.deliveryId?Dt(t):e.path?Tt(e.path):(S(`activity`),ne(`mission`))}),[Tt,Dt,S,ne]);let kt=(0,F.useRef)(yt);kt.current=yt,(0,F.useEffect)(()=>{qe(`all`),Ye(``),ye([]),Ge({kind:`reset`})},[H]);let At=kr(L,V?.daemon_commands?.revision),jt=kr(Me,at.data?.daemon_commands?.revision),Mt=(0,F.useCallback)(async e=>{Fe(e);try{await U.startDaemon(e),await r.refetch(),I(`success`,t(`sidebar.resumeSuccess`))}catch(e){I(`error`,t(`sidebar.resumeFailed`,{error:pi(e)}))}finally{Fe(null)}},[I,r,t]),{daemonBusy:Pt,manageDeleteProject:Ft,manageStopDaemon:K,manageRenameProject:It,manageStartDaemon:Lt,requestDispose:Rt,requestManageSession:zt,requestStartDaemon:Bt,requestStopDaemon:Vt,requestStopIteration:Ht,toggleContinuous:Ut}=Cc({actions:At,manageActions:jt,manageTargetSid:Me,setManageTargetSid:Ne,activeSid:L,clearProjectSelection:et,continuous:ot,notify:I,refetchProjects:r.refetch,selectProject:z,setDaemonManageOpen:je}),Wt=(0,F.useCallback)(async e=>{if(!L)return;let t=await At.updateProject.mutateAsync({sid:L,name:e});I(`success`,`Renamed to "${t.name}".`)},[At.updateProject,L,I]),Gt=(0,F.useMemo)(()=>uc({activeSid:L,activityEventsRef:kt,notify:I,onClearEvents:e=>Ge({kind:`clear`,offset:e}),onDispose:Rt,onOpenConfig:()=>u(`config`),onOpenDoctor:()=>u(`doctor`),onOpenHelp:()=>u(`help`),onOpenIdentity:()=>u(`identity`),onOpenInspector:()=>u(`inspector`),onOpenNewDaemon:()=>ke(!0),onOpenOperations:()=>u(`operations`),onOpenSidebar:()=>E(!0),onReconnectEvents:()=>Ge({kind:`reconnect`}),onRenameProject:Wt,onRewriteDraft:nt,onSelectProject:z,onSetArtifactPath:Ce,onSetEventFilter:qe,onSetEventQuery:Ye,onSetTaskItemId:De,onSetWorkspaceView:ne,onShowArtifacts:()=>C(!0),onStopIteration:Ht,onStopWaiting:Qe,refetchSnapshot:B.refetch}),[L,I,Wt,Rt,Ht,z,B.refetch,Qe,ne]);wc({focusComposer:()=>M(e=>e+1),openHelp:()=>u(`help`),toggleKiosk:()=>y(e=>!e),togglePalette:()=>u(e=>e===`palette`?`none`:`palette`),toggleReasoning:()=>T(e=>!e),toggleSidebarCollapse:()=>b(e=>!e)});let Kt=async(e,n=[],r)=>{let i=L;if(!i||Ie.current||Le.current)return!1;Ie.current=!0;let a,o;try{if(!n.length){let t=await lc(e,Gt);if(t.kind===`handled`)return r?.({type:`settled`,outcome:`message`}),!0;if(t.kind===`error`)return I(`error`,t.message),!1}a=++Re.current,o=new AbortController,Le.current={id:a,sid:i,controller:o}}finally{Ie.current=!1}let s=()=>{let e=Le.current;return!!(e&&e.id===a&&e.sid===i&&tt.current===i&&!o.signal.aborted)},c=()=>{Le.current?.id===a&&(Le.current=null,_e(!1),xe([]))};_e(!0),xe([]);let l=[];if(n.length)try{let e=await U.uploadAttachments(i,n,o.signal);if(!s())return!1;l=e.attachments.map(e=>({attachment_id:e.attachment_id}))}catch(e){return s()&&(I(`error`,t(`chat.attachmentUploadFailed`,{error:pi(e)})),c()),!1}ye(t=>[...t,hc(i,a,e)]);let u=(e,t=``,n=`auto`)=>{!s()||typeof e!=`string`||!e.trim()||ye(r=>gc(r,i,a,e,t,Date.now(),n))},d=e=>{if(!s())return;let t=e.item;typeof t?.id==`string`&&r?.({type:`task`,taskId:t.id});let n=e.daemon&&typeof e.daemon==`object`?e.daemon:null,i=typeof e.reply==`string`?e.reply:null;n?.admission_required?I(`error`,i||`Task queued, but all daemon slots are busy: ${String(n.error||`operator action required`)}`):n&&Number(n.rc??0)!==0?I(`error`,i||`Task queued, but executor did not start: ${String(n.error||`unknown error`)}`):i&&!r&&I(`success`,i),B.refetch?.()},f=e=>{s()&&Q(e,{dispatchTask:d,notifyError:e=>I(`error`,e),refetchTranscript:()=>{pt.refetch()}})};return(async()=>{let t=!1,n=null,a=[];try{try{await U.messageStream(i,e,{onPhase:(e,t,n)=>{!s()||n.heartbeat||(a=Kn(a,{label:e,role:t,kind:n.kind,detail:n.detail,heartbeat:n.heartbeat,quietS:n.quietS}),xe(a))},onDelta:(e,n,r)=>{s()&&(t=!0,a=qn(a),xe(a),u(e,n,r===`append`||r===`snapshot`?r:`auto`))},onDone:e=>{if(!s())return;u(e.reply,``,`snapshot`),f(e);let t=e.item;(e.kind!==`task`||typeof t?.id!=`string`)&&r?.({type:`settled`,outcome:e.kind===`error`?`error`:`message`})},onError:e=>{s()&&(n=e)}},{signal:o.signal,attachments:l,routeOverride:me})}catch(e){s()&&(n=e)}if(!s())return;n&&(I(`error`,mi(n,t)),r?.({type:`settled`,outcome:`error`}))}finally{o.signal.aborted&&r?.({type:`settled`,outcome:`cancelled`}),c()}})(),!0},qt=(0,F.useRef)(Kt);qt.current=Kt;let Jt=(0,F.useMemo)(()=>{let n=Fa(Nt,e=>{qt.current(e)},e=>{de(e),M(e=>e+1)},e),r=[...f?[]:[{id:`new`,label:t(`palette.newDaemon`),hint:`+`,group:t(`palette.view`),run:()=>ke(!0)}],{id:`transcript`,label:t(`palette.openTranscript`),hint:`/transcript`,group:t(`palette.view`),run:()=>u(`transcript`)},{id:`inspector`,label:t(`palette.openProject`),hint:t(`palette.projectHint`),group:t(`palette.view`),run:()=>u(`inspector`)},{id:`operations`,label:t(`palette.openOperations`),hint:t(`palette.operationsHint`),group:t(`palette.view`),run:()=>u(`operations`)},{id:`help`,label:t(`help.title`),hint:`?`,group:t(`palette.view`),run:()=>u(`help`)},{id:`reasoning`,label:t(ie?`palette.hideReasoning`:`palette.showReasoning`),hint:`⌘T`,group:t(`palette.view`),run:()=>T(e=>!e)},{id:`kiosk`,label:t(f?`palette.exitKiosk`:`palette.enterKiosk`),hint:`⌘.`,group:t(`palette.view`),run:()=>y(e=>!e)}],i=f?[]:[{id:`message`,label:t(`palette.messageArgus`),hint:`/`,group:t(`palette.action`),run:()=>M(e=>e+1)},...ge?[{id:`cancel-message`,label:t(`palette.stopWaiting`),hint:`Esc`,group:t(`palette.action`),run:Qe}]:[],...ot?[{id:`continuous`,label:ot.enabled?t(`palette.stopContinuous`):t(`palette.startContinuous`),group:t(`palette.action`),run:Ut}]:[],...V?.daemon.control_available===!1?[]:[V?.daemon.alive?{id:`stop`,label:t(`palette.stopDaemon`),group:t(`palette.action`),run:Vt}:{id:`start`,label:t(`palette.startDaemon`),group:t(`palette.action`),run:Bt}]],o=a.map(e=>({id:`p-${e.id}`,label:e.label||e.id,hint:e.daemon_alive?`● ${t(`common.live`)}`:`○`,keywords:`${e.id} ${e.display_name??``} ${e.objective} ${e.daemon_alive?`live running`:`stopped idle`}`,group:t(`palette.project`),run:()=>z(e.id)}));return[...r,...i,...n,...o]},[a,V?.daemon.alive,f,ie,ot?.enabled,ge,Qe,e,t]);return(0,X.jsxs)(`div`,{ref:re,style:{"--sidebar-width":`${m}px`,"--preview-width":`${v}px`},className:`workbench-shell ambient-canvas flex w-screen max-w-full overflow-hidden text-ink`,children:[(0,X.jsx)(Bc,{error:c,onRetry:()=>{r.refetch(),i.refetch()}}),Et.selection&&(0,X.jsx)(Jo,{sid:Et.selection.sid,path:Et.selection.path,delivery:Et.selection.receipt,deliveries:Ot,onSelectDelivery:Dt,onSelectPath:Et.selectPath,onClose:Et.close},`${Et.selection.sid}:${Et.selection.receipt.delivery_id}`),!f&&D?(0,X.jsx)(`button`,{type:`button`,"aria-label":t(`common.closeSessions`),onClick:()=>E(!1),className:`fixed inset-0 z-30 bg-black/40 lg:hidden`}):null,f?null:(0,X.jsx)(_s,{projects:a,activeId:L,localCwd:s,onSelect:e=>{z(e),E(!1)},onPrefetch:R,onManage:zt,onResume:e=>void Mt(e),resumingId:Pe,onOpenPanel:e=>u(e),onNew:()=>ke(!0),loading:r.isLoading,creating:it,error:r.isError?pi(r.error):void 0,onRetry:()=>void r.refetch(),mobileOpen:D,collapsed:!p,onToggleCollapse:()=>b(e=>!e),themeMode:ae,onCycleTheme:d}),!f&&p?(0,X.jsx)(ks,{label:t(`common.resizeSessions`),value:m,min:220,max:400,onPointerDown:e=>g(`left`,e),onReset:()=>x(256),onNudge:e=>x(t=>Math.max(220,Math.min(400,t+e)))}):null,(0,X.jsx)(`main`,{className:`flex min-w-0 flex-1 overflow-x-hidden`,children:V?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`${h===`activity`?`flex`:`hidden`} glass-panel glass-panel--main h-full min-w-0 flex-1 flex-col lg:flex`,children:[O!==`map`&&(0,X.jsx)(Zr,{snap:V,streamOk:ut,onStart:Bt,onStop:Vt,onManage:()=>L&&zt(L),busy:Pt,snapshotStale:B.isError,readOnly:f,missionView:bt}),(0,X.jsxs)(`div`,{className:`hidden h-10 shrink-0 items-center gap-1 border-b border-line/60 px-3 lg:flex`,children:[(0,X.jsxs)(`div`,{className:`workspace-tabs`,"data-active":O,children:[(0,X.jsx)(`span`,{className:`workspace-tab-indicator`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`mission`),className:`workspace-tab`,"data-selected":O===`mission`,children:t(`mobile.mission`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`activity`),className:`workspace-tab`,"data-selected":O===`activity`,children:t(`mobile.activity`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`workbench`),className:`workspace-tab`,"data-selected":O===`workbench`,children:t(`mobile.workbench`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>ne(`map`),className:`workspace-tab`,"data-selected":O===`map`,children:t(`mobile.map`)})]}),O===`mission`?(0,X.jsx)(`span`,{className:`ml-auto hidden max-w-72 truncate text-[10px] text-ink-faint sm:block`,children:bt?.active_role?t(`mission.roleActive`,{role:bt.active_role}):t(`mission.overview`)}):(0,X.jsx)(`span`,{className:`ml-auto`}),!f&&O!==`map`?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(`operations`),className:`rounded border border-line/60 px-2 py-1 text-[10px] text-ink-faint hover:border-blue/50 hover:text-blue`,children:t(`mission.operations`)}):null]}),O===`map`&&(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`m-auto text-sm text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Wc,{snapshot:V,events:lt,managerSteps:be,draft:ue,onDraftChange:de,onSend:Kt,pending:ge,onCancel:Qe,focusSignal:j,readOnly:f,onOpenSettings:()=>u(`config`),routeOverride:me,onRouteOverrideChange:he,conversationEvents:yt,connected:ut,artifacts:st.data??[],deliveryCount:Ot.length,onOpenDelivery:()=>{Ot[0]&&Dt(Ot[0])},onOpenReceipt:Dt,onOpenArtifact:Ce,onAnswer:()=>vt(!0)},V.session.id)}),(0,X.jsxs)(`div`,{className:`${O===`workbench`||O===`map`?`hidden`:`flex`} min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(lo,{alert:ft}),k===`mission`&&bt?(0,X.jsx)(Qs,{view:bt,sid:V.session.id,snapshot:V,gitDiff:ct.data,artifacts:st.data,onOpenArtifact:Tt,onOpenDelivery:Dt,onNotify:I}):(0,X.jsx)(aa,{events:yt,connected:ut,showReasoning:ie,onToggleReasoning:()=>T(e=>!e),embedded:!0,filter:Ke,query:Je,skipFirst:We.skipFirst,artifacts:st.data,onOpenArtifact:Tt,onOpenDelivery:Dt}),f?null:(0,X.jsx)(`div`,{className:`composer-dock shrink-0 px-4 pt-3`,children:(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-full lg:max-w-[61.8vw]`,children:[(0,X.jsx)(so,{questions:V.pending_questions??[],backlog:V.backlog,onAnswer:()=>vt(!0)}),(0,X.jsx)(Ma,{value:ue,onChange:de,onSend:Kt,onCancel:Qe,disabled:!L,pending:ge,focusSignal:j,embedded:!0,steps:be,onRewrite:nt,rewriting:fe,slashSelection:N,onSlashSelectionChange:P,routeOverride:me,onRouteOverrideChange:he},L||`no-session`)]})})]}),A&&L?(0,X.jsx)(`div`,{className:`${O===`workbench`?`flex`:`hidden`} min-h-0 flex-1`,children:(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-xs text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Uc,{sid:L,active:O===`workbench`})})}):null]}),_&&O!==`map`?(0,X.jsx)(ks,{label:t(`common.resizePreview`),value:v,min:320,max:600,onPointerDown:e=>g(`right`,e),onReset:()=>w(440),onNudge:e=>w(t=>Math.max(320,Math.min(600,t-e)))}):null,(O!==`map`||h===`preview`)&&(0,X.jsxs)(`aside`,{"data-resizable-panel":`right`,className:`${h===`preview`?`flex`:`hidden`} relative min-w-0 flex-1 flex-col overflow-hidden border-l border-line/60 bg-panel transition-[width] duration-[250ms] ease-panel lg:flex lg:flex-none ${_?`lg:w-[var(--preview-width)]`:`lg:w-14`}`,children:[(0,X.jsx)(`div`,{className:`lg:hidden`,children:(0,X.jsx)(Zr,{snap:V,streamOk:ut,onStart:Bt,onStop:Vt,onManage:()=>L&&zt(L),busy:Pt,snapshotStale:B.isError,readOnly:f,missionView:bt})}),(0,X.jsx)(ds,{sid:H,artifacts:st.data,error:st.isError,onExpand:Ce,className:`min-h-0 flex-1 mobile-scroll-region ${_?`lg:flex`:`lg:hidden`}`,embedded:!0,onCollapse:()=>C(!1),missionView:bt,activityEvents:yt,requestedPath:we.path,requestedPathToken:we.token}),_?null:(0,X.jsx)(`div`,{className:`hidden h-12 items-center justify-center border-b border-line/50 text-ink-faint lg:flex`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>C(!0),"aria-label":t(`common.expandPreview`),title:t(`common.expandPreview`),className:`flex h-8 w-8 items-center justify-center rounded-md border border-line/50 bg-bg/40 hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:ee,className:`h-3.5 w-3.5`})})})]})]}):(0,X.jsx)(oc,{loading:r.isLoading||!!(L&&B.isLoading),hasProjects:a.length>0,error:r.isError&&a.length===0?pi(r.error):B.isError&&!V?pi(B.error):void 0,onRetry:()=>{r.refetch(),L&&B.refetch()},onNew:()=>ke(!0),onChoose:()=>E(!0),canCreate:!f})}),(0,X.jsx)(La,{open:l===`palette`,onClose:()=>u(`none`),items:Jt}),(0,X.jsx)(za,{open:l===`help`,onClose:()=>u(`none`)}),L&&(0,X.jsx)(ro,{sid:L,open:l===`doctor`,onClose:()=>u(`none`)}),L&&(0,X.jsx)(io,{sid:L,open:l===`config`,onClose:()=>u(`none`),themeStyle:oe,onThemeStyleChange:te}),L&&(0,X.jsx)(ao,{sid:L,open:l===`identity`,onClose:()=>u(`none`)}),L&&(0,X.jsx)(oo,{sid:L,open:l===`transcript`,onClose:()=>u(`none`)}),L&&V?(0,X.jsx)(Ts,{open:l===`inspector`,snap:V,journal:mt.data??[],busy:At.disposeBacklog.isPending||At.stopBacklog.isPending,onClose:()=>u(`none`),onDispose:Rt,onStop:Ht,onInspect:De}):null,L&&V?(0,X.jsx)(rc,{open:l===`operations`,sid:L,snap:V,onClose:()=>u(`none`),onChanged:()=>{B.refetch(),r.refetch()},onRestored:async e=>{await r.refetch(),z(e)}}):null,(0,X.jsx)(Jo,{sid:L,path:Se,onClose:()=>Ce(null)}),(0,X.jsx)(Os,{sid:L,itemId:Ee,onClose:()=>De(null),onDone:e=>Rt(e,`done`),onSkip:e=>Rt(e,`rm`),onStop:Ht,busy:At.disposeBacklog.isPending||At.stopBacklog.isPending,readOnly:f}),(0,X.jsx)(ps,{open:Oe,busy:it,onClose:()=>ke(!1),onCreate:rt}),(0,X.jsx)(co,{reply:gt,open:G,busy:_t,onClose:()=>vt(!1),onSubmit:ht}),Me?(0,X.jsx)(ms,{open:Ae,sid:Me,name:at.data?.session.display_name||a.find(e=>e.id===Me)?.display_name||a.find(e=>e.id===Me)?.label||``,alive:at.data?.daemon.alive??!!a.find(e=>e.id===Me)?.daemon_alive,controlAvailable:at.data?.daemon.control_available!==!1,busy:Pt,onClose:()=>{je(!1),Ne(null)},onRename:It,onStart:Lt,onStop:K,onDelete:Ft}):null,(0,X.jsx)(fs,{notice:He,onClose:Xe}),V&&!f?(0,X.jsx)(sc,{active:h===`preview`?`preview`:O,sidebarOpen:D,onSelect:e=>{if(e===`preview`){S(`preview`);return}S(`activity`),ne(e)},onOpenSessions:()=>E(!0)}):null]})}function Kc({onDone:e}){let{t}=Z(),n=(0,F.useRef)(!1),r=(0,F.useCallback)(()=>{n.current||(n.current=!0,e())},[e]);return(0,F.useEffect)(()=>{let e=window.setTimeout(r,970),t=()=>r();return window.addEventListener(`keydown`,t,{once:!0}),()=>{window.clearTimeout(e),window.removeEventListener(`keydown`,t)}},[r]),(0,X.jsx)(`div`,{role:`status`,"aria-label":t(`splash.starting`),onClick:r,onAnimationEnd:e=>{e.currentTarget===e.target&&r()},className:`argus-web-splash`,children:(0,X.jsx)(`div`,{className:`argus-web-splash-logo`,"aria-hidden":`true`,children:(0,X.jsx)(ki,{size:168})})})}function qc(e,t){let n=!1;e.addEventListener(`vite:preloadError`,e=>{e.preventDefault(),!n&&(n=!0,t())})}qc(window,()=>window.location.reload()),Ge();var Jc=window.parent!==window;document.documentElement.dataset.argusEmbedded=String(Jc);var Yc=new Oe({defaultOptions:{queries:{staleTime:3e3,retry:pr,refetchOnWindowFocus:!1}}});function Xc(){let[e,t]=(0,F.useState)(!Jc);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Gc,{}),e?(0,X.jsx)(Kc,{onDone:()=>t(!1)}):null]})}ke.createRoot(document.getElementById(`root`)).render((0,X.jsx)(F.StrictMode,{children:(0,X.jsx)(fe,{client:Yc,children:(0,X.jsx)(Jr,{children:(0,X.jsx)(Xc,{})})})}));export{Z as A,oa as C,di as D,Oi as E,et as F,Ce as I,qe as M,Je as N,ai as O,st as P,ka as S,ki as T,so as _,Po as a,ya as b,wo as c,bo as d,yo as f,ho as g,go as h,Io as i,U as j,$r as k,So as l,_o as m,Nc as n,Do as o,vo as p,zs as r,To as s,Mc as t,xo as u,Na as v,aa as w,Ea as x,Aa as y}; \ No newline at end of file diff --git a/frontend/web/dist/assets/pdf-DN4bD3_L.js b/frontend/web/dist/assets/pdf-Bit9sP4D.js similarity index 99% rename from frontend/web/dist/assets/pdf-DN4bD3_L.js rename to frontend/web/dist/assets/pdf-Bit9sP4D.js index d1f33f7b9..6ef2710cc 100644 --- a/frontend/web/dist/assets/pdf-DN4bD3_L.js +++ b/frontend/web/dist/assets/pdf-Bit9sP4D.js @@ -1,4 +1,4 @@ -import{O as e}from"./index-TnyRuCvG.js";var t=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),n=[1/0,1/0,-1/0,-1/0],r=new Float32Array(n),i=[.001,0,0,.001,0,0],a=`http://www.w3.org/2000/svg`,o={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},s={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},c=`pdfjs_internal_id_`,l=`pdfjs_internal_editor_`,u={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},d={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},f={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},p={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},m={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},h={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},g={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},_={ERRORS:0,WARNINGS:1,INFOS:5},v={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},y={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},x=_.WARNINGS;function S(e){Number.isInteger(e)&&(x=e)}function C(){return x}function w(e){x>=_.INFOS&&console.info(`Info: ${e}`)}function T(e){x>=_.WARNINGS&&console.warn(`Warning: ${e}`)}function E(e){throw Error(e)}function D(e,t){e||E(t)}function O(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function k(e,t=null,n=null){if(!e)return null;if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=se(e)}catch{}let r=t?URL.parse(e,t):URL.parse(e);return O(r)?r:null}function A(e,t,n=!1){let r=URL.parse(e);return r?(r.hash=t,r.href):n&&k(e,`http://example.com`)?e.split(`#`,1)[0]+`${t?`#${t}`:``}`:``}function j(e){return e.substring(e.lastIndexOf(`/`)+1)}function M(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var N=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),ee=class extends N{constructor(e,t){super(e,`PasswordException`),this.code=t}},te=class extends N{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},ne=class extends N{constructor(e){super(e,`InvalidPDFException`)}},re=class extends N{constructor(e,t,n){super(e,`ResponseException`),this.status=t,this.missing=n}},ie=class extends N{constructor(e){super(e,`FormatError`)}},P=class extends N{constructor(e){super(e,`AbortException`)}};function ae(e){(typeof e!=`object`||e?.length===void 0)&&E(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t`u`)return M(this,`isAlphaColorInputSupported`,!1);let e=document.createElement(`input`);return e.type=`color`,e.setAttribute(`alpha`,``),e.value=`#ff000080`,M(this,`isAlphaColorInputSupported`,e.value!==`#ff0000`)}static get isBackdropFilterSupported(){return M(this,`isBackdropFilterSupported`,typeof CSS<`u`&&CSS.supports(`backdrop-filter`,`blur(1px)`))}},I=class{static get hexNums(){return M(this,`hexNums`,Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)))}static makeHexColor(e,t,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,n=0){let r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4],e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];for(let t=0;t<6;t+=2){let l=e[n+t],u=e[n+t+1];e[n+t]=l*r+u*a+s,e[n+t+1]=l*i+u*o+c}}static applyInverseTransform(e,t){let n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=e[0],u=e[1],d=e[2],f=e[3],p=r*l+s,m=p,h=r*d+s,g=h,_=o*u+c,v=_,y=o*f+c,b=y;if(i!==0||a!==0){let e=i*l,t=i*d,n=a*u,r=a*f;p+=n,g+=n,h+=r,m+=r,_+=e,b+=e,y+=t,v+=t}n[0]=Math.min(n[0],p,h,m,g),n[1]=Math.min(n[1],_,y,v,b),n[2]=Math.max(n[2],p,h,m,g),n[3]=Math.max(n[3],_,y,v,b)}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){let n=e[0],r=e[1],i=e[2],a=e[3],o=n**2+r**2,s=n*i+r*a,c=i**2+a**2,l=(o+c)/2,u=Math.sqrt(l**2-(o*c-s**2));t[0]=Math.sqrt(l+u||1),t[1]=Math.sqrt(l-u||1)}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,r,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],t,r),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],t,r)}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s),this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c)}};function se(e){return decodeURIComponent(escape(e))}var ce=null,le=null;function ue(e){return ce||(ce=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,le=new Map([[`ſt`,`ſt`]])),e.replaceAll(ce,(e,t,n)=>t?t.normalize(`NFKC`):le.get(n))}function de(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),ae(e)}function fe(e,t,n){if(!Array.isArray(n)||n.length<2)return!1;let[r,i,...a]=n;if(!e(r)&&!Number.isInteger(r)||!t(i))return!1;let o=a.length,s=!0;switch(i.name){case`XYZ`:if(o<2||o>3)return!1;break;case`Fit`:case`FitB`:return o===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(o>1)return!1;break;case`FitR`:if(o!==4)return!1;s=!1;break;default:return!1}for(let e of a)if(!(typeof e==`number`||s&&e===null))return!1;return!0}var pe=()=>[],me=()=>new Map,he=()=>Object.create(null),ge=()=>new Set;typeof Iterator.prototype.join!=`function`&&(Iterator.prototype.join=function(e){return[...this].join(e)});function L(e,t,n){return Math.min(Math.max(e,t),n)}var _e=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let e=this.viewBox;return M(this,`rawDims`,{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){let n=[e,t];return I.applyTransform(n,this.transform),n}convertToPdfPoint(e,t){let n=[e,t];return I.applyInverseTransform(n,this.transform),n}},ve=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return e!==`textarea`&&e!==`input`&&e!==`option`&&e!==`select`}},ye=/url\(|image-set\(/i,be=/^on/i,xe=class{static get _allowedHtmlElements(){return M(this,`_allowedHtmlElements`,new Set([`a`,`b`,`br`,`button`,`div`,`i`,`img`,`input`,`label`,`li`,`ol`,`option`,`p`,`select`,`span`,`sub`,`sup`,`textarea`,`ul`]))}static get _allowedSvgElements(){return M(this,`_allowedSvgElements`,new Set([`ellipse`,`line`,`path`,`rect`,`svg`]))}static get _allowedRichTextElements(){return M(this,`_allowedRichTextElements`,new Set([`a`,`b`,`br`,`div`,`i`,`li`,`ol`,`p`,`span`,`sub`,`sup`,`ul`]))}static get _allowedRichTextAttributes(){return M(this,`_allowedRichTextAttributes`,new Set([`class`,`dir`,`style`]))}static get _allowedRichTextStyles(){return M(this,`_allowedRichTextStyles`,new Set(`color.font.fontFamily.fontSize.fontStretch.fontStyle.fontWeight.kerningMode.letterSpacing.lineHeight.margin.marginBottom.marginLeft.marginRight.marginTop.orphans.paddingLeft.paddingRight.breakAfter.breakBefore.breakInside.tabInterval.tabStop.textAlign.textDecoration.textIndent.transform.verticalAlign.widows`.split(`.`)))}static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})})}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null&&!be.test(t)&&!(r===`richText`&&!this._allowedRichTextAttributes.has(t)))switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:if(r===`richText`){let t=this._allowedRichTextStyles;for(let[r,i]of Object.entries(n))t.has(r)&&!ye.test(i)&&(e.style[r]=i)}else Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i?.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static#e(e,t,n){return n===`richText`?!t&&this._allowedRichTextElements.has(e)?document.createElement(e):null:t?t===a&&this._allowedSvgElements.has(e)?document.createElementNS(a,e):null:this._allowedHtmlElements.has(e)?document.createElement(e):null}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=this.#e(r.name,r.attributes?.xmlns,i)??document.createElement(`div`);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&ve.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=this.#e(u,s.attributes?.xmlns,i);if(d){if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&ve.shouldBuildText(u)&&c.push(e),d.append(e)}}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new _e({viewBox:[0,0,parseInt(r,10),parseInt(i,10)],userUnit:1,scale:t,rotation:n})}},Se=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ce(e,t=`text`){if(Ae(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`blob`:return n.blob();case`bytes`:return n.bytes();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t===`bytes`?`arraybuffer`:t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`bytes`:n(new Uint8Array(i.response));return;case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}var we=class extends N{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function Te(e){let t=e.length,n=0;for(;n{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,`https://foo.bar`)}catch{}try{return new URL(decodeURIComponent(e),`https://foo.bar`)}catch{}return null})(e);if(!n)return t;let r=e=>{try{let t=decodeURIComponent(e);return t.includes(`/`)&&(t=j(t),t.length===4&&i.test(t))?e:t}catch{return e}},i=/\.pdf$/i,a=j(n.pathname);if(i.test(a))return r(a);if(n.searchParams.size>0){let e=e=>[...e].findLast(e=>i.test(e)),t=e(n.searchParams.values())??e(n.searchParams.keys());if(t)return r(t)}if(n.hash){let e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(e)return r(e[0])}return t}var ke=class{#e=new Map;times=[];time(e){this.#e.has(e)&&T(`Timer is already running for ${e}`),this.#e.set(e,Date.now())}timeEnd(e){this.#e.has(e)||T(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.#e.get(e),end:Date.now()}),this.#e.delete(e)}toString(){let e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join(``)}};function Ae(e,t){let n=t?URL.parse(e,t):URL.parse(e);return/https?:/.test(n?.protocol??``)}function R(e){e.preventDefault()}function z(e){e.preventDefault(),e.stopPropagation()}var je=class{static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!=`string`)return null;this.#e||=RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?`);let t=this.#e.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}};function Me(e){if(e.startsWith(`#`)){let t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith(`rgb(`)){let[t,n,r]=e.slice(4,-1).split(`,`).map(e=>parseInt(e,10));return[t,n,r,1]}if(e.startsWith(`rgba(`)){let t=e.slice(5,-1).split(`,`);return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!==`none`?parseFloat(t[4]):1]:null}function Ne(e){let t=Me(e);return t?t.slice(0,3):(T(`Not a valid color format: "${e}"`),[0,0,0])}function Pe(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,t.style.colorScheme=`only light`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,Ne(r))}t.remove()}function B(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function V(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Fe(e,t,n=!1,r=!0){if(t instanceof _e){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,s=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!n||t.rotation%180==0?(a.width=o,a.height=s):(a.width=s,a.height=o)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var Ie=class e{constructor(){let{pixelRatio:t}=e;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,n,r,i,a=-1){let o=1/0,s=1/0,c=1/0;r=e.capPixels(r,a),r>0&&(o=Math.sqrt(r/(t*n))),i!==-1&&(s=i/t,c=i/n);let l=Math.min(o,s,c);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let n=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,n):n}return e}},Le=[`image/apng`,`image/avif`,`image/bmp`,`image/gif`,`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`image/x-icon`],Re=class{static get isDarkMode(){return M(this,`isDarkMode`,!!window?.matchMedia?.(`(prefers-color-scheme: dark)`).matches)}},ze=class{static get commentForegroundColor(){let e=document.createElement(`span`);e.classList.add(`comment`,`sidebar`);let{style:t}=e;t.width=t.height=`0`,t.display=`none`,t.color=`var(--comment-fg-color)`,document.body.append(e);let{color:n}=window.getComputedStyle(e);return e.remove(),M(this,`commentForegroundColor`,Ne(n))}};function Be(e,t){t=L(t??1,0,1);let n=255*(1-t);return e.map(e=>Math.round(e*t+n))}function Ve(e,t){let n=e[0]/255,r=e[1]/255,i=e[2]/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)t[0]=t[1]=0;else{let e=a-o;switch(t[1]=s<.5?e/(a+o):e/(2-a-o),a){case n:t[0]=((r-i)/e+(ri?(r+.05)/(i+.05):(i+.05)/(r+.05)}var Ge=new Map;function Ke(e,t){let n=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,r=Ge.get(n);if(r)return r;let i=new Float32Array(9),a=i.subarray(0,3),o=i.subarray(3,6);Ve(e,o);let s=i.subarray(6,9);Ve(t,s);let c=s[2]<.5,l=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),We(o,s,a).005;){let n=o[2]=(e+t)/2;c===We(o,s,a){n.delete()},{signal:n._signal}),this.#r.append(r)}get#p(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#f(t),this.#r.append(t,this.#p),this.#i=e}addComment(e,t=null){if(this.#a)return;let n=e.renderForToolbar();if(!n)return;this.#f(n);let r=this.#o=this.#p;t?(this.#r.insertBefore(n,t),this.#r.insertBefore(r,t)):this.#r.append(n,r),this.#a=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;let t=e.renderButton();this.#f(t),this.#r.append(t,this.#p)}async addEditSignatureButton(e){let t=this.#s=await e.renderEditButton(this.#n);this.#f(t),this.#r.append(t,this.#p)}removeButton(e){e===`comment`&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#o?.remove(),this.#o=null)}async addButton(e,t){switch(e){case`colorPicker`:t&&this.addColorPicker(t);break;case`altText`:t&&await this.addAltText(t);break;case`editSignature`:t&&await this.addEditSignatureButton(t);break;case`delete`:this.addDeleteButton();break;case`comment`:t&&this.addComment(t)}}async addButtonBefore(e,t,n){if(!t&&e===`comment`)return;let r=this.#r.querySelector(n);r&&e===`comment`&&this.addComment(t,r)}updateEditSignatureButton(e){this.#s&&(this.#s.title=e)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},Xe=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`);let t=this.#n._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener(`contextmenu`,R,{signal:t});let n=this.#e=document.createElement(`div`);return n.className=`buttons`,e.append(n),this.#n.hasCommentManager()&&this.#a(`commentButton`,`pdfjs-comment-floating-button`,`pdfjs-comment-floating-button-label`,()=>{this.#n.commentSelection(`floating_button`)}),this.#a(`highlightButton`,`pdfjs-highlight-floating-button1`,`pdfjs-highlight-floating-button-label`,()=>{this.#n.highlightSelection(`floating_button`)}),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(en){r=a,n=e;continue}t?a>r&&(r=a):a=1}static clearPointerType(){e.#r=null}static clearPointerIds(){e.#e=NaN,e.#t=null}static clearTimeStamp(){e.#n=NaN}},$e=class{#e=0;get id(){return`${l}${this.#e++}`}},et=class e{#e=de();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=`data:image/svg+xml;charset=UTF-8,`,t=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),n=new Image;n.src=e;let r=n.decode().then(()=>(t.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0));return M(this,`_isSVGFittingCanvas`,r)}async#r(t,n){this.#n||=new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await Ce(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){T(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},tt=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},nt=class e{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:n}=F.platform;for(let[r,i,a={}]of t){let t=r.some(e=>e.startsWith(`mac+`));for(let o of r){let r=o;if(t){let e=o.startsWith(`mac+`);if(n!==e)continue;e&&(r=o.slice(4))}let[s,c]=e.#e(r);s!==null&&this.callbacks.getOrInsertComputed(s,pe).push({callback:i,options:a,modifiers:c})}}}static#e(t){let n=null,r=0;for(let i of t.split(`+`)){if(i=i.trim(),!i)continue;let a=i.toUpperCase(),o=e[a];if(o){r|=o;continue}if(n!==null){T(`KeyboardManager: multiple keys in shortcut "${t}"`);break}n=a===`SPACE`?` `:i}return n===null&&T(`KeyboardManager: no key found in shortcut "${t}"`),[n,r]}static#t(e){let t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?t[1]?.toLowerCase()??t[2]:null}exec(t,n){let r=this.callbacks.get(n.key);if(!r){if(/^[a-z]$/i.test(n.key))return;let t=e.#t(n.code);if(t===null||t===n.key||(r=this.callbacks.get(t),!r))return}let i=(n.altKey?e.ALT:0)|(n.ctrlKey?e.CTRL:0)|(n.metaKey?e.META:0)|(n.shiftKey?e.SHIFT:0),a=r.find(e=>e.modifiers===i);if(!a)return;let{callback:o,options:{bubbles:s=!1,args:c=[],checker:l=null}}=a;l&&!l(t,n)||(o.bind(t,...c,n)(),s||z(n))}},rt=class e{static _colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return Pe(e),M(this,`_colors`,e)}convert(t){let n=Ne(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?I.makeHexColor(...t):e}},it=class e{#e=new AbortController;#t=null;#n=null;#r=new Map;#i=new Map;#a=null;#o=null;#s=null;#c=null;#l=new tt;#u=null;#d=null;#f=null;#p=0;#m=new Set;#h=null;#g=null;#_=new Set;_editorUndoBar=null;#v=!1;#y=!1;#b=!1;#x=null;#S=null;#C=null;#w=null;#T=!1;#E=null;#D=new $e;#O=!1;#k=!1;#A=!1;#j=null;#M=null;#N=null;#P=null;#F=null;#I=u.NONE;#L=new Set;#R=null;#z=null;#B=null;#V=null;#H=null;#U={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#W=[0,0];#G=null;#K=null;#q=null;#J=null;#Y=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#K.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return M(this,`_keyboardManager`,new nt([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#K.contains(t)&&!e.isEnterHandled}],[[`Space`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#K.contains(document.activeElement)}],[[`Escape`],t.unselectAll],[[`ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this._signal=this.#e.signal;this.#K=e,this.#q=t,this.#J=n,this.#o=r,this.#u=i,this.#z=a,this.#H=s,this._eventBus=o;let _={signal:g,...Ze};o.on(`editingaction`,this.onEditingAction.bind(this),_),o.on(`pagechanging`,this.onPageChanging.bind(this),_),o.on(`scalechanging`,this.onScaleChanging.bind(this),_),o.on(`rotationchanging`,this.onRotationChanging.bind(this),_),o.on(`setpreference`,this.onSetPreference.bind(this),_),o.on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),_),window.addEventListener(`pointerdown`,()=>{this.#k=!0},{capture:!0,signal:g}),window.addEventListener(`pointerup`,()=>{this.#k=!1},{capture:!0,signal:g}),window.addEventListener(`beforeunload`,this.endCurrentEditing.bind(this),{capture:!0,signal:g}),this.#te(),this.#ce(),this.#ie(),this.#s=s.annotationStorage,this.#x=s.filterFactory,this.#B=c,this.#w=l||null,this.#v=u,this.#y=d,this.#b=f,this.#F=p||null,this.viewParameters={realScale:Se.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=h!==!1,i?.setSidebarUiManager(this)}destroy(){this.#Y?.resolve(),this.#Y=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#i.values())e.destroy();this.#i.clear(),this.#r.clear(),this.#_.clear(),this.#P?.clear(),this.#t=null,this.#L.clear(),this.#l.destroy(),this.#o?.destroy(),this.#u?.destroy(),this.#z?.destroy(),this.#E?.hide(),this.#E=null,this.#N?.destroy(),this.#N=null,this.#n=null,this.#S&&=(clearTimeout(this.#S),null),this.#G&&=(clearTimeout(this.#G),null),this._editorUndoBar?.destroy(),this.#H=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#F}get useNewAltTextFlow(){return this.#y}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return M(this,`hcmFilter`,this.#B?this.#x.addHCMFilter(this.#B.foreground,this.#B.background):`none`)}get direction(){return M(this,`direction`,getComputedStyle(this.#K).direction)}get _highlightColors(){return M(this,`_highlightColors`,this.#w?new Map(this.#w.split(`,`).map(e=>(e=e.split(`=`).map(e=>e.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return M(this,`highlightColors`,null);let t=new Map,n=!!this.#B;for(let[r,i]of e){let e=r.endsWith(`_HCM`);if(n&&e){t.set(r.replace(`_HCM`,``),i);continue}!n&&!e&&t.set(r,i)}return M(this,`highlightColors`,t)}get highlightColorNames(){return M(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#f=e}setMainHighlightColorPicker(e){this.#N=e}editAltText(e,t=!1){this.#o?.editAltText(this,e,t)}hasCommentManager(){return!!this.#u}editComment(e,t,n,r){this.#u?.showDialog(this,e,t,n,r)}selectComment(e,t){(this.#i.get(e)?.getEditorByUID(t))?.toggleComment(!0,!0)}updateComment(e){this.#u?.updateComment(e.getData())}updatePopupColor(e){this.#u?.updatePopupColor(e)}removeComment(e){this.#u?.removeComments([e.uid])}deleteComment(e,t){let n=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,`comment`),this.toggleComment(null),e.comment=null},undo:n,mustExec:!0})}toggleComment(e,t,n=void 0){this.#u?.toggleCommentPopup(e,t,n)}makeCommentColor(e,t){return e&&this.#u?.makeCommentColor(e,t)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(e){if(this.#i.has(e-1))return;let{resolve:t,promise:n}=Promise.withResolvers(),r=n=>{n.pageNumber===e&&(this._eventBus.off(`editorsrendered`,r),t())};this._eventBus.on(`editorsrendered`,r,Ze),await n}getSignature(e){this.#z?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#z}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal,...Ze}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){e===`enableNewAltTextWhenAddingImage`&&(this.#b=t)}onPageChanging({pageNumber:e}){this.#p=e-1}deletePage(e){for(let t of this.getEditors(e))t.remove();this.#i.delete(e),this.#p===e&&(this.#p=0)}focusMainContainer(){this.#K.focus()}findParent(e,t){for(let n of this.#i.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#q.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#_.add(e)}removeShouldRescale(e){this.#_.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Se.PDF_TO_CSS_UNITS;for(let e of this.#_)e.onScaleChanging();this.#f?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#X({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Z(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#i.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``,t=!1){let n=document.getSelection();if(!n||n.isCollapsed)return;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n,s=n.toString(),c=this.#X(n).closest(`.textLayer`),l=this.getSelectionBoxes(c);if(!l)return;n.empty();let d=this.#Z(c),f=this.#I===u.NONE,p=()=>{let n=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o,text:s});f&&this.showAllEditors(`highlight`,!0,!0),t&&n?.editComment()};if(f){this.switchToMode(u.HIGHLIGHT,p);return}p()}commentSelection(e=``){this.highlightSelection(e,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Q(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#X(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#E||=new Xe(this),this.#E.show(t,n,this.direction===`ltr`))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#s)return null;let t=`${l}${e}`,n=this.#s.getRawValue(t);return n&&this.#s.remove(t),n}addToAnnotationStorage(e){!e.isEmpty()&&this.#s&&!this.#s.has(e.id)&&this.#s.setValue(e.id,e)}a11yAlert(e,t=null){let n=this.#J;n&&(n.setAttribute(`data-l10n-id`,e),t?n.setAttribute(`data-l10n-args`,JSON.stringify(t)):n.removeAttribute(`data-l10n-args`))}#$(){let e=document.getSelection();if(!e||e.isCollapsed){this.#R&&(this.#E?.hide(),this.#R=null,this.#le({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#R)return;let n=this.#X(e).closest(`.textLayer`);if(!n){this.#R&&(this.#E?.hide(),this.#R=null,this.#le({hasSelectedText:!1}));return}if(this.#E?.hide(),this.#R=t,this.#le({hasSelectedText:!0}),(this.#I===u.HIGHLIGHT||this.#I===u.NONE)&&(this.#I===u.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#T=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#I===u.HIGHLIGHT?this.#Z(n):null;if(e?.toggleDrawing(),this.#k){let t=new AbortController,n=this.combinedSignal(t),r=n=>{(n.type!==`pointerup`||n.button===0)&&(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#ee(`main_toolbar`))};window.addEventListener(`pointerup`,r,{signal:n}),window.addEventListener(`blur`,r,{signal:n})}else e?.toggleDrawing(!0),this.#ee(`main_toolbar`)}}#ee(e=``){this.#I===u.HIGHLIGHT?this.highlightSelection(e):this.#v&&this.#Q()}#te(){document.addEventListener(`selectionchange`,this.#$.bind(this),{signal:this._signal})}#ne(){if(this.#C)return;this.#C=new AbortController;let e=this.combinedSignal(this.#C);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#re(){this.#C?.abort(),this.#C=null}blur(){if(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#ee(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#L)if(t.div.contains(e)){this.#M=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#M)return;let[e,t]=this.#M;this.#M=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ie(){if(this.#j)return;this.#j=new AbortController;let e=this.combinedSignal(this.#j);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#ae(){this.#j?.abort(),this.#j=null}#oe(){if(this.#d)return;this.#d=new AbortController;let e=this.combinedSignal(this.#d);document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}#se(){this.#d?.abort(),this.#d=null}#ce(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#ie(),this.setEditingState(!0)}removeEditListeners(){this.#ae(),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#g)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#g)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#L){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#g)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){T(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#pe(t);this.#ge(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){T(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#I!==u.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#ee(`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;case`commentSelection`:this.commentSelection(`context_menu`)}}updatePageIndex(e,t){for(let n of this.getEditors(e))n.pageIndex=t;let n=this.#a.get(e);n&&(n.pageIndex=t,this.#i.set(t,n),this.#O?n.enable():n.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear()}endUpdatePages(){this.#a=null}clonePage(e,t){for(let n of this.getEditors(e)){let e=n.serialize(n.mode!==u.HIGHLIGHT);e&&(e.pageIndex=t,e.id=this.getId(),e.isClone=!0,delete e.popupRef,this.#s.setValue(e.id,e))}}findClonesForPage(e){let t=[],{pageIndex:n}=e;for(let[r,i]of this.#s)i.pageIndex===n&&i.isClone&&(this.#s.remove(r),t.push(e.deserialize(i).then(t=>{t&&(t.isClone=!0,e.addOrRebuild(t))})));return Promise.all(t)}#le(e){Object.entries(e).some(([e,t])=>this.#U[e]!==t)&&(this._eventBus.dispatch(`editingstateschanged`,{source:this,details:Object.assign(this.#U,e)}),this.#I===u.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#ue([[d.HIGHLIGHT_FREE,!0]]))}#ue(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#ne(),this.#oe(),this.#le({isEditing:this.#I!==u.NONE,isEmpty:this.#he(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#re(),this.#se(),this.#le({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#g){this.#g=e;for(let e of this.#g)this.#ue(e.defaultPropertiesToUpdate)}}getId(){return this.#D.id}get currentLayer(){return this.#i.get(this.#p)}getLayer(e){return this.#i.get(e)}get currentPageIndex(){return this.#p}addLayer(e){this.#i.set(e.pageIndex,e),this.#O?e.enable():e.disable()}removeLayer(e){this.#i.delete(e.pageIndex)}async updateMode(e,t=null,n=!1,r=!1,i=!1,a=!1){if(this.#I!==e&&!(this.#Y&&(await this.#Y.promise,!this.#Y))){if(this.#Y=Promise.withResolvers(),this.#f?.commitOrRemove(),this.#I===u.POPUP&&this.#u?.hideSidebar(),this.#u?.destroyPopup(),this.#I=e,e===u.NONE){this.setEditingState(!1),this.#fe();for(let e of this.#r.values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#Y.resolve();return}for(let e of this.#r.values())e.addStandaloneCommentButton();e===u.SIGNATURE&&await this.#z?.loadSignatures(),n&&H.clearPointerType(),this.setEditingState(!0),await this.#de(),this.unselectAll();for(let t of this.#i.values())t.updateMode(e);if(e===u.POPUP){this.#n||=await this.#H.getAnnotationsByType(new Set(this.#g.map(e=>e._editorType)));let e=new Set,t=[];for(let n of this.#r.values()){let{annotationElementId:r,hasComment:i,deleted:a}=n;r&&e.add(r),i&&!a&&t.push(n.getData())}for(let n of this.#n){let{id:r,popupRef:i,contentsObj:a}=n;i&&a?.str&&!e.has(r)&&!this.#m.has(r)&&t.push(n)}this.#u?.showSidebar(t)}if(!t){r&&this.addNewEditorFromKeyboard(),this.#Y.resolve();return}for(let e of this.#r.values())e.uid===t?(this.setSelected(e),a?e.editComment():i?e.enterInEditMode():e.focus()):e.unselect();this.#Y.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#I&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,...e})}updateParams(e,t){if(this.#g){switch(e){case d.CREATE:this.currentLayer.addNewEditor(t);return;case d.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#V||=new Map).set(e,t),this.showAllEditors(`highlight`,t)}if(this.hasSelection)for(let n of this.#L)n.updateParams(e,t);else for(let n of this.#g)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#r.values())n.editorType===e&&n.show(t);(this.#V?.get(d.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#ue([[d.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#A!==e){this.#A=e;for(let t of this.#i.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#de(){if(!this.#O){this.#O=!0;let e=[];for(let t of this.#i.values())e.push(t.enable());await Promise.all(e);for(let e of this.#r.values())e.enable()}}#fe(){if(this.unselectAll(),this.#O){this.#O=!1;for(let e of this.#i.values())e.disable();for(let e of this.#r.values())e.disable()}}*getEditors(e){for(let t of this.#r.values())t.pageIndex===e&&(yield t)}getEditor(e){return this.#r.get(e)}addEditor(e){this.#r.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#S&&clearTimeout(this.#S),this.#S=setTimeout(()=>{this.focusMainContainer(),this.#S=null},0)),this.#r.delete(e.id),e.annotationElementId&&this.#P?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#m.has(e.annotationElementId))&&this.#s?.remove(e.id)}addDeletedAnnotationElement(e){this.#m.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#m.has(e)}removeDeletedAnnotationElement(e){this.#m.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#pe(e){let t=this.#i.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#ue(e.propertiesToUpdate))}get#me(){let e=null;for(e of this.#L);return e}updateUI(e){this.#me===e&&this.#ue(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#ue(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#L.has(e)){this.#L.delete(e),e.unselect(),this.#le({hasSelectedEditor:this.hasSelection});return}this.#L.add(e),e.select(),this.#ue(e.propertiesToUpdate),this.#le({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#f?.commitOrRemove();for(let t of this.#L)t!==e&&t.unselect();this.#u?.destroyPopup(),this.#L.clear(),this.#L.add(e),e.select(),this.#ue(e.propertiesToUpdate),this.#le({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#L.values().next().value}unselect(e){e.unselect(),this.#L.delete(e),this.#le({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#L.size!==0}get isEnterHandled(){return this.#L.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#le({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#he()}),this._editorUndoBar?.hide()}redo(){this.#l.redo(),this.#le({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#he()})}addCommands(e){this.#l.add(e),this.#le({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#he()})}cleanUndoStack(e){this.#l.cleanType(e)}#he(){if(this.#r.size===0)return!0;if(this.#r.size===1)for(let e of this.#r.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#L],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#pe(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ge(e){for(let e of this.#L)e.unselect();this.#L.clear();for(let t of e)t.isEmpty()||(this.#L.add(t),t.select());this.#le({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#L)e.commit();this.#ge(this.#r.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#I!==u.NONE))&&!this.#f?.commitOrRemove()&&(this.#u?.destroyPopup(),this.hasSelection)){for(let e of this.#L)e.unselect();this.#L.clear(),this.#le({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#W[0]+=e,this.#W[1]+=t;let[r,i]=this.#W,a=[...this.#L];this.#G&&clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#G=null,this.#W[0]=this.#W[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(r,i),e.translationDone())},undo:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(-r,-i),e.translationDone())},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t),n.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#h=new Map;for(let e of this.#L)this.#h.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#h)return!1;this.disableUserSelect(!1);let e=this.#h;this.#h=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#r.has(e.id)){let i=this.#i.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#h)for(let n of this.#h.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#L.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#I}isEditingMode(){return this.#I!==u.NONE}get imageManager(){return M(this,`imageManager`,new et)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a})}let s=[];for(let e=0,n=t.rangeCount;ee.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e){this.#s?.remove(),this.#s=null;return}if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),(this.#e!==e||this.#t!==t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getElementForAltText()?.setAttribute(`aria-describedby`,n.id)}},ot=class{#e=null;#t=null;#n=!1;#r=null;#i=null;#a=null;#o=null;#s=null;#c=!1;#l=null;constructor(e){this.#r=e}renderForToolbar(){let e=this.#t=document.createElement(`button`);return e.className=`comment`,this.#u(e,!1)}renderForStandalone(){let e=this.#e=document.createElement(`button`);e.className=`annotationCommentButton`;let t=this.#r.commentButtonPosition;if(t){let{style:n}=e;n.insetInlineEnd=`calc(${100*(this.#r._uiManager.direction===`ltr`?1-t[0]:t[0])}% - var(--comment-button-dim))`,n.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let r=this.#r.commentButtonColor;r&&(n.backgroundColor=r)}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;let e=this.#r.commentButtonColor;e&&(this.#e.style.backgroundColor=e),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#e)return null;let{x:e,y:t,height:n}=this.#e.getBoundingClientRect(),{x:r,y:i,width:a,height:o}=this.#r.parent.boundingClientRect;return[(e-r)/a,(t+n-i)/o]}set commentPopupPositionInLayer(e){this.#l=e}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:t}){this.#e&&(this.#e.classList.toggle(`selected`,e),this.#e.ariaExpanded=t)}#u(e,t){if(!this.#r._uiManager.hasCommentManager())return null;e.tabIndex=`0`,e.ariaHasPopup=`dialog`,t?(e.ariaControls=`commentPopup`,e.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`)):(e.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],e.setAttribute(`data-l10n-id`,`pdfjs-editor-add-comment-button`));let n=this.#r._uiManager._signal;if(!(n instanceof AbortSignal)||n.aborted)return e;e.addEventListener(`contextmenu`,R,{signal:n}),t&&(e.addEventListener(`focusin`,e=>{this.#r._focusEventsAllowed=!1,z(e)},{capture:!0,signal:n}),e.addEventListener(`focusout`,e=>{this.#r._focusEventsAllowed=!0,z(e)},{capture:!0,signal:n})),e.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:n});let r=t=>{t.preventDefault(),e===this.#t?this.edit():this.#r.toggleComment(!0)};return e.addEventListener(`click`,r,{capture:!0,signal:n}),e.addEventListener(`keydown`,t=>{t.target===e&&t.key===`Enter`&&(this.#n=!0,r(t))},{signal:n}),e.addEventListener(`pointerenter`,()=>{this.#r.toggleComment(!1,!0)},{signal:n}),e.addEventListener(`pointerleave`,()=>{this.#r.toggleComment(!1,!1)},{signal:n}),e}edit(e){let t=this.commentPopupPositionInLayer,n,r;if(t)[n,r]=t;else{[n,r]=this.#r.commentButtonPosition;let{width:e,height:t,x:i,y:a}=this.#r;n=i+n*e,r=a+r*t}let i=this.#r.parent.boundingClientRect,{x:a,y:o,width:s,height:c}=i;this.#r._uiManager.editComment(this.#r,a+n*s,o+r*c,{...e,parentDimensions:i})}finish(){this.#t&&(this.#t.focus({focusVisible:this.#n}),this.#n=!1)}isDeleted(){return this.#c||this.#o===``}isEmpty(){return this.#o===null}hasBeenEdited(){return this.isDeleted()||this.#o!==this.#i}serialize(){return this.data}get data(){return{text:this.#o,richText:this.#a,date:this.#s,deleted:this.isDeleted()}}set data(e){if(e!==this.#o&&(this.#a=null),e===null){this.#o=``,this.#c=!0;return}this.#o=e,this.#s=new Date,this.#c=!1}restoreData({text:e,richText:t,date:n}){this.#o=e,this.#a=t,this.#s=n,this.#c=!1}setInitialText(e,t=null){this.#i=e,this.data=e,this.#s=null,this.#a=t}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#o=``,this.#a=null,this.#s=null,this.#r=null,this.#n=!1,this.#c=!1}},st=class e{#e;#t=!1;#n=null;#r;#i;#a;#o;#s=null;#c;#l=null;#u;#d=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#u=new AbortController,this.#c=AbortSignal.any([o,this.#u.signal]),e.addEventListener(`touchstart`,this.#f.bind(this),{passive:!1,signal:this.#c})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ie.pixelRatio}#f(e){if(this.#r?.())return;if(e.touches.length===1){if(this.#s)return;let e=this.#s=new AbortController,t=AbortSignal.any([this.#c,e.signal]),n=this.#e,r={capture:!0,signal:t,passive:!1},i=e=>{e.pointerType===`touch`&&(this.#s?.abort(),this.#s=null)};n.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(z(e),i(e))},r),n.addEventListener(`pointerup`,i,r),n.addEventListener(`pointercancel`,i,r);return}if(!this.#d){this.#d=new AbortController;let e=AbortSignal.any([this.#c,this.#d.signal]),t=this.#e,n={signal:e,capture:!1,passive:!1};t.addEventListener(`touchmove`,this.#p.bind(this),n);let r=this.#m.bind(this);t.addEventListener(`touchend`,r,n),t.addEventListener(`touchcancel`,r,n),n.capture=!0,t.addEventListener(`pointerdown`,z,n),t.addEventListener(`pointermove`,z,n),t.addEventListener(`pointercancel`,z,n),t.addEventListener(`pointerup`,z,n),this.#i?.()}if(z(e),e.touches.length!==2||this.#n?.()){this.#l=null;return}let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#l={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#p(t){if(!this.#l||t.touches.length!==2)return;z(t);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=this.#l,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!this.#t&&Math.abs(v-_)<=e.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,!this.#t){this.#t=!0;return}let y=[(i+o)/2,(a+s)/2];this.#a?.(y,v,_)}#m(e){e.touches.length>=2||(this.#d&&(this.#d.abort(),this.#d=null,this.#o?.()),this.#l&&(z(e),this.#l=null,this.#t=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#s?.abort(),this.#s=null}},U=class e{#e=null;#t=null;#n=null;#r=null;#i=null;#a=!1;#o=null;#s=``;#c=null;#l=null;#u=null;#d=null;#f=null;#p=``;#m=!1;#h=null;#g=!1;#_=!1;#v=!1;#y=null;#b=0;#x=0;#S=null;#C=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#w=!1;#T=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new rt;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=it.TRANSLATE_SMALL,r=it.TRANSLATE_BIG;return M(this,`_resizerKeyboardManager`,new nt([[[`ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return M(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new ct({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._l10nAlert??=Object.freeze({highlight:`pdfjs-editor-highlight-added-alert`,freetext:`pdfjs-editor-freetext-added-alert`,ink:`pdfjs-editor-ink-added-alert`,stamp:`pdfjs-editor-stamp-added-alert`,signature:`pdfjs-editor-signature-added-alert`}),e._l10nResizer??=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){E(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#w}set _isDraggable(e){this.#w=e,this.div?.classList.toggle(`draggable`,e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#T}setParent(e){e===null?(this.#W(),this.#d?.remove(),this.#d=null):(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r),this._onTranslated()}#E([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#E(this.parentDimensions,e,t)}translateInPage(e,t){this.#h||=[this.x,this.y,this.width,this.height],this.#E(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){this.#h||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=L(i,0,n-o),a=L(a,0,r-s);break;case 90:i=L(i,0,n-s),a=L(a,o,r);break;case 180:i=L(i,o,n),a=L(a,s,r);break;case 270:i=L(i,s,n),a=L(a,0,r-o)}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#D(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#D(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#D(t,n,360-this.parentRotation)}#O(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(){let{div:{style:e},width:t,height:n}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*n).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#k(){if(this.#c)return;this.#c=document.createElement(`div`),this.#c.classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);this.#c.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#A.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,R,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#c)}#A(e,t){t.preventDefault();let{isMac:n}=F.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#l=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#N.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,z,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,R,{signal:a}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#M()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#j(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#M(){if(!this.#u)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#u;this.#u=null;let i=this.x,a=this.y,o=this.width,s=this.height;(i!==e||a!==t||o!==n||s!==r)&&this.addCommands({cmd:this.#j.bind(this,i,a,o,s),undo:this.#j.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#N(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#O(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#O(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2]}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#l;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#l[0]=e,this.#l[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=L(Math.abs(b[0]-y[0]-E),l,1)/s:T=L(Math.abs(b[1]-y[1]-D),u,1)/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#_)return this._editToolbar;this._editToolbar=new Ye(this),this.div.append(this._editToolbar.render());let{toolbarButtons:e}=this;if(e)for(let[t,n]of e)await this._editToolbar.addButton(t,n);return this.hasComment||this._editToolbar.addButton(`comment`,this.addCommentButton()),this._editToolbar.addButton(`delete`),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore(`comment`,this.addCommentButton(),`.deleteButton`)}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton(`comment`)}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#n?.destroy()}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(at.initialize(e._l10n),this.#n=new at(this),this.#e&&=(this.#n.data=this.#e,null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}focusCommentButton(){this.#r?.focusButton()}addCommentButton(){return this.canAddComment?this.#r||=new ot(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove(`hidden`);return}this.hasComment&&(this.#i=this.#r.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#r.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add(`hidden`)}get comment(){if(!this.#r)return null;let{data:{richText:e,text:t,date:n,deleted:r}}=this.#r;return{text:t,richText:e,date:n,deleted:r,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){this.#r||=new ot(this),typeof e==`object`&&e?this.#r.restoreData(e):this.#r.data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:n}){if(!t||(this.#r||=new ot(this),this.#r.setInitialText(e,n),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){return this.#r?.hasBeenEdited()}get hasDeletedComment(){return this.#r?.isDeleted()}get hasComment(){return!!this.#r&&!this.#r.isEmpty()&&!this.#r.isDeleted()}async editComment(e){this.#r||=new ot(this),this.#r.edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){this.#r.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,t]=e.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,i=r+n+1,a=t-100,o=i+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[i,a,o,t]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){this.#r.data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let e=this.div=document.createElement(`div`);e.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),e.className=this.name,e.setAttribute(`id`,this.id),e.tabIndex=this.#a?-1:0,e.setAttribute(`role`,`application`),this.defaultL10nId&&e.setAttribute(`data-l10n-id`,this.defaultL10nId),this._isVisible||e.classList.add(`hidden`),this.setInForeground(),this.#z();let[t,n]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*n/t).toFixed(2)}%`,e.style.maxHeight=`${(100*t/n).toFixed(2)}%`);let[r,i]=this.getInitialTranslation();return this.translate(r,i),Qe(this,e,[`keydown`,`pointerdown`,`dblclick`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#C||=new st({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#P.bind(this),onPinching:this.#F.bind(this),onPinchEnd:this.#I.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#P(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#F(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#O(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#h||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#I(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#M()}pointerdown(e){let{isMac:t}=F.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#R(e);return}this.#L(e)}#L(e){let{isMac:t}=F.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#R(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#o=null,this.#m=!1,this._uiManager.endDragSession()||this.#L(e),n&&this._onStopDragging()};t&&(this.#b=e.clientX,this.#x=e.clientY,this.#o=e.pointerId,this.#s=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#o){z(e);return}let[a,o]=this.screenToPageTranslation(t-this.#b,r-this.#x);this.#b=t,this.#x=r,this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,z,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#s&&(this.#C||e.isPrimary)&&o(e),z(e)},a));let s=e=>{if(!this.#o||this.#o===e.pointerId){o(e);return}z(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&e._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#r?.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:n,opacity:r,deleted:i,richText:a},uid:o,pageIndex:s,creationDate:c,modificationDate:l}=this;return{id:o,pageIndex:s,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:c,modificationDate:n||l,popupRef:!i,color:t,opacity:r}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#_=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#_=!1,!0):!1}isInEditMode(){return this.#_}shouldGetKeyboardEvents(){return this.#v}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t0&&e0}#z(){if(this.#f||!this.div)return;this.#f=new AbortController;let e=this._uiManager.combinedSignal(this.#f);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}rebuild(){this.#z()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||``}}serialize(e=!1,t=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||``}}static async deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:n.getId(),uiManager:n,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});r.rotation=e.rotation,r.#e=e.accessibilityData,r._isCopy=e.isCopy||!1;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#y&&=(clearTimeout(this.#y),null),this.#W(),this.removeEditToolbar(),this.#S){for(let e of this.#S.values())clearTimeout(e);this.#S=null}this.parent=null,this.#C?.destroy(),this.#C=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#k(),this.#c.classList.remove(`hidden`))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction===`ltr`?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,n]}=this,[r,i,a,o]=this.getPDFRect();return[e._round(r+(a-r)*t),e._round(i+(o-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#r.commentPopupPositionInLayer}set commentPopupPosition(e){this.#r.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#r.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#r.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#r?.setCommentButtonStates(e)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#c.children;if(!this.#t){this.#t=Array.from(n);let t=this.#B.bind(this),r=this.#V.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#H.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(ai)for(let e=0;e{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#c?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!==`BUTTON`&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(e){this.#g=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#S||=new Map;let{action:n}=t,r=this.#S.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},e._telemetryTimeout),this.#S.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(e){if(!this.#d&&!this.deleted){this.#d=e.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},ct=class extends U{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},lt=3285377520,W=4294901760,ut=65535,dt=class{constructor(e){this.h1=e?e&4294967295:lt,this.h2=e?e&4294967295:lt}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e>>17,o=o*d&W|o*p&ut,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&W|s*f&ut,s=s<<15|s>>>17,s=s*d&W|s*p&ut,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&W|o*f&ut,o=o<<15|o>>>17,o=o*d&W|o*p&ut,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&W|e*36045&ut,t=t*4283543511&W|((t<<16|e>>>16)*2950163797&W)>>>16,e^=t>>>1,e=e*444984403&W|e*60499&ut,t=t*3301882366&W|((t<<16|e>>>16)*3120437893&W)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},ft=Object.freeze({map:null,hash:``,transfer:void 0}),pt=class{#e=!1;#t=null;#n=null;#r=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,t){let n=this.#r.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#r.get(e)}remove(e){let t=this.#r.get(e);t!==void 0&&(t instanceof U&&this.#n.delete(t.annotationElementId),this.#r.delete(e),this.#r.size===0&&this.resetModified(),!this.#r.values().some(e=>e instanceof U)&&this.onAnnotationEditor?.(null))}setValue(e,t){let n=this.#r.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#r.set(e,t);r&&this.#i(),t instanceof U&&((this.#n||=new Map).set(t.annotationElementId,t),this.onAnnotationEditor?.(t.constructor._type))}has(e){return this.#r.has(e)}get size(){return this.#r.size}#i(){this.#e||(this.#e=!0,this.onSetModified?.())}resetModified(){this.#e&&(this.#e=!1,this.onResetModified?.())}get print(){return new mt(this)}get serializable(){if(this.#r.size===0)return ft;let e=new Map,t=new dt,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#r){let o=a instanceof U?a.serialize(!1,r):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:ft}get editorStats(){let e=null,t=new Map,n=0,r=0;for(let i of this.#r.values()){if(!(i instanceof U)){i.popup&&(i.popup.deleted?r+=1:n+=1);continue}i.isCommentDeleted?r+=1:i.hasEditedComment&&(n+=1);let a=i.telemetryFinalData;if(!a)continue;let{type:o}=a;t.getOrInsertComputed(o,()=>Object.getPrototypeOf(i).constructor),e||=Object.create(null);let s=e[o]||=new Map;for(let[e,t]of Object.entries(a)){if(e===`type`)continue;let n=s.getOrInsertComputed(e,me);n.set(t,(n.get(t)??0)+1)}}if((r>0||n>0)&&(e||=Object.create(null),e.comments={deleted:r,edited:n}),!e)return null;for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,t){let n=this.#n?.get(e);return n?(n.updateFromAnnotationLayer(t),!0):!1}getEditor(e){return this.#n?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;let e=[];if(this.#n)for(let t of this.#n.values())t.serialize()&&e.push(t.annotationElementId);let t=``;if(e.length){let n=new dt;n.update(e.join(`,`)),t=n.hexdigest()}return this.#t={ids:new Set(e),hash:t}}[Symbol.iterator](){return this.#r.entries()}},mt=class extends pt{#e=ft;constructor(e){super();let{serializable:t}=e;if(t===ft)return;let{map:n,hash:r,transfer:i}=t,a=structuredClone(n,i?{transfer:i}:null);this.#e={map:a,hash:r,transfer:[]}}get print(){E(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return M(this,`modifiedIds`,{ids:new Set,hash:``})}},ht=`__forcedDependency`,{floor:gt,ceil:_t}=Math;function vt(e,t,n,r,i,a){e[t*4+0]=Math.min(e[t*4+0],n),e[t*4+1]=Math.min(e[t*4+1],r),e[t*4+2]=Math.max(e[t*4+2],i),e[t*4+3]=Math.max(e[t*4+3],a)}function yt(e,t,n,r,i){let a;e?(e<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=e,i[2]*=e,t<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=n,i[1]+=r,i[2]+=n,i[3]+=r}var bt=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],xt=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===bt}minX(e){return this.#t[e*4+0]/256}minY(e){return this.#t[e*4+1]/256}maxX(e){return(this.#t[e*4+2]+1)/256}maxY(e){return(this.#t[e*4+3]+1)/256}},St=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),Ct=class{#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#n=new Float64Array(n);_pendingBBoxIdx=-1;#r;#i;#a;#o;_savesStack=[];_markedContentStack=[];constructor(e,t){this.#r=e.width,this.#i=e.height,this.#s(t)}growOperationsCount(e){e>=this.#o.length&&this.#s(e,this.#o)}#s(e,t){let n=new ArrayBuffer(e*4);this.#a=new Uint8ClampedArray(n),this.#o=new Uint32Array(n),t&&t.length>0?(this.#o.set(t),this.#o.fill(bt,t.length)):this.#o.fill(bt)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,t){let n=Object.getPrototypeOf(this.#t);if(n===null)return this;this.#t=n;let r=this._savesStack.pop();return r!==void 0&&(t?.(r,e),this.#o[e]=this.#o[r]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){let n=this._savesStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let n=this._markedContentStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}pushBaseTransform(e){return this.#e.push(I.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){return this.#e.length>1&&this.#e.pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,this.#n.set(n,0)),this}recordClipBox(e,t,r,i,a,o){let s=I.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform()),c=n.slice();I.axialAlignedBoundingBox([r,a,i,o],s,c);let l=I.intersect(this.#t,c);return l?(this.#t[0]=l[0],this.#t[1]=l[1],this.#t[2]=l[2],this.#t[3]=l[3]):(this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0),this}recordBBox(e,t,r,i,a,o){let s=this.#t;if(s[0]===1/0)return this;let c=I.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform());if(s[0]===-1/0)return I.axialAlignedBoundingBox([r,a,i,o],c,this.#n),this;let l=n.slice();return I.axialAlignedBoundingBox([r,a,i,o],c,l),this.#n[0]=L(l[0],s[0],this.#n[0]),this.#n[1]=L(l[1],s[1],this.#n[1]),this.#n[2]=L(l[2],this.#n[2],s[2]),this.#n[3]=L(l[3],this.#n[3],s[3]),this}recordFullPageBBox(e){return this.#n[0]=Math.max(0,this.#t[0]),this.#n[1]=Math.max(0,this.#t[1]),this.#n[2]=Math.min(this.#r,this.#t[2]),this.#n[3]=Math.min(this.#i,this.#t[3]),this}recordOperation(e,t=!1,n){if(this._pendingBBoxIdx!==e)return this;let r=gt(this.#n[0]*256/this.#r),i=gt(this.#n[1]*256/this.#i),a=_t(this.#n[2]*256/this.#r),o=_t(this.#n[3]*256/this.#i);if(vt(this.#a,e,r,i,a,o),n)for(let t of n)for(let n of t)n!==e&&vt(this.#a,n,r,i,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#n[0]),this.#t[1]=Math.max(this.#t[1],this.#n[1]),this.#t[2]=Math.min(this.#t[2],this.#n[2]),this.#t[3]=Math.min(this.#t[3],this.#n[3])),this}take(){return new xt(this.#o,this.#a)}takeDebugMetadata(){throw Error(`Unreachable`)}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}},wt=class{#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[ht]:[]};#n=new Map;#r=new Set;#i=new Map;#a;#o;#s;constructor(e,t=!1){this.#s=e,t&&(this.#a=new Map,this.#o=(e,t)=>{St(this.#a,t).dependencies.add(e)})}get clipBox(){return this.#s.clipBox}growOperationsCount(e){this.#s.growOperationsCount(e)}save(e){return this.#e={__proto__:this.#e},this.#t={__proto__:this.#t,transform:{__proto__:this.#t.transform},moveText:{__proto__:this.#t.moveText},sameLineText:{__proto__:this.#t.sameLineText},[ht]:{__proto__:this.#t[ht]}},this.#s.save(e),this}restore(e){this.#s.restore(e,this.#o);let t=Object.getPrototypeOf(this.#e);return t===null?this:(this.#e=t,this.#t=Object.getPrototypeOf(this.#t),this)}recordOpenMarker(e){return this.#s.recordOpenMarker(e,this.#o),this}getOpenMarker(){return this.#s.getOpenMarker()}recordCloseMarker(e){return this.#s.recordCloseMarker(e,this.#o),this}beginMarkedContent(e){return this.#s.beginMarkedContent(e),this}endMarkedContent(e){return this.#s.endMarkedContent(e,this.#o),this}pushBaseTransform(e){return this.#s.pushBaseTransform(e),this}popBaseTransform(){return this.#s.popBaseTransform(),this}recordSimpleData(e,t){return this.#e[e]=t,this}recordIncrementalData(e,t){return this.#t[e].push(t),this}resetIncrementalData(e,t){return this.#t[e].length=0,this}recordNamedData(e,t){return this.#n.set(e,t),this}recordSimpleDataFromNamed(e,t,n){this.#e[e]=this.#n.get(t)??n}recordFutureForcedDependency(e,t){return this.recordIncrementalData(ht,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)t in this.#e&&this.recordFutureForcedDependency(t,this.#e[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of this.#r)this.recordFutureForcedDependency(ht,e);return this}resetBBox(e){return this.#s.resetBBox(e),this}recordClipBox(e,t,n,r,i,a){return this.#s.recordClipBox(e,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#s.recordBBox(e,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){let s=n.bbox,c,l;if(s&&(c=s[2]!==s[0]&&s[3]!==s[1]&&this.#i.get(n),c!==!1&&(l=[0,0,0,0],I.axialAlignedBoundingBox(s,n.fontMatrix,l),(r!==1||i!==0||a!==0)&&yt(r,-r,i,a,l),c)))return this.recordBBox(e,t,l[0],l[2],l[1],l[3]);if(!o)return this.recordFullPageBBox(e);let u=o();return s&&l&&c===void 0&&(c=l[0]<=i-u.actualBoundingBoxLeft&&l[2]>=i+u.actualBoundingBoxRight&&l[1]<=a-u.actualBoundingBoxAscent&&l[3]>=a+u.actualBoundingBoxDescent,this.#i.set(n,c),c)?this.recordBBox(e,t,l[0],l[2],l[1],l[3]):this.recordBBox(e,t,i-u.actualBoundingBoxLeft,i+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#s.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,t){let n=this.#r,r=this.#e,i=this.#t;for(let e of t)e in this.#e?n.add(r[e]):e in i&&i[e].forEach(n.add,n);return this}recordNamedDependency(e,t){return this.#n.has(t)&&this.#r.add(this.#n.get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[ht]),this.#a){let t=St(this.#a,e),{dependencies:n}=t;this.#r.forEach(n.add,n),this.#s._savesStack.forEach(n.add,n),this.#s._markedContentStack.forEach(n.add,n),n.delete(e),t.isRenderingOperation=!0}let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.recordOperation(e,t,[this.#r,this.#s._savesStack,this.#s._markedContentStack]),n&&this.#r.clear(),this}recordShowTextOperation(e,t=!1){let n=Array.from(this.#r);this.recordOperation(e,t),this.recordIncrementalData(`sameLineText`,e);for(let e of n)this.recordIncrementalData(`sameLineText`,e);return this}bboxToClipBoxDropOperation(e,t=!1){let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.bboxToClipBoxDropOperation(e),n&&this.#r.clear(),this}take(){return this.#i.clear(),this.#s.take()}takeDebugMetadata(){return this.#a}},Tt=class e{#e;#t;#n;#r=0;#i=0;constructor(t,n,r){if(t instanceof e&&t.#n===!!r)return t;this.#e=t,this.#t=n,this.#n=!!r}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw Error(`Unreachable`)}save(e){return this.#i++,this.#e.save(this.#t),this}restore(e){return this.#i>0&&(this.#e.restore(this.#t),this.#i--),this}recordOpenMarker(e){return this.#r++,this}getOpenMarker(){return this.#r>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#r--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return this.#e.pushBaseTransform(e),this}popBaseTransform(){return this.#e.popBaseTransform(),this}recordSimpleData(e,t){return this.#e.recordSimpleData(e,this.#t),this}recordIncrementalData(e,t){return this.#e.recordIncrementalData(e,this.#t),this}resetIncrementalData(e,t){return this.#e.resetIncrementalData(e,this.#t),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this.#e.recordSimpleDataFromNamed(e,t,this.#t),this}recordFutureForcedDependency(e,t){return this.#e.recordFutureForcedDependency(e,this.#t),this}inheritSimpleDataAsFutureForcedDependencies(e){return this.#e.inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#e.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return this.#n||this.#e.resetBBox(this.#t),this}recordClipBox(e,t,n,r,i,a){return this.#n||this.#e.recordClipBox(this.#t,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#n||this.#e.recordBBox(this.#t,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r,i,a,o){return this.#n||this.#e.recordCharacterBBox(this.#t,t,n,r,i,a,o),this}recordFullPageBBox(e){return this.#n||this.#e.recordFullPageBBox(this.#t),this}getSimpleIndex(e){return this.#e.getSimpleIndex(e)}recordDependencies(e,t){return this.#e.recordDependencies(this.#t,t),this}recordNamedDependency(e,t){return this.#e.recordNamedDependency(this.#t,t),this}recordOperation(e){return this.#e.recordOperation(this.#t,!0),this}recordShowTextOperation(e){return this.#e.recordShowTextOperation(this.#t,!0),this}bboxToClipBoxDropOperation(e){return this.#n||this.#e.bboxToClipBoxDropOperation(this.#t,!0),this}take(){throw Error(`Unreachable`)}takeDebugMetadata(){throw Error(`Unreachable`)}},G={stroke:[`path`,`transform`,`filter`,`strokeColor`,`strokeAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`dash`],fill:[`path`,`transform`,`filter`,`fillColor`,`fillAlpha`,`globalCompositeOperation`,`SMask`],imageXObject:[`transform`,`SMask`,`filter`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`],rawFillPath:[`filter`,`fillColor`,`fillAlpha`],showText:[`transform`,`leading`,`charSpacing`,`wordSpacing`,`hScale`,`textRise`,`moveText`,`textMatrix`,`font`,`fontObj`,`filter`,`fillColor`,`textRenderingMode`,`SMask`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`,`sameLineText`],transform:[`transform`],transformAndFill:[`transform`,`fillColor`]},Et=class e{#e;#t;#n=4;#r=0;#i=new e.#a(this.#n*6);static#a=F.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(t,r,i,a){if(this.#r===this.#n){this.#n*=2;let t=new e.#a(this.#n*6);t.set(this.#i),this.#i=t}let o=B(t),s;if(a[0]!==1/0){let e=n.slice();I.axialAlignedBoundingBox([0,-i,r,0],o,e);let t=I.intersect(a,e);if(!t)return;let[c,l,u,d]=t;if(c!==e[0]||l!==e[1]||u!==e[2]||d!==e[3]){let e=Math.atan2(o[1],o[0]),t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e));if(t<1e-6||n<1e-6||Math.abs(t-n)<1e-6)s=[c,l,c,d,u,l];else{let e=u-c,r=d-l,i=t*t,a=n*n,o=n*t,f=a-i,p=(r*a-e*o)/f;s=[c+(r*o-e*i)/f,l,c,l+p,u,d-p]}}}s||(s=[0,-i,0,0,r,-i],I.applyTransform(s,o,0),I.applyTransform(s,o,2),I.applyTransform(s,o,4)),s[0]/=this.#e,s[1]/=this.#t,s[2]/=this.#e,s[3]/=this.#t,s[4]/=this.#e,s[5]/=this.#t,this.#i.set(s,this.#r*6),this.#r++}take(){return this.#i.subarray(0,this.#r*6)}},Dt=class{#e=new Set;#t=null;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){let t=this.#n();t.insertRule(e,t.cssRules.length)}#n(){if(this.#t)return this.#t;let e=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&e){let{adoptedStyleSheets:t}=this._document;if(t){let n=new e;return t.push(n),this.#t=n}}return this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement)),this.#t=this.styleElement.sheet}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),this.#e.clear(),this.#t){let{adoptedStyleSheets:e}=this._document;e?.includes(this.#t)&&(this._document.adoptedStyleSheets=e.filter(e=>e!==this.#t)),this.#t=null}this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:n}){if(!(!e||this.#e.has(e.loadedName))){if(D(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:t,src:r,style:i}=e,a=new FontFace(t,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(t),n?.(e)}catch{T(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}E(`Not implemented: loadSystemFont without the Font Loading API.`)}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw T(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return M(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){return M(this,`isSyncFontLoadingSupported`,t||F.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(D(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return M(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function i(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let a,o,s=this._document.createElement(`canvas`);s.width=1,s.height=1;let c=s.getContext(`2d`),l=0;function u(e,t){if(++l>30){T(`Load test font never loaded.`),t();return}if(c.font=`30px `+e,c.fillText(`.`,0,20),c.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(u.bind(null,e,t))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let p=1482184792,m=n(f,16);for(a=0,o=d.length-3;a{g.remove(),t.complete()})}},Ot=class{compiledGlyphs=Object.create(null);#e;constructor(e,t=null,n,r){this.#e=e,this._inspectFont=t,n&&(this.charProcOperatorList=n),r&&Object.assign(this,r)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){T(`getPathGenerator - ignoring character: "${e}".`)}let i=Je(r?.path);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){M(this,`disableFontFace`,!!e)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get ascent(){return this.#e.ascent}get defaultWidth(){return this.#e.defaultWidth}get descent(){return this.#e.descent}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.#e.mimetype}get name(){return this.#e.name}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}get defaultVMetrics(){return this.#e.defaultVMetrics}},kt=class{static strings=[`fontFamily`,`fontWeight`,`italicAngle`]},At=class{static strings=[`css`,`loadedName`,`baseFontName`,`src`]},K=class{static bools=[`black`,`bold`,`disableFontFace`,`fontExtraProperties`,`isInvalidPDFjsFont`,`isType3Font`,`italic`,`missingFile`,`remeasure`,`vertical`];static numbers=[`ascent`,`defaultWidth`,`descent`];static strings=[`fallbackName`,`loadedName`,`mimetype`,`name`];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6},jt=class{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16},Mt=class{#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}#r(e){D(e>n&3;return r===0?void 0:r===2}get black(){return this.#r(0)}get bold(){return this.#r(1)}get disableFontFace(){return this.#r(2)}get fontExtraProperties(){return this.#r(3)}get isInvalidPDFjsFont(){return this.#r(4)}get isType3Font(){return this.#r(5)}get italic(){return this.#r(6)}get missingFile(){return this.#r(7)}get remeasure(){return this.#r(8)}get vertical(){return this.#r(9)}#i(e){return D(e0){t=n.slice();for(let e=0,n=l.length;etypeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,Vt=fe.bind(null,Bt,e=>typeof e==`object`&&typeof e?.name==`string`),Ht=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){T("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},Ut={DATA:1,ERROR:2},q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Wt(){}function J(e){if(e instanceof P||e instanceof ne||e instanceof ee||e instanceof re||e instanceof te)return e;switch(e instanceof Error||typeof e==`object`&&e||E(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new P(e.message);case`InvalidPDFException`:return new ne(e.message);case`PasswordException`:return new ee(e.message,e.code);case`ResponseException`:return new re(e.message,e.status,e.missing);case`UnknownErrorException`:return new te(e.message,e.details)}return new te(e.message,e.toString())}var Gt=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Ut.DATA)n.resolve(e.data);else if(e.callback===Ut.ERROR)n.reject(J(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:Ut.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:Ut.ERROR,callbackId:e.callbackId,reason:J(t)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:q.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{D(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:q.CANCEL,streamId:i,reason:J(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:q.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){D(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.ERROR,streamId:t,reason:J(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,reason:J(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case q.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(J(e.reason));break;case q.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(J(e.reason));break;case q.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Wt).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,reason:J(e)})});break;case q.ENQUEUE:if(D(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case q.CLOSE:if(D(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case q.ERROR:D(a,`error should have stream controller`),a.controller.error(J(e.reason)),this.#i(a,t);break;case q.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(J(e.reason)),this.#i(a,t);break;case q.CANCEL:if(!o)break;let s=J(e.reason);Promise.try(o.onCancel||Wt,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,reason:J(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}},Kt=class{#e=Object.freeze({cMapUrl:`CMap`,standardFontDataUrl:`font`,wasmUrl:`wasm`});constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:n=null}){this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=n}async fetch({kind:e,filename:t}){switch(e){case`cMapUrl`:case`standardFontDataUrl`:case`wasmUrl`:break;default:E(`Not implemented: ${e}`)}let n=this[e];if(!n)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let r=`${n}${t}`;return this._fetch(r,e).catch(t=>{throw Error(`Unable to load ${this.#e[e]} data at: ${r}`)})}async _fetch(e,t){E("Abstract method `_fetch` called.")}},qt=class extends Kt{async _fetch(e,t){let n=await Ce(e,t===`cMapUrl`&&!e.endsWith(`.bcmap`)?`text`:`bytes`);return n instanceof Uint8Array?n:oe(n)}},Jt=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset({canvas:e},t,n){if(!e)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.width=t,e.height=n}destroy(e){let{canvas:t}=e;if(!t)throw Error(`Canvas is not specified`);t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){E("Abstract method `_createCanvas` called.")}},Yt=class extends Jt{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},Xt=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addKnockoutFilter(e=0){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}addSelectionHCMFilter(e,t){return`none`}addSelectionFilter(){return`none`}createSelectionStyle(e=null){return null}destroy(e=!1){}},Zt=class extends Xt{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=new Map}get#c(){return this.#a||=new Map}get#l(){if(!this.#n){let e=this.#i.createElement(`div`),{style:t}=e;t.colorScheme=`only light`,t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=this.#i.createElementNS(a,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(a,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&(Te(e)?T(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=A(e,``))}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=I.makeHexColor(...a);let o=this.#v(t);if(t=I.makeHexColor(...o),this.#b(),e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array(256);for(let e=0;e<=255;e++){let t=e/255;s[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let c=s.join(`,`),l=`g_${this.#r}_hcm_filter`,u=i.filter=this.#m(l);this.#g(c,c,c,u),this.#p(u);let d=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(d(0,5),d(1,5),d(2,5),u),i.url=this.#d(l),i.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter(`selection`,e,t,`HighlightText`,`Highlight`)}addSelectionFilter(){return this.addHighlightHCMFilter(`selection_default`,`black`,`white`,`HighlightText`,`Highlight`)}createSelectionStyle(e=null){let t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return t===`none`||!F.platform.isFirefox?null:{"backdrop-filter":t,"background-color":`transparent`}}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addKnockoutFilter(e=0){let t=e>0?Math.min(1/e,1e6):1e6,n=`knockout_${t}`,r=this.#s.get(n);if(r)return r;let i=`g_${this.#r}_knockout_filter_${this.#o++}`,o=this.#d(i);this.#s.set(n,o);let s=this.#m(i),c=this.#i.createElementNS(a,`feComponentTransfer`);s.append(c);let l=this.#i.createElementNS(a,`feFuncA`);return l.setAttribute(`type`,`linear`),l.setAttribute(`slope`,`${t}`),l.setAttribute(`intercept`,`0`),c.append(l),o}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#x.bind(this));u{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(a,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0`),e.append(t)}#p(e){let t=this.#i.createElementNS(a,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0`),e.append(t)}#m(e){let t=this.#i.createElementNS(a,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(a,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(a,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(a,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,Ne(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#y(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,Me(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#b(){this.#l.style.color=``,this.#l.style.backgroundColor=``}#x(e){let[t,n,r,i]=this.#y(e);if(i===1)return[t,n,r];let[a,o,s]=this.#v(`Canvas`);return[Qt(t,a,i),Qt(n,o,i),Qt(r,s,i)]}};function Qt(e,t,n){return Math.round(n*e+(1-n)*t)}t&&T("Please use the `legacy` build in Node.js environments.");async function $t(e){let t=await process.getBuiltinModule(`fs/promises`).readFile(e);return new Uint8Array(t)}var en=class extends Xt{},tn=class extends Jt{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire(import.meta.url)(`@napi-rs/canvas`).createCanvas(e,t)}},nn=class extends Kt{async _fetch(e,t){return $t(e)}};function rn({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=F.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=c^l,p=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r>7&1)&f,n[m+1]=c^-(r>>6&1)&f,n[m+2]=c^-(r>>5&1)&f,n[m+3]=c^-(r>>4&1)&f,n[m+4]=c^-(r>>3&1)&f,n[m+5]=c^-(r>>2&1)&f,n[m+6]=c^-(r>>1&1)&f,n[m+7]=c^-(r&1)&f}if(d===0)continue;let r=t>7-e&1)&f}return{srcPos:t,destPos:m}}function an({src:e,srcPos:t=0,dest:n,destPos:r=0,width:i,height:a}){let o=0,s=i*a*3,c=s>>2,l=new Uint32Array(e.buffer,t,c),u=F.isLittleEndian?4278190080:255;if(F.isLittleEndian){for(;o>>24|t<<8|u,n[r+2]=t>>>16|i<<16|u,n[r+3]=i>>>8|u}for(let i=o*4,a=t+s;i>>8|u,n[r+2]=t<<16|i>>>16|u,n[r+3]=i<<8|u}for(let i=o*4,a=t+s;i=_.INFOS&&console.info(`Info: ${e}`)}function T(e){x>=_.WARNINGS&&console.warn(`Warning: ${e}`)}function E(e){throw Error(e)}function D(e,t){e||E(t)}function O(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function k(e,t=null,n=null){if(!e)return null;if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=se(e)}catch{}let r=t?URL.parse(e,t):URL.parse(e);return O(r)?r:null}function A(e,t,n=!1){let r=URL.parse(e);return r?(r.hash=t,r.href):n&&k(e,`http://example.com`)?e.split(`#`,1)[0]+`${t?`#${t}`:``}`:``}function j(e){return e.substring(e.lastIndexOf(`/`)+1)}function M(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var N=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),ee=class extends N{constructor(e,t){super(e,`PasswordException`),this.code=t}},te=class extends N{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},ne=class extends N{constructor(e){super(e,`InvalidPDFException`)}},re=class extends N{constructor(e,t,n){super(e,`ResponseException`),this.status=t,this.missing=n}},ie=class extends N{constructor(e){super(e,`FormatError`)}},P=class extends N{constructor(e){super(e,`AbortException`)}};function ae(e){(typeof e!=`object`||e?.length===void 0)&&E(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t`u`)return M(this,`isAlphaColorInputSupported`,!1);let e=document.createElement(`input`);return e.type=`color`,e.setAttribute(`alpha`,``),e.value=`#ff000080`,M(this,`isAlphaColorInputSupported`,e.value!==`#ff0000`)}static get isBackdropFilterSupported(){return M(this,`isBackdropFilterSupported`,typeof CSS<`u`&&CSS.supports(`backdrop-filter`,`blur(1px)`))}},I=class{static get hexNums(){return M(this,`hexNums`,Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)))}static makeHexColor(e,t,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,n=0){let r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4],e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];for(let t=0;t<6;t+=2){let l=e[n+t],u=e[n+t+1];e[n+t]=l*r+u*a+s,e[n+t+1]=l*i+u*o+c}}static applyInverseTransform(e,t){let n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=e[0],u=e[1],d=e[2],f=e[3],p=r*l+s,m=p,h=r*d+s,g=h,_=o*u+c,v=_,y=o*f+c,b=y;if(i!==0||a!==0){let e=i*l,t=i*d,n=a*u,r=a*f;p+=n,g+=n,h+=r,m+=r,_+=e,b+=e,y+=t,v+=t}n[0]=Math.min(n[0],p,h,m,g),n[1]=Math.min(n[1],_,y,v,b),n[2]=Math.max(n[2],p,h,m,g),n[3]=Math.max(n[3],_,y,v,b)}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){let n=e[0],r=e[1],i=e[2],a=e[3],o=n**2+r**2,s=n*i+r*a,c=i**2+a**2,l=(o+c)/2,u=Math.sqrt(l**2-(o*c-s**2));t[0]=Math.sqrt(l+u||1),t[1]=Math.sqrt(l-u||1)}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,r,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],t,r),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],t,r)}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s),this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c)}};function se(e){return decodeURIComponent(escape(e))}var ce=null,le=null;function ue(e){return ce||(ce=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,le=new Map([[`ſt`,`ſt`]])),e.replaceAll(ce,(e,t,n)=>t?t.normalize(`NFKC`):le.get(n))}function de(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),ae(e)}function fe(e,t,n){if(!Array.isArray(n)||n.length<2)return!1;let[r,i,...a]=n;if(!e(r)&&!Number.isInteger(r)||!t(i))return!1;let o=a.length,s=!0;switch(i.name){case`XYZ`:if(o<2||o>3)return!1;break;case`Fit`:case`FitB`:return o===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(o>1)return!1;break;case`FitR`:if(o!==4)return!1;s=!1;break;default:return!1}for(let e of a)if(!(typeof e==`number`||s&&e===null))return!1;return!0}var pe=()=>[],me=()=>new Map,he=()=>Object.create(null),ge=()=>new Set;typeof Iterator.prototype.join!=`function`&&(Iterator.prototype.join=function(e){return[...this].join(e)});function L(e,t,n){return Math.min(Math.max(e,t),n)}var _e=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let e=this.viewBox;return M(this,`rawDims`,{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){let n=[e,t];return I.applyTransform(n,this.transform),n}convertToPdfPoint(e,t){let n=[e,t];return I.applyInverseTransform(n,this.transform),n}},ve=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return e!==`textarea`&&e!==`input`&&e!==`option`&&e!==`select`}},ye=/url\(|image-set\(/i,be=/^on/i,xe=class{static get _allowedHtmlElements(){return M(this,`_allowedHtmlElements`,new Set([`a`,`b`,`br`,`button`,`div`,`i`,`img`,`input`,`label`,`li`,`ol`,`option`,`p`,`select`,`span`,`sub`,`sup`,`textarea`,`ul`]))}static get _allowedSvgElements(){return M(this,`_allowedSvgElements`,new Set([`ellipse`,`line`,`path`,`rect`,`svg`]))}static get _allowedRichTextElements(){return M(this,`_allowedRichTextElements`,new Set([`a`,`b`,`br`,`div`,`i`,`li`,`ol`,`p`,`span`,`sub`,`sup`,`ul`]))}static get _allowedRichTextAttributes(){return M(this,`_allowedRichTextAttributes`,new Set([`class`,`dir`,`style`]))}static get _allowedRichTextStyles(){return M(this,`_allowedRichTextStyles`,new Set(`color.font.fontFamily.fontSize.fontStretch.fontStyle.fontWeight.kerningMode.letterSpacing.lineHeight.margin.marginBottom.marginLeft.marginRight.marginTop.orphans.paddingLeft.paddingRight.breakAfter.breakBefore.breakInside.tabInterval.tabStop.textAlign.textDecoration.textIndent.transform.verticalAlign.widows`.split(`.`)))}static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})})}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null&&!be.test(t)&&!(r===`richText`&&!this._allowedRichTextAttributes.has(t)))switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:if(r===`richText`){let t=this._allowedRichTextStyles;for(let[r,i]of Object.entries(n))t.has(r)&&!ye.test(i)&&(e.style[r]=i)}else Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i?.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static#e(e,t,n){return n===`richText`?!t&&this._allowedRichTextElements.has(e)?document.createElement(e):null:t?t===a&&this._allowedSvgElements.has(e)?document.createElementNS(a,e):null:this._allowedHtmlElements.has(e)?document.createElement(e):null}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=this.#e(r.name,r.attributes?.xmlns,i)??document.createElement(`div`);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&ve.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=this.#e(u,s.attributes?.xmlns,i);if(d){if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&ve.shouldBuildText(u)&&c.push(e),d.append(e)}}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new _e({viewBox:[0,0,parseInt(r,10),parseInt(i,10)],userUnit:1,scale:t,rotation:n})}},Se=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ce(e,t=`text`){if(Ae(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`blob`:return n.blob();case`bytes`:return n.bytes();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t===`bytes`?`arraybuffer`:t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`bytes`:n(new Uint8Array(i.response));return;case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}var we=class extends N{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function Te(e){let t=e.length,n=0;for(;n{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,`https://foo.bar`)}catch{}try{return new URL(decodeURIComponent(e),`https://foo.bar`)}catch{}return null})(e);if(!n)return t;let r=e=>{try{let t=decodeURIComponent(e);return t.includes(`/`)&&(t=j(t),t.length===4&&i.test(t))?e:t}catch{return e}},i=/\.pdf$/i,a=j(n.pathname);if(i.test(a))return r(a);if(n.searchParams.size>0){let e=e=>[...e].findLast(e=>i.test(e)),t=e(n.searchParams.values())??e(n.searchParams.keys());if(t)return r(t)}if(n.hash){let e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(e)return r(e[0])}return t}var ke=class{#e=new Map;times=[];time(e){this.#e.has(e)&&T(`Timer is already running for ${e}`),this.#e.set(e,Date.now())}timeEnd(e){this.#e.has(e)||T(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.#e.get(e),end:Date.now()}),this.#e.delete(e)}toString(){let e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join(``)}};function Ae(e,t){let n=t?URL.parse(e,t):URL.parse(e);return/https?:/.test(n?.protocol??``)}function R(e){e.preventDefault()}function z(e){e.preventDefault(),e.stopPropagation()}var je=class{static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!=`string`)return null;this.#e||=RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?`);let t=this.#e.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}};function Me(e){if(e.startsWith(`#`)){let t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith(`rgb(`)){let[t,n,r]=e.slice(4,-1).split(`,`).map(e=>parseInt(e,10));return[t,n,r,1]}if(e.startsWith(`rgba(`)){let t=e.slice(5,-1).split(`,`);return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!==`none`?parseFloat(t[4]):1]:null}function Ne(e){let t=Me(e);return t?t.slice(0,3):(T(`Not a valid color format: "${e}"`),[0,0,0])}function Pe(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,t.style.colorScheme=`only light`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,Ne(r))}t.remove()}function B(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function V(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Fe(e,t,n=!1,r=!0){if(t instanceof _e){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,s=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!n||t.rotation%180==0?(a.width=o,a.height=s):(a.width=s,a.height=o)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var Ie=class e{constructor(){let{pixelRatio:t}=e;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,n,r,i,a=-1){let o=1/0,s=1/0,c=1/0;r=e.capPixels(r,a),r>0&&(o=Math.sqrt(r/(t*n))),i!==-1&&(s=i/t,c=i/n);let l=Math.min(o,s,c);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let n=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,n):n}return e}},Le=[`image/apng`,`image/avif`,`image/bmp`,`image/gif`,`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`image/x-icon`],Re=class{static get isDarkMode(){return M(this,`isDarkMode`,!!window?.matchMedia?.(`(prefers-color-scheme: dark)`).matches)}},ze=class{static get commentForegroundColor(){let e=document.createElement(`span`);e.classList.add(`comment`,`sidebar`);let{style:t}=e;t.width=t.height=`0`,t.display=`none`,t.color=`var(--comment-fg-color)`,document.body.append(e);let{color:n}=window.getComputedStyle(e);return e.remove(),M(this,`commentForegroundColor`,Ne(n))}};function Be(e,t){t=L(t??1,0,1);let n=255*(1-t);return e.map(e=>Math.round(e*t+n))}function Ve(e,t){let n=e[0]/255,r=e[1]/255,i=e[2]/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)t[0]=t[1]=0;else{let e=a-o;switch(t[1]=s<.5?e/(a+o):e/(2-a-o),a){case n:t[0]=((r-i)/e+(ri?(r+.05)/(i+.05):(i+.05)/(r+.05)}var Ge=new Map;function Ke(e,t){let n=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,r=Ge.get(n);if(r)return r;let i=new Float32Array(9),a=i.subarray(0,3),o=i.subarray(3,6);Ve(e,o);let s=i.subarray(6,9);Ve(t,s);let c=s[2]<.5,l=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),We(o,s,a).005;){let n=o[2]=(e+t)/2;c===We(o,s,a){n.delete()},{signal:n._signal}),this.#r.append(r)}get#p(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#f(t),this.#r.append(t,this.#p),this.#i=e}addComment(e,t=null){if(this.#a)return;let n=e.renderForToolbar();if(!n)return;this.#f(n);let r=this.#o=this.#p;t?(this.#r.insertBefore(n,t),this.#r.insertBefore(r,t)):this.#r.append(n,r),this.#a=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;let t=e.renderButton();this.#f(t),this.#r.append(t,this.#p)}async addEditSignatureButton(e){let t=this.#s=await e.renderEditButton(this.#n);this.#f(t),this.#r.append(t,this.#p)}removeButton(e){e===`comment`&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#o?.remove(),this.#o=null)}async addButton(e,t){switch(e){case`colorPicker`:t&&this.addColorPicker(t);break;case`altText`:t&&await this.addAltText(t);break;case`editSignature`:t&&await this.addEditSignatureButton(t);break;case`delete`:this.addDeleteButton();break;case`comment`:t&&this.addComment(t)}}async addButtonBefore(e,t,n){if(!t&&e===`comment`)return;let r=this.#r.querySelector(n);r&&e===`comment`&&this.addComment(t,r)}updateEditSignatureButton(e){this.#s&&(this.#s.title=e)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},Xe=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`);let t=this.#n._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener(`contextmenu`,R,{signal:t});let n=this.#e=document.createElement(`div`);return n.className=`buttons`,e.append(n),this.#n.hasCommentManager()&&this.#a(`commentButton`,`pdfjs-comment-floating-button`,`pdfjs-comment-floating-button-label`,()=>{this.#n.commentSelection(`floating_button`)}),this.#a(`highlightButton`,`pdfjs-highlight-floating-button1`,`pdfjs-highlight-floating-button-label`,()=>{this.#n.highlightSelection(`floating_button`)}),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(en){r=a,n=e;continue}t?a>r&&(r=a):a=1}static clearPointerType(){e.#r=null}static clearPointerIds(){e.#e=NaN,e.#t=null}static clearTimeStamp(){e.#n=NaN}},$e=class{#e=0;get id(){return`${l}${this.#e++}`}},et=class e{#e=de();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=`data:image/svg+xml;charset=UTF-8,`,t=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),n=new Image;n.src=e;let r=n.decode().then(()=>(t.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0));return M(this,`_isSVGFittingCanvas`,r)}async#r(t,n){this.#n||=new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await Ce(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){T(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},tt=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},nt=class e{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:n}=F.platform;for(let[r,i,a={}]of t){let t=r.some(e=>e.startsWith(`mac+`));for(let o of r){let r=o;if(t){let e=o.startsWith(`mac+`);if(n!==e)continue;e&&(r=o.slice(4))}let[s,c]=e.#e(r);s!==null&&this.callbacks.getOrInsertComputed(s,pe).push({callback:i,options:a,modifiers:c})}}}static#e(t){let n=null,r=0;for(let i of t.split(`+`)){if(i=i.trim(),!i)continue;let a=i.toUpperCase(),o=e[a];if(o){r|=o;continue}if(n!==null){T(`KeyboardManager: multiple keys in shortcut "${t}"`);break}n=a===`SPACE`?` `:i}return n===null&&T(`KeyboardManager: no key found in shortcut "${t}"`),[n,r]}static#t(e){let t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?t[1]?.toLowerCase()??t[2]:null}exec(t,n){let r=this.callbacks.get(n.key);if(!r){if(/^[a-z]$/i.test(n.key))return;let t=e.#t(n.code);if(t===null||t===n.key||(r=this.callbacks.get(t),!r))return}let i=(n.altKey?e.ALT:0)|(n.ctrlKey?e.CTRL:0)|(n.metaKey?e.META:0)|(n.shiftKey?e.SHIFT:0),a=r.find(e=>e.modifiers===i);if(!a)return;let{callback:o,options:{bubbles:s=!1,args:c=[],checker:l=null}}=a;l&&!l(t,n)||(o.bind(t,...c,n)(),s||z(n))}},rt=class e{static _colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return Pe(e),M(this,`_colors`,e)}convert(t){let n=Ne(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?I.makeHexColor(...t):e}},it=class e{#e=new AbortController;#t=null;#n=null;#r=new Map;#i=new Map;#a=null;#o=null;#s=null;#c=null;#l=new tt;#u=null;#d=null;#f=null;#p=0;#m=new Set;#h=null;#g=null;#_=new Set;_editorUndoBar=null;#v=!1;#y=!1;#b=!1;#x=null;#S=null;#C=null;#w=null;#T=!1;#E=null;#D=new $e;#O=!1;#k=!1;#A=!1;#j=null;#M=null;#N=null;#P=null;#F=null;#I=u.NONE;#L=new Set;#R=null;#z=null;#B=null;#V=null;#H=null;#U={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#W=[0,0];#G=null;#K=null;#q=null;#J=null;#Y=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#K.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return M(this,`_keyboardManager`,new nt([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#K.contains(t)&&!e.isEnterHandled}],[[`Space`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#K.contains(document.activeElement)}],[[`Escape`],t.unselectAll],[[`ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this._signal=this.#e.signal;this.#K=e,this.#q=t,this.#J=n,this.#o=r,this.#u=i,this.#z=a,this.#H=s,this._eventBus=o;let _={signal:g,...Ze};o.on(`editingaction`,this.onEditingAction.bind(this),_),o.on(`pagechanging`,this.onPageChanging.bind(this),_),o.on(`scalechanging`,this.onScaleChanging.bind(this),_),o.on(`rotationchanging`,this.onRotationChanging.bind(this),_),o.on(`setpreference`,this.onSetPreference.bind(this),_),o.on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),_),window.addEventListener(`pointerdown`,()=>{this.#k=!0},{capture:!0,signal:g}),window.addEventListener(`pointerup`,()=>{this.#k=!1},{capture:!0,signal:g}),window.addEventListener(`beforeunload`,this.endCurrentEditing.bind(this),{capture:!0,signal:g}),this.#te(),this.#ce(),this.#ie(),this.#s=s.annotationStorage,this.#x=s.filterFactory,this.#B=c,this.#w=l||null,this.#v=u,this.#y=d,this.#b=f,this.#F=p||null,this.viewParameters={realScale:Se.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=h!==!1,i?.setSidebarUiManager(this)}destroy(){this.#Y?.resolve(),this.#Y=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#i.values())e.destroy();this.#i.clear(),this.#r.clear(),this.#_.clear(),this.#P?.clear(),this.#t=null,this.#L.clear(),this.#l.destroy(),this.#o?.destroy(),this.#u?.destroy(),this.#z?.destroy(),this.#E?.hide(),this.#E=null,this.#N?.destroy(),this.#N=null,this.#n=null,this.#S&&=(clearTimeout(this.#S),null),this.#G&&=(clearTimeout(this.#G),null),this._editorUndoBar?.destroy(),this.#H=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#F}get useNewAltTextFlow(){return this.#y}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return M(this,`hcmFilter`,this.#B?this.#x.addHCMFilter(this.#B.foreground,this.#B.background):`none`)}get direction(){return M(this,`direction`,getComputedStyle(this.#K).direction)}get _highlightColors(){return M(this,`_highlightColors`,this.#w?new Map(this.#w.split(`,`).map(e=>(e=e.split(`=`).map(e=>e.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return M(this,`highlightColors`,null);let t=new Map,n=!!this.#B;for(let[r,i]of e){let e=r.endsWith(`_HCM`);if(n&&e){t.set(r.replace(`_HCM`,``),i);continue}!n&&!e&&t.set(r,i)}return M(this,`highlightColors`,t)}get highlightColorNames(){return M(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#f=e}setMainHighlightColorPicker(e){this.#N=e}editAltText(e,t=!1){this.#o?.editAltText(this,e,t)}hasCommentManager(){return!!this.#u}editComment(e,t,n,r){this.#u?.showDialog(this,e,t,n,r)}selectComment(e,t){(this.#i.get(e)?.getEditorByUID(t))?.toggleComment(!0,!0)}updateComment(e){this.#u?.updateComment(e.getData())}updatePopupColor(e){this.#u?.updatePopupColor(e)}removeComment(e){this.#u?.removeComments([e.uid])}deleteComment(e,t){let n=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,`comment`),this.toggleComment(null),e.comment=null},undo:n,mustExec:!0})}toggleComment(e,t,n=void 0){this.#u?.toggleCommentPopup(e,t,n)}makeCommentColor(e,t){return e&&this.#u?.makeCommentColor(e,t)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(e){if(this.#i.has(e-1))return;let{resolve:t,promise:n}=Promise.withResolvers(),r=n=>{n.pageNumber===e&&(this._eventBus.off(`editorsrendered`,r),t())};this._eventBus.on(`editorsrendered`,r,Ze),await n}getSignature(e){this.#z?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#z}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal,...Ze}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){e===`enableNewAltTextWhenAddingImage`&&(this.#b=t)}onPageChanging({pageNumber:e}){this.#p=e-1}deletePage(e){for(let t of this.getEditors(e))t.remove();this.#i.delete(e),this.#p===e&&(this.#p=0)}focusMainContainer(){this.#K.focus()}findParent(e,t){for(let n of this.#i.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#q.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#_.add(e)}removeShouldRescale(e){this.#_.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Se.PDF_TO_CSS_UNITS;for(let e of this.#_)e.onScaleChanging();this.#f?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#X({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Z(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#i.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``,t=!1){let n=document.getSelection();if(!n||n.isCollapsed)return;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n,s=n.toString(),c=this.#X(n).closest(`.textLayer`),l=this.getSelectionBoxes(c);if(!l)return;n.empty();let d=this.#Z(c),f=this.#I===u.NONE,p=()=>{let n=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o,text:s});f&&this.showAllEditors(`highlight`,!0,!0),t&&n?.editComment()};if(f){this.switchToMode(u.HIGHLIGHT,p);return}p()}commentSelection(e=``){this.highlightSelection(e,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Q(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#X(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#E||=new Xe(this),this.#E.show(t,n,this.direction===`ltr`))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#s)return null;let t=`${l}${e}`,n=this.#s.getRawValue(t);return n&&this.#s.remove(t),n}addToAnnotationStorage(e){!e.isEmpty()&&this.#s&&!this.#s.has(e.id)&&this.#s.setValue(e.id,e)}a11yAlert(e,t=null){let n=this.#J;n&&(n.setAttribute(`data-l10n-id`,e),t?n.setAttribute(`data-l10n-args`,JSON.stringify(t)):n.removeAttribute(`data-l10n-args`))}#$(){let e=document.getSelection();if(!e||e.isCollapsed){this.#R&&(this.#E?.hide(),this.#R=null,this.#le({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#R)return;let n=this.#X(e).closest(`.textLayer`);if(!n){this.#R&&(this.#E?.hide(),this.#R=null,this.#le({hasSelectedText:!1}));return}if(this.#E?.hide(),this.#R=t,this.#le({hasSelectedText:!0}),(this.#I===u.HIGHLIGHT||this.#I===u.NONE)&&(this.#I===u.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#T=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#I===u.HIGHLIGHT?this.#Z(n):null;if(e?.toggleDrawing(),this.#k){let t=new AbortController,n=this.combinedSignal(t),r=n=>{(n.type!==`pointerup`||n.button===0)&&(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#ee(`main_toolbar`))};window.addEventListener(`pointerup`,r,{signal:n}),window.addEventListener(`blur`,r,{signal:n})}else e?.toggleDrawing(!0),this.#ee(`main_toolbar`)}}#ee(e=``){this.#I===u.HIGHLIGHT?this.highlightSelection(e):this.#v&&this.#Q()}#te(){document.addEventListener(`selectionchange`,this.#$.bind(this),{signal:this._signal})}#ne(){if(this.#C)return;this.#C=new AbortController;let e=this.combinedSignal(this.#C);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#re(){this.#C?.abort(),this.#C=null}blur(){if(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#ee(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#L)if(t.div.contains(e)){this.#M=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#M)return;let[e,t]=this.#M;this.#M=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ie(){if(this.#j)return;this.#j=new AbortController;let e=this.combinedSignal(this.#j);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#ae(){this.#j?.abort(),this.#j=null}#oe(){if(this.#d)return;this.#d=new AbortController;let e=this.combinedSignal(this.#d);document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}#se(){this.#d?.abort(),this.#d=null}#ce(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#ie(),this.setEditingState(!0)}removeEditListeners(){this.#ae(),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#g)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#g)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#L){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#g)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){T(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#pe(t);this.#ge(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){T(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#I!==u.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#ee(`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;case`commentSelection`:this.commentSelection(`context_menu`)}}updatePageIndex(e,t){for(let n of this.getEditors(e))n.pageIndex=t;let n=this.#a.get(e);n&&(n.pageIndex=t,this.#i.set(t,n),this.#O?n.enable():n.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear()}endUpdatePages(){this.#a=null}clonePage(e,t){for(let n of this.getEditors(e)){let e=n.serialize(n.mode!==u.HIGHLIGHT);e&&(e.pageIndex=t,e.id=this.getId(),e.isClone=!0,delete e.popupRef,this.#s.setValue(e.id,e))}}findClonesForPage(e){let t=[],{pageIndex:n}=e;for(let[r,i]of this.#s)i.pageIndex===n&&i.isClone&&(this.#s.remove(r),t.push(e.deserialize(i).then(t=>{t&&(t.isClone=!0,e.addOrRebuild(t))})));return Promise.all(t)}#le(e){Object.entries(e).some(([e,t])=>this.#U[e]!==t)&&(this._eventBus.dispatch(`editingstateschanged`,{source:this,details:Object.assign(this.#U,e)}),this.#I===u.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#ue([[d.HIGHLIGHT_FREE,!0]]))}#ue(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#ne(),this.#oe(),this.#le({isEditing:this.#I!==u.NONE,isEmpty:this.#he(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#re(),this.#se(),this.#le({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#g){this.#g=e;for(let e of this.#g)this.#ue(e.defaultPropertiesToUpdate)}}getId(){return this.#D.id}get currentLayer(){return this.#i.get(this.#p)}getLayer(e){return this.#i.get(e)}get currentPageIndex(){return this.#p}addLayer(e){this.#i.set(e.pageIndex,e),this.#O?e.enable():e.disable()}removeLayer(e){this.#i.delete(e.pageIndex)}async updateMode(e,t=null,n=!1,r=!1,i=!1,a=!1){if(this.#I!==e&&!(this.#Y&&(await this.#Y.promise,!this.#Y))){if(this.#Y=Promise.withResolvers(),this.#f?.commitOrRemove(),this.#I===u.POPUP&&this.#u?.hideSidebar(),this.#u?.destroyPopup(),this.#I=e,e===u.NONE){this.setEditingState(!1),this.#fe();for(let e of this.#r.values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#Y.resolve();return}for(let e of this.#r.values())e.addStandaloneCommentButton();e===u.SIGNATURE&&await this.#z?.loadSignatures(),n&&H.clearPointerType(),this.setEditingState(!0),await this.#de(),this.unselectAll();for(let t of this.#i.values())t.updateMode(e);if(e===u.POPUP){this.#n||=await this.#H.getAnnotationsByType(new Set(this.#g.map(e=>e._editorType)));let e=new Set,t=[];for(let n of this.#r.values()){let{annotationElementId:r,hasComment:i,deleted:a}=n;r&&e.add(r),i&&!a&&t.push(n.getData())}for(let n of this.#n){let{id:r,popupRef:i,contentsObj:a}=n;i&&a?.str&&!e.has(r)&&!this.#m.has(r)&&t.push(n)}this.#u?.showSidebar(t)}if(!t){r&&this.addNewEditorFromKeyboard(),this.#Y.resolve();return}for(let e of this.#r.values())e.uid===t?(this.setSelected(e),a?e.editComment():i?e.enterInEditMode():e.focus()):e.unselect();this.#Y.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#I&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,...e})}updateParams(e,t){if(this.#g){switch(e){case d.CREATE:this.currentLayer.addNewEditor(t);return;case d.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#V||=new Map).set(e,t),this.showAllEditors(`highlight`,t)}if(this.hasSelection)for(let n of this.#L)n.updateParams(e,t);else for(let n of this.#g)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#r.values())n.editorType===e&&n.show(t);(this.#V?.get(d.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#ue([[d.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#A!==e){this.#A=e;for(let t of this.#i.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#de(){if(!this.#O){this.#O=!0;let e=[];for(let t of this.#i.values())e.push(t.enable());await Promise.all(e);for(let e of this.#r.values())e.enable()}}#fe(){if(this.unselectAll(),this.#O){this.#O=!1;for(let e of this.#i.values())e.disable();for(let e of this.#r.values())e.disable()}}*getEditors(e){for(let t of this.#r.values())t.pageIndex===e&&(yield t)}getEditor(e){return this.#r.get(e)}addEditor(e){this.#r.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#S&&clearTimeout(this.#S),this.#S=setTimeout(()=>{this.focusMainContainer(),this.#S=null},0)),this.#r.delete(e.id),e.annotationElementId&&this.#P?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#m.has(e.annotationElementId))&&this.#s?.remove(e.id)}addDeletedAnnotationElement(e){this.#m.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#m.has(e)}removeDeletedAnnotationElement(e){this.#m.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#pe(e){let t=this.#i.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#ue(e.propertiesToUpdate))}get#me(){let e=null;for(e of this.#L);return e}updateUI(e){this.#me===e&&this.#ue(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#ue(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#L.has(e)){this.#L.delete(e),e.unselect(),this.#le({hasSelectedEditor:this.hasSelection});return}this.#L.add(e),e.select(),this.#ue(e.propertiesToUpdate),this.#le({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#f?.commitOrRemove();for(let t of this.#L)t!==e&&t.unselect();this.#u?.destroyPopup(),this.#L.clear(),this.#L.add(e),e.select(),this.#ue(e.propertiesToUpdate),this.#le({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#L.values().next().value}unselect(e){e.unselect(),this.#L.delete(e),this.#le({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#L.size!==0}get isEnterHandled(){return this.#L.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#le({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#he()}),this._editorUndoBar?.hide()}redo(){this.#l.redo(),this.#le({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#he()})}addCommands(e){this.#l.add(e),this.#le({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#he()})}cleanUndoStack(e){this.#l.cleanType(e)}#he(){if(this.#r.size===0)return!0;if(this.#r.size===1)for(let e of this.#r.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#L],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#pe(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ge(e){for(let e of this.#L)e.unselect();this.#L.clear();for(let t of e)t.isEmpty()||(this.#L.add(t),t.select());this.#le({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#L)e.commit();this.#ge(this.#r.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#I!==u.NONE))&&!this.#f?.commitOrRemove()&&(this.#u?.destroyPopup(),this.hasSelection)){for(let e of this.#L)e.unselect();this.#L.clear(),this.#le({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#W[0]+=e,this.#W[1]+=t;let[r,i]=this.#W,a=[...this.#L];this.#G&&clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#G=null,this.#W[0]=this.#W[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(r,i),e.translationDone())},undo:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(-r,-i),e.translationDone())},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t),n.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#h=new Map;for(let e of this.#L)this.#h.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#h)return!1;this.disableUserSelect(!1);let e=this.#h;this.#h=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#r.has(e.id)){let i=this.#i.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#h)for(let n of this.#h.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#L.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#I}isEditingMode(){return this.#I!==u.NONE}get imageManager(){return M(this,`imageManager`,new et)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a})}let s=[];for(let e=0,n=t.rangeCount;ee.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e){this.#s?.remove(),this.#s=null;return}if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),(this.#e!==e||this.#t!==t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getElementForAltText()?.setAttribute(`aria-describedby`,n.id)}},ot=class{#e=null;#t=null;#n=!1;#r=null;#i=null;#a=null;#o=null;#s=null;#c=!1;#l=null;constructor(e){this.#r=e}renderForToolbar(){let e=this.#t=document.createElement(`button`);return e.className=`comment`,this.#u(e,!1)}renderForStandalone(){let e=this.#e=document.createElement(`button`);e.className=`annotationCommentButton`;let t=this.#r.commentButtonPosition;if(t){let{style:n}=e;n.insetInlineEnd=`calc(${100*(this.#r._uiManager.direction===`ltr`?1-t[0]:t[0])}% - var(--comment-button-dim))`,n.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let r=this.#r.commentButtonColor;r&&(n.backgroundColor=r)}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;let e=this.#r.commentButtonColor;e&&(this.#e.style.backgroundColor=e),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#e)return null;let{x:e,y:t,height:n}=this.#e.getBoundingClientRect(),{x:r,y:i,width:a,height:o}=this.#r.parent.boundingClientRect;return[(e-r)/a,(t+n-i)/o]}set commentPopupPositionInLayer(e){this.#l=e}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:t}){this.#e&&(this.#e.classList.toggle(`selected`,e),this.#e.ariaExpanded=t)}#u(e,t){if(!this.#r._uiManager.hasCommentManager())return null;e.tabIndex=`0`,e.ariaHasPopup=`dialog`,t?(e.ariaControls=`commentPopup`,e.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`)):(e.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],e.setAttribute(`data-l10n-id`,`pdfjs-editor-add-comment-button`));let n=this.#r._uiManager._signal;if(!(n instanceof AbortSignal)||n.aborted)return e;e.addEventListener(`contextmenu`,R,{signal:n}),t&&(e.addEventListener(`focusin`,e=>{this.#r._focusEventsAllowed=!1,z(e)},{capture:!0,signal:n}),e.addEventListener(`focusout`,e=>{this.#r._focusEventsAllowed=!0,z(e)},{capture:!0,signal:n})),e.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:n});let r=t=>{t.preventDefault(),e===this.#t?this.edit():this.#r.toggleComment(!0)};return e.addEventListener(`click`,r,{capture:!0,signal:n}),e.addEventListener(`keydown`,t=>{t.target===e&&t.key===`Enter`&&(this.#n=!0,r(t))},{signal:n}),e.addEventListener(`pointerenter`,()=>{this.#r.toggleComment(!1,!0)},{signal:n}),e.addEventListener(`pointerleave`,()=>{this.#r.toggleComment(!1,!1)},{signal:n}),e}edit(e){let t=this.commentPopupPositionInLayer,n,r;if(t)[n,r]=t;else{[n,r]=this.#r.commentButtonPosition;let{width:e,height:t,x:i,y:a}=this.#r;n=i+n*e,r=a+r*t}let i=this.#r.parent.boundingClientRect,{x:a,y:o,width:s,height:c}=i;this.#r._uiManager.editComment(this.#r,a+n*s,o+r*c,{...e,parentDimensions:i})}finish(){this.#t&&(this.#t.focus({focusVisible:this.#n}),this.#n=!1)}isDeleted(){return this.#c||this.#o===``}isEmpty(){return this.#o===null}hasBeenEdited(){return this.isDeleted()||this.#o!==this.#i}serialize(){return this.data}get data(){return{text:this.#o,richText:this.#a,date:this.#s,deleted:this.isDeleted()}}set data(e){if(e!==this.#o&&(this.#a=null),e===null){this.#o=``,this.#c=!0;return}this.#o=e,this.#s=new Date,this.#c=!1}restoreData({text:e,richText:t,date:n}){this.#o=e,this.#a=t,this.#s=n,this.#c=!1}setInitialText(e,t=null){this.#i=e,this.data=e,this.#s=null,this.#a=t}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#o=``,this.#a=null,this.#s=null,this.#r=null,this.#n=!1,this.#c=!1}},st=class e{#e;#t=!1;#n=null;#r;#i;#a;#o;#s=null;#c;#l=null;#u;#d=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#u=new AbortController,this.#c=AbortSignal.any([o,this.#u.signal]),e.addEventListener(`touchstart`,this.#f.bind(this),{passive:!1,signal:this.#c})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ie.pixelRatio}#f(e){if(this.#r?.())return;if(e.touches.length===1){if(this.#s)return;let e=this.#s=new AbortController,t=AbortSignal.any([this.#c,e.signal]),n=this.#e,r={capture:!0,signal:t,passive:!1},i=e=>{e.pointerType===`touch`&&(this.#s?.abort(),this.#s=null)};n.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(z(e),i(e))},r),n.addEventListener(`pointerup`,i,r),n.addEventListener(`pointercancel`,i,r);return}if(!this.#d){this.#d=new AbortController;let e=AbortSignal.any([this.#c,this.#d.signal]),t=this.#e,n={signal:e,capture:!1,passive:!1};t.addEventListener(`touchmove`,this.#p.bind(this),n);let r=this.#m.bind(this);t.addEventListener(`touchend`,r,n),t.addEventListener(`touchcancel`,r,n),n.capture=!0,t.addEventListener(`pointerdown`,z,n),t.addEventListener(`pointermove`,z,n),t.addEventListener(`pointercancel`,z,n),t.addEventListener(`pointerup`,z,n),this.#i?.()}if(z(e),e.touches.length!==2||this.#n?.()){this.#l=null;return}let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#l={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#p(t){if(!this.#l||t.touches.length!==2)return;z(t);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=this.#l,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!this.#t&&Math.abs(v-_)<=e.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,!this.#t){this.#t=!0;return}let y=[(i+o)/2,(a+s)/2];this.#a?.(y,v,_)}#m(e){e.touches.length>=2||(this.#d&&(this.#d.abort(),this.#d=null,this.#o?.()),this.#l&&(z(e),this.#l=null,this.#t=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#s?.abort(),this.#s=null}},U=class e{#e=null;#t=null;#n=null;#r=null;#i=null;#a=!1;#o=null;#s=``;#c=null;#l=null;#u=null;#d=null;#f=null;#p=``;#m=!1;#h=null;#g=!1;#_=!1;#v=!1;#y=null;#b=0;#x=0;#S=null;#C=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#w=!1;#T=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new rt;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=it.TRANSLATE_SMALL,r=it.TRANSLATE_BIG;return M(this,`_resizerKeyboardManager`,new nt([[[`ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return M(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new ct({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._l10nAlert??=Object.freeze({highlight:`pdfjs-editor-highlight-added-alert`,freetext:`pdfjs-editor-freetext-added-alert`,ink:`pdfjs-editor-ink-added-alert`,stamp:`pdfjs-editor-stamp-added-alert`,signature:`pdfjs-editor-signature-added-alert`}),e._l10nResizer??=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){E(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#w}set _isDraggable(e){this.#w=e,this.div?.classList.toggle(`draggable`,e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#T}setParent(e){e===null?(this.#W(),this.#d?.remove(),this.#d=null):(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r),this._onTranslated()}#E([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#E(this.parentDimensions,e,t)}translateInPage(e,t){this.#h||=[this.x,this.y,this.width,this.height],this.#E(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){this.#h||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=L(i,0,n-o),a=L(a,0,r-s);break;case 90:i=L(i,0,n-s),a=L(a,o,r);break;case 180:i=L(i,o,n),a=L(a,s,r);break;case 270:i=L(i,s,n),a=L(a,0,r-o)}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#D(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#D(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#D(t,n,360-this.parentRotation)}#O(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(){let{div:{style:e},width:t,height:n}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*n).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#k(){if(this.#c)return;this.#c=document.createElement(`div`),this.#c.classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);this.#c.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#A.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,R,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#c)}#A(e,t){t.preventDefault();let{isMac:n}=F.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#l=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#N.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,z,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,R,{signal:a}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#M()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#j(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#M(){if(!this.#u)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#u;this.#u=null;let i=this.x,a=this.y,o=this.width,s=this.height;(i!==e||a!==t||o!==n||s!==r)&&this.addCommands({cmd:this.#j.bind(this,i,a,o,s),undo:this.#j.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#N(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#O(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#O(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2]}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#l;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#l[0]=e,this.#l[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=L(Math.abs(b[0]-y[0]-E),l,1)/s:T=L(Math.abs(b[1]-y[1]-D),u,1)/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#_)return this._editToolbar;this._editToolbar=new Ye(this),this.div.append(this._editToolbar.render());let{toolbarButtons:e}=this;if(e)for(let[t,n]of e)await this._editToolbar.addButton(t,n);return this.hasComment||this._editToolbar.addButton(`comment`,this.addCommentButton()),this._editToolbar.addButton(`delete`),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore(`comment`,this.addCommentButton(),`.deleteButton`)}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton(`comment`)}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#n?.destroy()}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(at.initialize(e._l10n),this.#n=new at(this),this.#e&&=(this.#n.data=this.#e,null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}focusCommentButton(){this.#r?.focusButton()}addCommentButton(){return this.canAddComment?this.#r||=new ot(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove(`hidden`);return}this.hasComment&&(this.#i=this.#r.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#r.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add(`hidden`)}get comment(){if(!this.#r)return null;let{data:{richText:e,text:t,date:n,deleted:r}}=this.#r;return{text:t,richText:e,date:n,deleted:r,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){this.#r||=new ot(this),typeof e==`object`&&e?this.#r.restoreData(e):this.#r.data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:n}){if(!t||(this.#r||=new ot(this),this.#r.setInitialText(e,n),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){return this.#r?.hasBeenEdited()}get hasDeletedComment(){return this.#r?.isDeleted()}get hasComment(){return!!this.#r&&!this.#r.isEmpty()&&!this.#r.isDeleted()}async editComment(e){this.#r||=new ot(this),this.#r.edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){this.#r.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,t]=e.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,i=r+n+1,a=t-100,o=i+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[i,a,o,t]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){this.#r.data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let e=this.div=document.createElement(`div`);e.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),e.className=this.name,e.setAttribute(`id`,this.id),e.tabIndex=this.#a?-1:0,e.setAttribute(`role`,`application`),this.defaultL10nId&&e.setAttribute(`data-l10n-id`,this.defaultL10nId),this._isVisible||e.classList.add(`hidden`),this.setInForeground(),this.#z();let[t,n]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*n/t).toFixed(2)}%`,e.style.maxHeight=`${(100*t/n).toFixed(2)}%`);let[r,i]=this.getInitialTranslation();return this.translate(r,i),Qe(this,e,[`keydown`,`pointerdown`,`dblclick`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#C||=new st({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#P.bind(this),onPinching:this.#F.bind(this),onPinchEnd:this.#I.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#P(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#F(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#O(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#h||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#I(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#M()}pointerdown(e){let{isMac:t}=F.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#R(e);return}this.#L(e)}#L(e){let{isMac:t}=F.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#R(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#o=null,this.#m=!1,this._uiManager.endDragSession()||this.#L(e),n&&this._onStopDragging()};t&&(this.#b=e.clientX,this.#x=e.clientY,this.#o=e.pointerId,this.#s=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#o){z(e);return}let[a,o]=this.screenToPageTranslation(t-this.#b,r-this.#x);this.#b=t,this.#x=r,this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,z,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#s&&(this.#C||e.isPrimary)&&o(e),z(e)},a));let s=e=>{if(!this.#o||this.#o===e.pointerId){o(e);return}z(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&e._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#r?.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:n,opacity:r,deleted:i,richText:a},uid:o,pageIndex:s,creationDate:c,modificationDate:l}=this;return{id:o,pageIndex:s,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:c,modificationDate:n||l,popupRef:!i,color:t,opacity:r}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#_=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#_=!1,!0):!1}isInEditMode(){return this.#_}shouldGetKeyboardEvents(){return this.#v}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t0&&e0}#z(){if(this.#f||!this.div)return;this.#f=new AbortController;let e=this._uiManager.combinedSignal(this.#f);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}rebuild(){this.#z()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||``}}serialize(e=!1,t=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||``}}static async deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:n.getId(),uiManager:n,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});r.rotation=e.rotation,r.#e=e.accessibilityData,r._isCopy=e.isCopy||!1;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#y&&=(clearTimeout(this.#y),null),this.#W(),this.removeEditToolbar(),this.#S){for(let e of this.#S.values())clearTimeout(e);this.#S=null}this.parent=null,this.#C?.destroy(),this.#C=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#k(),this.#c.classList.remove(`hidden`))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction===`ltr`?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,n]}=this,[r,i,a,o]=this.getPDFRect();return[e._round(r+(a-r)*t),e._round(i+(o-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#r.commentPopupPositionInLayer}set commentPopupPosition(e){this.#r.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#r.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#r.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#r?.setCommentButtonStates(e)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#c.children;if(!this.#t){this.#t=Array.from(n);let t=this.#B.bind(this),r=this.#V.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#H.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(ai)for(let e=0;e{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#c?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!==`BUTTON`&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(e){this.#g=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#S||=new Map;let{action:n}=t,r=this.#S.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},e._telemetryTimeout),this.#S.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(e){if(!this.#d&&!this.deleted){this.#d=e.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},ct=class extends U{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},lt=3285377520,W=4294901760,ut=65535,dt=class{constructor(e){this.h1=e?e&4294967295:lt,this.h2=e?e&4294967295:lt}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e>>17,o=o*d&W|o*p&ut,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&W|s*f&ut,s=s<<15|s>>>17,s=s*d&W|s*p&ut,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&W|o*f&ut,o=o<<15|o>>>17,o=o*d&W|o*p&ut,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&W|e*36045&ut,t=t*4283543511&W|((t<<16|e>>>16)*2950163797&W)>>>16,e^=t>>>1,e=e*444984403&W|e*60499&ut,t=t*3301882366&W|((t<<16|e>>>16)*3120437893&W)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},ft=Object.freeze({map:null,hash:``,transfer:void 0}),pt=class{#e=!1;#t=null;#n=null;#r=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,t){let n=this.#r.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#r.get(e)}remove(e){let t=this.#r.get(e);t!==void 0&&(t instanceof U&&this.#n.delete(t.annotationElementId),this.#r.delete(e),this.#r.size===0&&this.resetModified(),!this.#r.values().some(e=>e instanceof U)&&this.onAnnotationEditor?.(null))}setValue(e,t){let n=this.#r.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#r.set(e,t);r&&this.#i(),t instanceof U&&((this.#n||=new Map).set(t.annotationElementId,t),this.onAnnotationEditor?.(t.constructor._type))}has(e){return this.#r.has(e)}get size(){return this.#r.size}#i(){this.#e||(this.#e=!0,this.onSetModified?.())}resetModified(){this.#e&&(this.#e=!1,this.onResetModified?.())}get print(){return new mt(this)}get serializable(){if(this.#r.size===0)return ft;let e=new Map,t=new dt,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#r){let o=a instanceof U?a.serialize(!1,r):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:ft}get editorStats(){let e=null,t=new Map,n=0,r=0;for(let i of this.#r.values()){if(!(i instanceof U)){i.popup&&(i.popup.deleted?r+=1:n+=1);continue}i.isCommentDeleted?r+=1:i.hasEditedComment&&(n+=1);let a=i.telemetryFinalData;if(!a)continue;let{type:o}=a;t.getOrInsertComputed(o,()=>Object.getPrototypeOf(i).constructor),e||=Object.create(null);let s=e[o]||=new Map;for(let[e,t]of Object.entries(a)){if(e===`type`)continue;let n=s.getOrInsertComputed(e,me);n.set(t,(n.get(t)??0)+1)}}if((r>0||n>0)&&(e||=Object.create(null),e.comments={deleted:r,edited:n}),!e)return null;for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,t){let n=this.#n?.get(e);return n?(n.updateFromAnnotationLayer(t),!0):!1}getEditor(e){return this.#n?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;let e=[];if(this.#n)for(let t of this.#n.values())t.serialize()&&e.push(t.annotationElementId);let t=``;if(e.length){let n=new dt;n.update(e.join(`,`)),t=n.hexdigest()}return this.#t={ids:new Set(e),hash:t}}[Symbol.iterator](){return this.#r.entries()}},mt=class extends pt{#e=ft;constructor(e){super();let{serializable:t}=e;if(t===ft)return;let{map:n,hash:r,transfer:i}=t,a=structuredClone(n,i?{transfer:i}:null);this.#e={map:a,hash:r,transfer:[]}}get print(){E(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return M(this,`modifiedIds`,{ids:new Set,hash:``})}},ht=`__forcedDependency`,{floor:gt,ceil:_t}=Math;function vt(e,t,n,r,i,a){e[t*4+0]=Math.min(e[t*4+0],n),e[t*4+1]=Math.min(e[t*4+1],r),e[t*4+2]=Math.max(e[t*4+2],i),e[t*4+3]=Math.max(e[t*4+3],a)}function yt(e,t,n,r,i){let a;e?(e<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=e,i[2]*=e,t<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=n,i[1]+=r,i[2]+=n,i[3]+=r}var bt=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],xt=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===bt}minX(e){return this.#t[e*4+0]/256}minY(e){return this.#t[e*4+1]/256}maxX(e){return(this.#t[e*4+2]+1)/256}maxY(e){return(this.#t[e*4+3]+1)/256}},St=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),Ct=class{#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#n=new Float64Array(n);_pendingBBoxIdx=-1;#r;#i;#a;#o;_savesStack=[];_markedContentStack=[];constructor(e,t){this.#r=e.width,this.#i=e.height,this.#s(t)}growOperationsCount(e){e>=this.#o.length&&this.#s(e,this.#o)}#s(e,t){let n=new ArrayBuffer(e*4);this.#a=new Uint8ClampedArray(n),this.#o=new Uint32Array(n),t&&t.length>0?(this.#o.set(t),this.#o.fill(bt,t.length)):this.#o.fill(bt)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,t){let n=Object.getPrototypeOf(this.#t);if(n===null)return this;this.#t=n;let r=this._savesStack.pop();return r!==void 0&&(t?.(r,e),this.#o[e]=this.#o[r]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){let n=this._savesStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let n=this._markedContentStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}pushBaseTransform(e){return this.#e.push(I.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){return this.#e.length>1&&this.#e.pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,this.#n.set(n,0)),this}recordClipBox(e,t,r,i,a,o){let s=I.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform()),c=n.slice();I.axialAlignedBoundingBox([r,a,i,o],s,c);let l=I.intersect(this.#t,c);return l?(this.#t[0]=l[0],this.#t[1]=l[1],this.#t[2]=l[2],this.#t[3]=l[3]):(this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0),this}recordBBox(e,t,r,i,a,o){let s=this.#t;if(s[0]===1/0)return this;let c=I.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform());if(s[0]===-1/0)return I.axialAlignedBoundingBox([r,a,i,o],c,this.#n),this;let l=n.slice();return I.axialAlignedBoundingBox([r,a,i,o],c,l),this.#n[0]=L(l[0],s[0],this.#n[0]),this.#n[1]=L(l[1],s[1],this.#n[1]),this.#n[2]=L(l[2],this.#n[2],s[2]),this.#n[3]=L(l[3],this.#n[3],s[3]),this}recordFullPageBBox(e){return this.#n[0]=Math.max(0,this.#t[0]),this.#n[1]=Math.max(0,this.#t[1]),this.#n[2]=Math.min(this.#r,this.#t[2]),this.#n[3]=Math.min(this.#i,this.#t[3]),this}recordOperation(e,t=!1,n){if(this._pendingBBoxIdx!==e)return this;let r=gt(this.#n[0]*256/this.#r),i=gt(this.#n[1]*256/this.#i),a=_t(this.#n[2]*256/this.#r),o=_t(this.#n[3]*256/this.#i);if(vt(this.#a,e,r,i,a,o),n)for(let t of n)for(let n of t)n!==e&&vt(this.#a,n,r,i,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#n[0]),this.#t[1]=Math.max(this.#t[1],this.#n[1]),this.#t[2]=Math.min(this.#t[2],this.#n[2]),this.#t[3]=Math.min(this.#t[3],this.#n[3])),this}take(){return new xt(this.#o,this.#a)}takeDebugMetadata(){throw Error(`Unreachable`)}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}},wt=class{#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[ht]:[]};#n=new Map;#r=new Set;#i=new Map;#a;#o;#s;constructor(e,t=!1){this.#s=e,t&&(this.#a=new Map,this.#o=(e,t)=>{St(this.#a,t).dependencies.add(e)})}get clipBox(){return this.#s.clipBox}growOperationsCount(e){this.#s.growOperationsCount(e)}save(e){return this.#e={__proto__:this.#e},this.#t={__proto__:this.#t,transform:{__proto__:this.#t.transform},moveText:{__proto__:this.#t.moveText},sameLineText:{__proto__:this.#t.sameLineText},[ht]:{__proto__:this.#t[ht]}},this.#s.save(e),this}restore(e){this.#s.restore(e,this.#o);let t=Object.getPrototypeOf(this.#e);return t===null?this:(this.#e=t,this.#t=Object.getPrototypeOf(this.#t),this)}recordOpenMarker(e){return this.#s.recordOpenMarker(e,this.#o),this}getOpenMarker(){return this.#s.getOpenMarker()}recordCloseMarker(e){return this.#s.recordCloseMarker(e,this.#o),this}beginMarkedContent(e){return this.#s.beginMarkedContent(e),this}endMarkedContent(e){return this.#s.endMarkedContent(e,this.#o),this}pushBaseTransform(e){return this.#s.pushBaseTransform(e),this}popBaseTransform(){return this.#s.popBaseTransform(),this}recordSimpleData(e,t){return this.#e[e]=t,this}recordIncrementalData(e,t){return this.#t[e].push(t),this}resetIncrementalData(e,t){return this.#t[e].length=0,this}recordNamedData(e,t){return this.#n.set(e,t),this}recordSimpleDataFromNamed(e,t,n){this.#e[e]=this.#n.get(t)??n}recordFutureForcedDependency(e,t){return this.recordIncrementalData(ht,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)t in this.#e&&this.recordFutureForcedDependency(t,this.#e[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of this.#r)this.recordFutureForcedDependency(ht,e);return this}resetBBox(e){return this.#s.resetBBox(e),this}recordClipBox(e,t,n,r,i,a){return this.#s.recordClipBox(e,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#s.recordBBox(e,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){let s=n.bbox,c,l;if(s&&(c=s[2]!==s[0]&&s[3]!==s[1]&&this.#i.get(n),c!==!1&&(l=[0,0,0,0],I.axialAlignedBoundingBox(s,n.fontMatrix,l),(r!==1||i!==0||a!==0)&&yt(r,-r,i,a,l),c)))return this.recordBBox(e,t,l[0],l[2],l[1],l[3]);if(!o)return this.recordFullPageBBox(e);let u=o();return s&&l&&c===void 0&&(c=l[0]<=i-u.actualBoundingBoxLeft&&l[2]>=i+u.actualBoundingBoxRight&&l[1]<=a-u.actualBoundingBoxAscent&&l[3]>=a+u.actualBoundingBoxDescent,this.#i.set(n,c),c)?this.recordBBox(e,t,l[0],l[2],l[1],l[3]):this.recordBBox(e,t,i-u.actualBoundingBoxLeft,i+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#s.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,t){let n=this.#r,r=this.#e,i=this.#t;for(let e of t)e in this.#e?n.add(r[e]):e in i&&i[e].forEach(n.add,n);return this}recordNamedDependency(e,t){return this.#n.has(t)&&this.#r.add(this.#n.get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[ht]),this.#a){let t=St(this.#a,e),{dependencies:n}=t;this.#r.forEach(n.add,n),this.#s._savesStack.forEach(n.add,n),this.#s._markedContentStack.forEach(n.add,n),n.delete(e),t.isRenderingOperation=!0}let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.recordOperation(e,t,[this.#r,this.#s._savesStack,this.#s._markedContentStack]),n&&this.#r.clear(),this}recordShowTextOperation(e,t=!1){let n=Array.from(this.#r);this.recordOperation(e,t),this.recordIncrementalData(`sameLineText`,e);for(let e of n)this.recordIncrementalData(`sameLineText`,e);return this}bboxToClipBoxDropOperation(e,t=!1){let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.bboxToClipBoxDropOperation(e),n&&this.#r.clear(),this}take(){return this.#i.clear(),this.#s.take()}takeDebugMetadata(){return this.#a}},Tt=class e{#e;#t;#n;#r=0;#i=0;constructor(t,n,r){if(t instanceof e&&t.#n===!!r)return t;this.#e=t,this.#t=n,this.#n=!!r}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw Error(`Unreachable`)}save(e){return this.#i++,this.#e.save(this.#t),this}restore(e){return this.#i>0&&(this.#e.restore(this.#t),this.#i--),this}recordOpenMarker(e){return this.#r++,this}getOpenMarker(){return this.#r>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#r--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return this.#e.pushBaseTransform(e),this}popBaseTransform(){return this.#e.popBaseTransform(),this}recordSimpleData(e,t){return this.#e.recordSimpleData(e,this.#t),this}recordIncrementalData(e,t){return this.#e.recordIncrementalData(e,this.#t),this}resetIncrementalData(e,t){return this.#e.resetIncrementalData(e,this.#t),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this.#e.recordSimpleDataFromNamed(e,t,this.#t),this}recordFutureForcedDependency(e,t){return this.#e.recordFutureForcedDependency(e,this.#t),this}inheritSimpleDataAsFutureForcedDependencies(e){return this.#e.inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#e.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return this.#n||this.#e.resetBBox(this.#t),this}recordClipBox(e,t,n,r,i,a){return this.#n||this.#e.recordClipBox(this.#t,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#n||this.#e.recordBBox(this.#t,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r,i,a,o){return this.#n||this.#e.recordCharacterBBox(this.#t,t,n,r,i,a,o),this}recordFullPageBBox(e){return this.#n||this.#e.recordFullPageBBox(this.#t),this}getSimpleIndex(e){return this.#e.getSimpleIndex(e)}recordDependencies(e,t){return this.#e.recordDependencies(this.#t,t),this}recordNamedDependency(e,t){return this.#e.recordNamedDependency(this.#t,t),this}recordOperation(e){return this.#e.recordOperation(this.#t,!0),this}recordShowTextOperation(e){return this.#e.recordShowTextOperation(this.#t,!0),this}bboxToClipBoxDropOperation(e){return this.#n||this.#e.bboxToClipBoxDropOperation(this.#t,!0),this}take(){throw Error(`Unreachable`)}takeDebugMetadata(){throw Error(`Unreachable`)}},G={stroke:[`path`,`transform`,`filter`,`strokeColor`,`strokeAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`dash`],fill:[`path`,`transform`,`filter`,`fillColor`,`fillAlpha`,`globalCompositeOperation`,`SMask`],imageXObject:[`transform`,`SMask`,`filter`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`],rawFillPath:[`filter`,`fillColor`,`fillAlpha`],showText:[`transform`,`leading`,`charSpacing`,`wordSpacing`,`hScale`,`textRise`,`moveText`,`textMatrix`,`font`,`fontObj`,`filter`,`fillColor`,`textRenderingMode`,`SMask`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`,`sameLineText`],transform:[`transform`],transformAndFill:[`transform`,`fillColor`]},Et=class e{#e;#t;#n=4;#r=0;#i=new e.#a(this.#n*6);static#a=F.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(t,r,i,a){if(this.#r===this.#n){this.#n*=2;let t=new e.#a(this.#n*6);t.set(this.#i),this.#i=t}let o=B(t),s;if(a[0]!==1/0){let e=n.slice();I.axialAlignedBoundingBox([0,-i,r,0],o,e);let t=I.intersect(a,e);if(!t)return;let[c,l,u,d]=t;if(c!==e[0]||l!==e[1]||u!==e[2]||d!==e[3]){let e=Math.atan2(o[1],o[0]),t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e));if(t<1e-6||n<1e-6||Math.abs(t-n)<1e-6)s=[c,l,c,d,u,l];else{let e=u-c,r=d-l,i=t*t,a=n*n,o=n*t,f=a-i,p=(r*a-e*o)/f;s=[c+(r*o-e*i)/f,l,c,l+p,u,d-p]}}}s||(s=[0,-i,0,0,r,-i],I.applyTransform(s,o,0),I.applyTransform(s,o,2),I.applyTransform(s,o,4)),s[0]/=this.#e,s[1]/=this.#t,s[2]/=this.#e,s[3]/=this.#t,s[4]/=this.#e,s[5]/=this.#t,this.#i.set(s,this.#r*6),this.#r++}take(){return this.#i.subarray(0,this.#r*6)}},Dt=class{#e=new Set;#t=null;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){let t=this.#n();t.insertRule(e,t.cssRules.length)}#n(){if(this.#t)return this.#t;let e=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&e){let{adoptedStyleSheets:t}=this._document;if(t){let n=new e;return t.push(n),this.#t=n}}return this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement)),this.#t=this.styleElement.sheet}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),this.#e.clear(),this.#t){let{adoptedStyleSheets:e}=this._document;e?.includes(this.#t)&&(this._document.adoptedStyleSheets=e.filter(e=>e!==this.#t)),this.#t=null}this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:n}){if(!(!e||this.#e.has(e.loadedName))){if(D(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:t,src:r,style:i}=e,a=new FontFace(t,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(t),n?.(e)}catch{T(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}E(`Not implemented: loadSystemFont without the Font Loading API.`)}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw T(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return M(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){return M(this,`isSyncFontLoadingSupported`,t||F.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(D(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return M(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function i(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let a,o,s=this._document.createElement(`canvas`);s.width=1,s.height=1;let c=s.getContext(`2d`),l=0;function u(e,t){if(++l>30){T(`Load test font never loaded.`),t();return}if(c.font=`30px `+e,c.fillText(`.`,0,20),c.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(u.bind(null,e,t))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let p=1482184792,m=n(f,16);for(a=0,o=d.length-3;a{g.remove(),t.complete()})}},Ot=class{compiledGlyphs=Object.create(null);#e;constructor(e,t=null,n,r){this.#e=e,this._inspectFont=t,n&&(this.charProcOperatorList=n),r&&Object.assign(this,r)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){T(`getPathGenerator - ignoring character: "${e}".`)}let i=Je(r?.path);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){M(this,`disableFontFace`,!!e)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get ascent(){return this.#e.ascent}get defaultWidth(){return this.#e.defaultWidth}get descent(){return this.#e.descent}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.#e.mimetype}get name(){return this.#e.name}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}get defaultVMetrics(){return this.#e.defaultVMetrics}},kt=class{static strings=[`fontFamily`,`fontWeight`,`italicAngle`]},At=class{static strings=[`css`,`loadedName`,`baseFontName`,`src`]},K=class{static bools=[`black`,`bold`,`disableFontFace`,`fontExtraProperties`,`isInvalidPDFjsFont`,`isType3Font`,`italic`,`missingFile`,`remeasure`,`vertical`];static numbers=[`ascent`,`defaultWidth`,`descent`];static strings=[`fallbackName`,`loadedName`,`mimetype`,`name`];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6},jt=class{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16},Mt=class{#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}#r(e){D(e>n&3;return r===0?void 0:r===2}get black(){return this.#r(0)}get bold(){return this.#r(1)}get disableFontFace(){return this.#r(2)}get fontExtraProperties(){return this.#r(3)}get isInvalidPDFjsFont(){return this.#r(4)}get isType3Font(){return this.#r(5)}get italic(){return this.#r(6)}get missingFile(){return this.#r(7)}get remeasure(){return this.#r(8)}get vertical(){return this.#r(9)}#i(e){return D(e0){t=n.slice();for(let e=0,n=l.length;etypeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,Vt=fe.bind(null,Bt,e=>typeof e==`object`&&typeof e?.name==`string`),Ht=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){T("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},Ut={DATA:1,ERROR:2},q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Wt(){}function J(e){if(e instanceof P||e instanceof ne||e instanceof ee||e instanceof re||e instanceof te)return e;switch(e instanceof Error||typeof e==`object`&&e||E(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new P(e.message);case`InvalidPDFException`:return new ne(e.message);case`PasswordException`:return new ee(e.message,e.code);case`ResponseException`:return new re(e.message,e.status,e.missing);case`UnknownErrorException`:return new te(e.message,e.details)}return new te(e.message,e.toString())}var Gt=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Ut.DATA)n.resolve(e.data);else if(e.callback===Ut.ERROR)n.reject(J(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:Ut.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:Ut.ERROR,callbackId:e.callbackId,reason:J(t)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:q.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{D(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:q.CANCEL,streamId:i,reason:J(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:q.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){D(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.ERROR,streamId:t,reason:J(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,reason:J(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case q.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(J(e.reason));break;case q.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(J(e.reason));break;case q.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Wt).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,reason:J(e)})});break;case q.ENQUEUE:if(D(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case q.CLOSE:if(D(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case q.ERROR:D(a,`error should have stream controller`),a.controller.error(J(e.reason)),this.#i(a,t);break;case q.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(J(e.reason)),this.#i(a,t);break;case q.CANCEL:if(!o)break;let s=J(e.reason);Promise.try(o.onCancel||Wt,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,reason:J(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}},Kt=class{#e=Object.freeze({cMapUrl:`CMap`,standardFontDataUrl:`font`,wasmUrl:`wasm`});constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:n=null}){this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=n}async fetch({kind:e,filename:t}){switch(e){case`cMapUrl`:case`standardFontDataUrl`:case`wasmUrl`:break;default:E(`Not implemented: ${e}`)}let n=this[e];if(!n)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let r=`${n}${t}`;return this._fetch(r,e).catch(t=>{throw Error(`Unable to load ${this.#e[e]} data at: ${r}`)})}async _fetch(e,t){E("Abstract method `_fetch` called.")}},qt=class extends Kt{async _fetch(e,t){let n=await Ce(e,t===`cMapUrl`&&!e.endsWith(`.bcmap`)?`text`:`bytes`);return n instanceof Uint8Array?n:oe(n)}},Jt=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset({canvas:e},t,n){if(!e)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.width=t,e.height=n}destroy(e){let{canvas:t}=e;if(!t)throw Error(`Canvas is not specified`);t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){E("Abstract method `_createCanvas` called.")}},Yt=class extends Jt{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},Xt=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addKnockoutFilter(e=0){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}addSelectionHCMFilter(e,t){return`none`}addSelectionFilter(){return`none`}createSelectionStyle(e=null){return null}destroy(e=!1){}},Zt=class extends Xt{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=new Map}get#c(){return this.#a||=new Map}get#l(){if(!this.#n){let e=this.#i.createElement(`div`),{style:t}=e;t.colorScheme=`only light`,t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=this.#i.createElementNS(a,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(a,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&(Te(e)?T(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=A(e,``))}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=I.makeHexColor(...a);let o=this.#v(t);if(t=I.makeHexColor(...o),this.#b(),e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array(256);for(let e=0;e<=255;e++){let t=e/255;s[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let c=s.join(`,`),l=`g_${this.#r}_hcm_filter`,u=i.filter=this.#m(l);this.#g(c,c,c,u),this.#p(u);let d=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(d(0,5),d(1,5),d(2,5),u),i.url=this.#d(l),i.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter(`selection`,e,t,`HighlightText`,`Highlight`)}addSelectionFilter(){return this.addHighlightHCMFilter(`selection_default`,`black`,`white`,`HighlightText`,`Highlight`)}createSelectionStyle(e=null){let t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return t===`none`||!F.platform.isFirefox?null:{"backdrop-filter":t,"background-color":`transparent`}}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addKnockoutFilter(e=0){let t=e>0?Math.min(1/e,1e6):1e6,n=`knockout_${t}`,r=this.#s.get(n);if(r)return r;let i=`g_${this.#r}_knockout_filter_${this.#o++}`,o=this.#d(i);this.#s.set(n,o);let s=this.#m(i),c=this.#i.createElementNS(a,`feComponentTransfer`);s.append(c);let l=this.#i.createElementNS(a,`feFuncA`);return l.setAttribute(`type`,`linear`),l.setAttribute(`slope`,`${t}`),l.setAttribute(`intercept`,`0`),c.append(l),o}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#x.bind(this));u{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(a,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0`),e.append(t)}#p(e){let t=this.#i.createElementNS(a,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0`),e.append(t)}#m(e){let t=this.#i.createElementNS(a,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(a,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(a,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(a,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,Ne(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#y(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,Me(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#b(){this.#l.style.color=``,this.#l.style.backgroundColor=``}#x(e){let[t,n,r,i]=this.#y(e);if(i===1)return[t,n,r];let[a,o,s]=this.#v(`Canvas`);return[Qt(t,a,i),Qt(n,o,i),Qt(r,s,i)]}};function Qt(e,t,n){return Math.round(n*e+(1-n)*t)}t&&T("Please use the `legacy` build in Node.js environments.");async function $t(e){let t=await process.getBuiltinModule(`fs/promises`).readFile(e);return new Uint8Array(t)}var en=class extends Xt{},tn=class extends Jt{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire(import.meta.url)(`@napi-rs/canvas`).createCanvas(e,t)}},nn=class extends Kt{async _fetch(e,t){return $t(e)}};function rn({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=F.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=c^l,p=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r>7&1)&f,n[m+1]=c^-(r>>6&1)&f,n[m+2]=c^-(r>>5&1)&f,n[m+3]=c^-(r>>4&1)&f,n[m+4]=c^-(r>>3&1)&f,n[m+5]=c^-(r>>2&1)&f,n[m+6]=c^-(r>>1&1)&f,n[m+7]=c^-(r&1)&f}if(d===0)continue;let r=t>7-e&1)&f}return{srcPos:t,destPos:m}}function an({src:e,srcPos:t=0,dest:n,destPos:r=0,width:i,height:a}){let o=0,s=i*a*3,c=s>>2,l=new Uint32Array(e.buffer,t,c),u=F.isLittleEndian?4278190080:255;if(F.isLittleEndian){for(;o>>24|t<<8|u,n[r+2]=t>>>16|i<<16|u,n[r+3]=i>>>8|u}for(let i=o*4,a=t+s;i>>8|u,n[r+2]=t<<16|i>>>16|u,n[r+3]=i<<8|u}for(let i=o*4,a=t+s;i - + diff --git a/tests/core/test_copilot_parser_refusal.py b/tests/core/test_copilot_parser_refusal.py new file mode 100644 index 000000000..7c69c3a7b --- /dev/null +++ b/tests/core/test_copilot_parser_refusal.py @@ -0,0 +1,131 @@ +"""Issue #113: only trusted, unmetered top-level parser refusals are free.""" +import json +import time + +import pytest + +from argus_skill.core.cost_control import cost_control_snapshot, reserve_call_budget +from argus_skill.core.usage import UsageLedger, UsageRecord, build_usage_record + +ERROR = ("Process exited with code 1 before turn completion.\n" + "error: unknown option '--context'\n(Did you mean --connect?)\n\n" + "Try 'copilot --help' for more information.") + + +def row(): + return dict(call_id="parser-call", project_id="p1", provider="copilot", + model="gpt-6-astra", run_label="manager-classify-grounded-retry", + started_at=time.time()-2, completed_at=time.time()-1, + status="error", source="run_exec", error=ERROR, + cost_usd=None, pricing_status="partial", thread_id=None) + + +def receipt(): + return dict(type="agent.io.complete", call_id="parser-call", backend="copilot", + run_label="manager-classify-grounded-retry", exit_code=1, + thread_id=None, turn_completed=False, turn_failed=True, + fatal_error="Process exited with code 1 before turn completion.", + tool_activity_observed=False, agent_message_count=0, + stdout_line_count=0, json_event_count=0, + command=["/usr/bin/copilot", "--context", "default"]) + + +def project(tmp_path, r=None, event=None): + p = tmp_path / "projects" / "p1" + p.mkdir(parents=True) + (p / "usage.jsonl").write_text(json.dumps(r or row()) + "\n") + (p / "events.jsonl").write_text(json.dumps(event or receipt()) + "\n") + return p + + +def test_historical_projection_is_idempotent_and_preserves_ledger(tmp_path): + p = project(tmp_path) + before = (p / "usage.jsonl").read_bytes() + for _ in range(2): + record = UsageLedger(p, migrate_legacy=False).records()[0] + assert (record.pricing_status, record.cost_usd) == ("not_billed", 0) + assert (p / "usage.jsonl").read_bytes() == before + + +def test_identical_text_without_receipt_is_not_evidence(): + assert UsageRecord.from_jsonable(row()).pricing_status == "partial" + + +@pytest.mark.parametrize("change", [ + {"agent_message_count": 1}, {"stdout_line_count": 1}, {"json_event_count": 1}, + {"tool_activity_observed": True}, {"turn_completed": True}, + {"thread_id": "session"}, {"exit_code": 0}, {"backend": "codex"}, + {"call_id": "other"}, {"command": ["copilot", "--prompt", "--context"]}, +]) +def test_untrusted_or_post_start_receipt_does_not_convert(tmp_path, change): + p = project(tmp_path, event={**receipt(), **change}) + assert UsageLedger(p, migrate_legacy=False).records()[0].pricing_status == "partial" + + +@pytest.mark.parametrize("change", [ + {"input_tokens": 0}, {"input_tokens": 9}, {"cached_input_tokens": 1}, + {"cache_write_tokens": 1}, {"output_tokens": 1}, {"reasoning_output_tokens": 1}, + {"premium_requests": 1}, {"premium_requests": 0}, {"total_nano_aiu": 0}, + {"model_usage": [{"input_tokens": 1}]}, {"cost_usd": .1}, + {"premium_request_cost_usd": .04}, {"thread_id": "session"}, + {"source": "legacy.events"}, {"status": "completed"}, +]) +def test_any_observed_usage_or_inconsistent_row_is_preserved(tmp_path, change): + p = project(tmp_path, r={**row(), **change}) + record = UsageLedger(p, migrate_legacy=False).records()[0] + assert record.pricing_status == "partial" + assert record.cost_usd == change.get("cost_usd") + + +@pytest.mark.parametrize("error", ["network timeout", "unknown failure", "", + "Tool said: " + ERROR, ERROR + "\nmodel output"]) +def test_unknown_network_and_quoted_text_still_block(tmp_path, error): + project(tmp_path, r={**row(), "error": error}) + snap = cost_control_snapshot(global_root=tmp_path) + assert snap["unresolved_calls"] == 1 + + +def test_cross_project_admission_releases_only_parser_item(tmp_path): + p = project(tmp_path) + p2 = tmp_path / "projects" / "p2" + p2.mkdir() + for target in (p, p2): + reservation, reason = reserve_call_budget( + call_id="probe-" + target.name, project_root=target, mission_id=None, + provider="copilot", model="gpt-6-astra", run_label="test", + global_root=tmp_path) + assert reservation is not None, reason + reservation.release(reason="test complete") + unknown = {**row(), "call_id": "unknown", "error": "network timeout"} + (p2 / "usage.jsonl").write_text(json.dumps(unknown) + "\n") + assert cost_control_snapshot(global_root=tmp_path)["unresolved_calls"] == 1 + + +def test_new_failure_uses_the_same_trusted_receipt(tmp_path): + r = row() + record = build_usage_record( + call_id=r["call_id"], project_root=tmp_path, mission_id=None, + provider="copilot", model=r["model"], run_label=r["run_label"], + started_at=r["started_at"], completed_at=r["completed_at"], status="error", + error=ERROR, startup_receipt=receipt()) + assert (record.pricing_status, record.cost_usd) == ("not_billed", 0) + + +def test_duplicate_or_missing_completion_receipt_fails_closed(tmp_path): + p = project(tmp_path) + path = p / "events.jsonl" + original = path.read_text() + for text in ("", original + original): + path.write_text(text) + assert UsageLedger(p, migrate_legacy=False).records()[0].pricing_status == "partial" + + +@pytest.mark.parametrize("field", ["premium_requests", "total_nano_aiu", "provider_cost_usd"]) +def test_new_failure_retains_observed_metering(tmp_path, field): + r = row() + record = build_usage_record( + call_id=r["call_id"], project_root=tmp_path, mission_id=None, + provider="copilot", model=r["model"], run_label=r["run_label"], + started_at=r["started_at"], completed_at=r["completed_at"], status="error", + error=ERROR, startup_receipt=receipt(), **{field: 1}) + assert record.pricing_status != "not_billed" diff --git a/tests/test_agent_cli_backend.py b/tests/test_agent_cli_backend.py index 6eb3af675..d5fab9ece 100644 --- a/tests/test_agent_cli_backend.py +++ b/tests/test_agent_cli_backend.py @@ -2434,3 +2434,38 @@ def test_build_backend_default_does_not_reuse_persisted_dsh_runner( assert build_agent_cli_backend_from_env() is captured assert captured["backend"] == "codex" assert captured["runner_bin"] is None + + +@pytest.mark.parametrize("observed", [False, True]) +def test_context_parser_failure_uses_trusted_completion_receipt(tmp_path, monkeypatch, observed): + root = tmp_path / "home" + project = root / "projects" / "p1" + monkeypatch.setenv("ARGUS_SKILL_HOME", str(root)) + monkeypatch.setenv("ARGUS_SKILL_COST_CONTROL", "1") + monkeypatch.setenv("ARGUS_SKILL_UNPRICED_COST_POLICY", "block") + monkeypatch.setenv("ARGUS_SKILL_COPILOT_GUARD", "0") + monkeypatch.setattr( + "argus_skill.adapters.agent_cli_backend._exec_spawn.capture_copilot_usage_cursor", + lambda: None, + ) + monkeypatch.setattr( + "argus_skill.adapters.agent_cli_backend._exec_spawn.read_copilot_usage_since", + lambda *args, **kwargs: None, + ) + backend = AgentCliBackend(backend="copilot") + backend.set_usage_context(project_root=project, mission_id="mission-1") + + def fake_run_exec(self, **kwargs): + return _make_cli_result( + command=["copilot", "--context", "default"], exit_code=1, + thread_id=None, fatal_error="Process exited with code 1 before turn completion.", + stderr_lines=["error: unknown option '--context'", "(Did you mean --connect?)", + "", "Try 'copilot --help' for more information."], + stdout_lines=["model/tool output"] if observed else [], + ) + + monkeypatch.setattr(backend._runner.__class__, "run_exec", fake_run_exec) + result = backend.run_exec(prompt="test", options=RunnerOptions(model="gpt-6-astra"), + run_label="manager-classify-grounded-retry") + assert result.pricing_status == ("partial" if observed else "not_billed") + assert result.cost_usd == (None if observed else 0.0)