@xopcai/xopc 0.0.243 → 0.0.244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDH4HgP7.js → agent-avatar-dicebear-BhXGsupm.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BDCfJZhh.js → agent-defaults-settings-panel-Blzn2H6t.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-B0ZWgf-U.js → agents-Cmp-z8Y_.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-Blfwszzn.js → app-management-settings-panel-CezjAP1K.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-C3V7Na75.js → appearance-settings-C-CfS05x.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-BiEks0-F.js → apps-page-7Y13_bqZ.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-BS-S4LJ9.js → attachment-load-DI4CoIga.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-C7Y3L30D.js → automations-page-D04Xceck.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-workspace-A3zPkPuo.js → automations-workspace-wEO1OWk0.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-BM9B5kcm.js → binary-plugins-BJQe8TRu.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-BbnpkYP9.js → block-editor-BSzGjJC6.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-settings-page-Dk4FQ7fY.js → browser-settings-page-DjAZ_LF2.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-workflows-page-B9qGL-it.js → browser-workflows-page-CwbxA3B7.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capabilities-settings-panel--tR_El9e.js → capabilities-settings-panel-jt9bqUMK.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channels-settings-D347vl_J.js → channels-settings-Cz_TWY3a.js} +1 -1
  18. package/dist/gateway/static/root/assets/{chat-terminal-dock-DABPvwBT.js → chat-terminal-dock-D3gj2D3U.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-page-B-tvJkRJ.js → connectors-page-Shs5vbzx.js} +1 -1
  20. package/dist/gateway/static/root/assets/{cron-expression-D3bsKbNd.js → cron-expression-DgWHw0jX.js} +1 -1
  21. package/dist/gateway/static/root/assets/{date-picker-BsGM6Yty.js → date-picker-CKg-RPbs.js} +1 -1
  22. package/dist/gateway/static/root/assets/{dependency-picker-Dj3g6YXZ.js → dependency-picker-CVYkw-NN.js} +1 -1
  23. package/dist/gateway/static/root/assets/{desktop-pet-C1QT0Sur.js → desktop-pet-Bf46oXTY.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-settings-r6kAOnfY.js → desktop-pet-settings-BJO_klc7.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-debug-page-DOkf7nh9.js → extension-debug-page-T2PmFFOW.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-Cq2IA4Ho.js → extension-page-2wAE2RCe.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-DQn4qjDZ.js → extension-settings-page-Y9ZiCJ21.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-DM3poL22.js → gateway-config-api-DaYY1Gkn.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-settings-DPgH1hnh.js → gateway-settings-eO3IzW_J.js} +1 -1
  30. package/dist/gateway/static/root/assets/{heartbeat-settings-Bk80-E3b.js → heartbeat-settings-BAgrkyHc.js} +1 -1
  31. package/dist/gateway/static/root/assets/{home-page-DKo5JiMR.js → home-page-GTjKH7LK.js} +1 -1
  32. package/dist/gateway/static/root/assets/{index-B0WJL9N1.js → index-DUz0O54y.js} +8 -8
  33. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BEwvd8ZU.js → keyboard-shortcuts-settings-CWGqL6o5.js} +1 -1
  34. package/dist/gateway/static/root/assets/{local-app-workbench-page--eJ5rmNj.js → local-app-workbench-page-DKJ-rks0.js} +1 -1
  35. package/dist/gateway/static/root/assets/{local-apps-page-CgkY9E-r.js → local-apps-page-Bfidv29d.js} +1 -1
  36. package/dist/gateway/static/root/assets/{logs-page-Z49Td0J9.js → logs-page-DwAHrPbF.js} +1 -1
  37. package/dist/gateway/static/root/assets/{management-settings-Dv8NSJKt.js → management-settings-BG7j1I9f.js} +1 -1
  38. package/dist/gateway/static/root/assets/{markdown-split-Cm0RBB-t.js → markdown-split-AnmmpLs6.js} +1 -1
  39. package/dist/gateway/static/root/assets/{media-plugins-Bcr5sU1f.js → media-plugins-CGS-05cE.js} +1 -1
  40. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-kKDiXofY.js → mobile-pairing-wizard-DoKK5GfV.js} +1 -1
  41. package/dist/gateway/static/root/assets/{notes-page-CgsaRaGi.js → notes-page-Lr8rsFAR.js} +1 -1
  42. package/dist/gateway/static/root/assets/{notes-workbench-C1DEE09k.js → notes-workbench-ISWnKLxO.js} +2 -2
  43. package/dist/gateway/static/root/assets/{project-detail-page-isRapnp5.js → project-detail-page-BZqr4yam.js} +1 -1
  44. package/dist/gateway/static/root/assets/{projects-page-zvsjg0mi.js → projects-page-Dau8733A.js} +1 -1
  45. package/dist/gateway/static/root/assets/{remote-access-hub-C9TGZ9Hc.js → remote-access-hub-DdChlvGP.js} +1 -1
  46. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-2zm9edMA.js → runtime-tools-settings-panel-CmZTNv1W.js} +1 -1
  47. package/dist/gateway/static/root/assets/{schema-form-54A5gzkN.js → schema-form-XlVPyiVQ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{sessions-page-BP8RyiUn.js → sessions-page-C3kADsd4.js} +1 -1
  49. package/dist/gateway/static/root/assets/settings-advanced-gate-CSYy6SUa.js +1 -0
  50. package/dist/gateway/static/root/assets/{settings-page-DzDhoyxv.js → settings-page-DblUeM3V.js} +1 -1
  51. package/dist/gateway/static/root/assets/{setup-status-panel-uDicHU1w.js → setup-status-panel-bDfRfSnq.js} +1 -1
  52. package/dist/gateway/static/root/assets/{share-preview-page-lOmLCWFS.js → share-preview-page-DBMWFMN-.js} +1 -1
  53. package/dist/gateway/static/root/assets/{shares-settings-T4Yvouvv.js → shares-settings-Bu6lIStj.js} +1 -1
  54. package/dist/gateway/static/root/assets/{skill-reload-api-DVb7nrXz.js → skill-reload-api-BNMc4l04.js} +1 -1
  55. package/dist/gateway/static/root/assets/{skills-page-CnyNH3To.js → skills-page-CSOseeQe.js} +1 -1
  56. package/dist/gateway/static/root/assets/{skills-page.utils-CgDtf2qs.js → skills-page.utils-CniRGhkJ.js} +1 -1
  57. package/dist/gateway/static/root/assets/{system-settings-panel-C8yWfwtR.js → system-settings-panel-D0GqNpKy.js} +1 -1
  58. package/dist/gateway/static/root/assets/{task-detail-page-Tzfjlbf3.js → task-detail-page-BRCq-nR7.js} +1 -1
  59. package/dist/gateway/static/root/assets/{tunnel-api-Bvg679no.js → tunnel-api-BtjS2nrM.js} +1 -1
  60. package/dist/gateway/static/root/assets/{use-autosave-D88VGoyG.js → use-autosave-TwuAycG8.js} +1 -1
  61. package/dist/gateway/static/root/assets/{user-context-page-RijPtyfO.js → user-context-page-CbqPu8xZ.js} +1 -1
  62. package/dist/gateway/static/root/assets/{voice-api-key-field-CBHLsMcc.js → voice-api-key-field-CzwG5plu.js} +1 -1
  63. package/dist/gateway/static/root/assets/{work-discovery-overlay-GGe2TQ98.js → work-discovery-overlay-DS15FzQA.js} +1 -1
  64. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C0layUE9.js → workflow-run-setup-panel-C_boCemi.js} +1 -1
  65. package/dist/gateway/static/root/assets/{workflows-page-DQXIzBAc.js → workflows-page-CaI2ruyy.js} +1 -1
  66. package/dist/gateway/static/root/index.html +1 -1
  67. package/dist/package.js +1 -1
  68. package/dist/src/agent/agent-manager.js +4 -4
  69. package/dist/src/agent/background-review/run-background-review.js +1 -1
  70. package/dist/src/agent/embedded/model-runtime.js +1 -1
  71. package/dist/src/agent/embedded/run-for-session.js +1 -1
  72. package/dist/src/agent/image/tool-model-config.js +1 -1
  73. package/dist/src/agent/ipc/inbox.js +1 -1
  74. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  75. package/dist/src/agent/service.js +2 -2
  76. package/dist/src/agent/session/session-inspector.js +1 -1
  77. package/dist/src/agent/skills/hub-lock.js +1 -1
  78. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  79. package/dist/src/ai-assist/text-assist.js +1 -1
  80. package/dist/src/auth/credentials.js +2 -2
  81. package/dist/src/auth/profiles/store.js +1 -1
  82. package/dist/src/auth/sync-provider-auth.js +2 -2
  83. package/dist/src/automations/draft/automation-draft-service.js +1 -1
  84. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  85. package/dist/src/cli/commands/agent.js +2 -2
  86. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  87. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  88. package/dist/src/cli/commands/models.js +2 -2
  89. package/dist/src/cli/commands/onboard.js +1 -1
  90. package/dist/src/cli/commands/profile.js +1 -1
  91. package/dist/src/cli/commands/tunnel.js +1 -1
  92. package/dist/src/cli/commands/update.js +1 -1
  93. package/dist/src/cli/extension-cli-register.js +1 -1
  94. package/dist/src/config/index.js +5 -5
  95. package/dist/src/config/loader.js +1 -1
  96. package/dist/src/config/models-json.js +1 -1
  97. package/dist/src/extensions/lockfile.js +1 -1
  98. package/dist/src/gateway/agents-admin.js +1 -1
  99. package/dist/src/gateway/file-path-classifier.js +1 -1
  100. package/dist/src/gateway/heartbeat/service.js +1 -1
  101. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  102. package/dist/src/gateway/hono/routes/connectors.js +23 -23
  103. package/dist/src/gateway/hono/routes/models.js +1 -1
  104. package/dist/src/gateway/hono/routes/sessions.js +1 -1
  105. package/dist/src/gateway/run-loop.js +1 -1
  106. package/dist/src/gateway/service/config-coordinator.js +1 -1
  107. package/dist/src/gateway/service.js +6 -6
  108. package/dist/src/heartbeat/index.js +1 -1
  109. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  110. package/dist/src/providers/index.js +2 -2
  111. package/dist/src/providers/model-registry.js +1 -1
  112. package/dist/src/providers/register-runtime-providers.js +1 -1
  113. package/dist/src/share/hosted-session-share.js +1 -1
  114. package/dist/src/tui/tui-startup-resources.js +1 -1
  115. package/dist/src/tui/tui.js +1 -1
  116. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  117. package/package.json +3 -3
  118. package/dist/gateway/static/root/assets/settings-advanced-gate-D4EMxWAZ.js +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{m as u,t as d,u as f}from"./markdown-view-PPCLt7fu.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./pencil-DmIY3Oa-.js";import{t as h}from"./copy-to-clipboard-HOJ79TWv.js";import{t as g}from"./messages-CTSgFlE4.js";import{n as _}from"./locale-store-CMZljTJx.js";import{t as v}from"./cn-JdwAhgNB.js";import{s as y}from"./vendor-swr-BIWyz7Rc.js";import{a as b,d as x,i as S,l as C,n as w,o as T,s as E,t as D,u as O}from"./floating-ui.dom-B7uQOZZW.js";import{$c as ee,Ac as te,An as k,Cs as ne,Hc as re,Hn as ie,Jl as ae,Kc as oe,Mn as se,Nc as ce,Nn as le,Oc as ue,Qc as de,Rn as fe,Zc as pe,cc as me,jc as he,js as ge,nc as _e,pc as ve,tc as ye,vl as be,ws as xe,xc as Se}from"./index-B0WJL9N1.js";import{C as Ce,S as we}from"./vendor-codemirror--gTq3YAI.js";import{t as Te}from"./with-selector-aYPsXwdl.js";import{n as Ee}from"./notes-workbench-C1DEE09k.js";var A=e(r(),1),De=e(i(),1),j=o(),Oe=y();function M(e){this.content=e}M.prototype={constructor:M,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new M(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new M(n)},addToStart:function(e,t){return new M([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new M(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new M(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=M.from(e),e.size?new M(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=M.from(e),e.size?new M(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=M.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},M.from=function(e){if(e instanceof M)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new M(t)};function ke(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Me(e.charCodeAt(r-1))&&je(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=ke(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Ae(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Me(e.charCodeAt(i-1))&&je(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Ae(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function je(e){return e>=56320&&e<57344}function Me(e){return e>=55296&&e<56320}var N=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return ke(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ae(this,e,t,n)}findIndex(e){if(e==0)return Pe(0,e);if(e==this.size)return Pe(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Pe(t+1,i):Pe(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};N.empty=new N([],0);var Ne={index:0,offset:0};function Pe(e,t){return Ne.index=e,Ne.offset=t,Ne}function Fe(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Fe(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Fe(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var P=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fe(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};P.none=[];var Ie=class extends Error{},F=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Re(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Le(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(N.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};F.empty=new F(N.empty,0,0);function Le(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Le(a.content,t-i-1,n-i-1)))}function Re(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Re(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function ze(e,t,n){if(n.openStart>e.depth)throw new Ie(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ie(`Inconsistent open depths`);return Be(e,t,n,0)}function Be(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Be(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Ge(a,qe(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Ge(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Je(n,e);return Ge(a,Ke(e,i,o,t,r))}}function Ve(e,t){if(!t.type.compatibleContent(e.type))throw new Ie(`Cannot join `+t.type.name+` onto `+e.type.name)}function He(e,t,n){let r=e.node(n);return Ve(r,t.node(n)),r}function Ue(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function We(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ue(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ue(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ue(t.nodeBefore,r)}function Ge(e,t){if(!e.type.validContent(t))throw new Ie(`Invalid content for node `+e.type.name);return e.copy(t)}function Ke(e,t,n,r,i){let a=e.depth>i&&He(e,t,i+1),o=r.depth>i&&He(n,r,i+1),s=[];return We(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Ve(a,o),Ue(Ge(a,Ke(e,t,n,r,i+1)),s)):(a&&Ue(Ge(a,qe(e,t,i+1)),s),We(t,n,i,s),o&&Ue(Ge(o,qe(n,r,i+1)),s)),We(r,null,i,s),new N(s)}function qe(e,t,n){let r=[];return We(null,e,n,r),e.depth>n&&Ue(Ge(He(e,t,n+1),qe(e,t,n+1)),r),We(t,null,n,r),new N(r)}function Je(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(N.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ye=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return P.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new $e(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Qe.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Qe.set(t,r=new Xe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Ze,i}},Xe=class{constructor(){this.elts=[],this.i=0}},Ze=12,Qe=new WeakMap,$e=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},et=Object.create(null),tt=class e{constructor(e,t,n,r=P.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||N.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Fe(this.attrs,t||e.defaultAttrs||et)&&P.sameSet(this.marks,n||P.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return F.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new F(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return ze(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ye.resolveCached(this,e)}resolveNoCache(e){return Ye.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),rt(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=N.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=P.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!P.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=N.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};tt.prototype.text=void 0;var nt=class e extends tt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function rt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var it=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new at(t,n);if(r.next==null)return e.empty;let i=ot(r);r.next&&r.err(`Unexpected trailing text`);let a=gt(pt(i));return _t(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return N.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{m as u,t as d,u as f}from"./markdown-view-PPCLt7fu.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./pencil-DmIY3Oa-.js";import{t as h}from"./copy-to-clipboard-HOJ79TWv.js";import{t as g}from"./messages-CTSgFlE4.js";import{n as _}from"./locale-store-CMZljTJx.js";import{t as v}from"./cn-JdwAhgNB.js";import{s as y}from"./vendor-swr-BIWyz7Rc.js";import{a as b,d as x,i as S,l as C,n as w,o as T,s as E,t as D,u as O}from"./floating-ui.dom-B7uQOZZW.js";import{$c as ee,Ac as te,An as k,Cs as ne,Hc as re,Hn as ie,Jl as ae,Kc as oe,Mn as se,Nc as ce,Nn as le,Oc as ue,Qc as de,Rn as fe,Zc as pe,cc as me,jc as he,js as ge,nc as _e,pc as ve,tc as ye,vl as be,ws as xe,xc as Se}from"./index-DUz0O54y.js";import{C as Ce,S as we}from"./vendor-codemirror--gTq3YAI.js";import{t as Te}from"./with-selector-aYPsXwdl.js";import{n as Ee}from"./notes-workbench-ISWnKLxO.js";var A=e(r(),1),De=e(i(),1),j=o(),Oe=y();function M(e){this.content=e}M.prototype={constructor:M,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new M(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new M(n)},addToStart:function(e,t){return new M([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new M(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new M(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=M.from(e),e.size?new M(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=M.from(e),e.size?new M(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=M.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},M.from=function(e){if(e instanceof M)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new M(t)};function ke(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Me(e.charCodeAt(r-1))&&je(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=ke(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Ae(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Me(e.charCodeAt(i-1))&&je(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Ae(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function je(e){return e>=56320&&e<57344}function Me(e){return e>=55296&&e<56320}var N=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return ke(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ae(this,e,t,n)}findIndex(e){if(e==0)return Pe(0,e);if(e==this.size)return Pe(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Pe(t+1,i):Pe(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};N.empty=new N([],0);var Ne={index:0,offset:0};function Pe(e,t){return Ne.index=e,Ne.offset=t,Ne}function Fe(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Fe(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Fe(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var P=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fe(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};P.none=[];var Ie=class extends Error{},F=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Re(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Le(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(N.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};F.empty=new F(N.empty,0,0);function Le(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Le(a.content,t-i-1,n-i-1)))}function Re(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Re(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function ze(e,t,n){if(n.openStart>e.depth)throw new Ie(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ie(`Inconsistent open depths`);return Be(e,t,n,0)}function Be(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Be(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Ge(a,qe(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Ge(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Je(n,e);return Ge(a,Ke(e,i,o,t,r))}}function Ve(e,t){if(!t.type.compatibleContent(e.type))throw new Ie(`Cannot join `+t.type.name+` onto `+e.type.name)}function He(e,t,n){let r=e.node(n);return Ve(r,t.node(n)),r}function Ue(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function We(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ue(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ue(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ue(t.nodeBefore,r)}function Ge(e,t){if(!e.type.validContent(t))throw new Ie(`Invalid content for node `+e.type.name);return e.copy(t)}function Ke(e,t,n,r,i){let a=e.depth>i&&He(e,t,i+1),o=r.depth>i&&He(n,r,i+1),s=[];return We(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Ve(a,o),Ue(Ge(a,Ke(e,t,n,r,i+1)),s)):(a&&Ue(Ge(a,qe(e,t,i+1)),s),We(t,n,i,s),o&&Ue(Ge(o,qe(n,r,i+1)),s)),We(r,null,i,s),new N(s)}function qe(e,t,n){let r=[];return We(null,e,n,r),e.depth>n&&Ue(Ge(He(e,t,n+1),qe(e,t,n+1)),r),We(t,null,n,r),new N(r)}function Je(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(N.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ye=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return P.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new $e(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Qe.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Qe.set(t,r=new Xe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Ze,i}},Xe=class{constructor(){this.elts=[],this.i=0}},Ze=12,Qe=new WeakMap,$e=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},et=Object.create(null),tt=class e{constructor(e,t,n,r=P.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||N.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Fe(this.attrs,t||e.defaultAttrs||et)&&P.sameSet(this.marks,n||P.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return F.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new F(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return ze(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ye.resolveCached(this,e)}resolveNoCache(e){return Ye.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),rt(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=N.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=P.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!P.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=N.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};tt.prototype.text=void 0;var nt=class e extends tt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function rt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var it=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new at(t,n);if(r.next==null)return e.empty;let i=ot(r);r.next&&r.err(`Unexpected trailing text`);let a=gt(pt(i));return _t(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return N.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
2
2
  `)}};it.empty=new it(!0);var at=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ot(e){let t=[];do t.push(st(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function st(e){let t=[];do t.push(ct(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ct(e){let t=ft(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ut(e,t);else break;return t}function lt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ut(e,t){let n=lt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:lt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function dt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function ft(e){if(e.eat(`(`)){let t=ot(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=dt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function pt(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function mt(e,t){return t-e}function ht(e,t){let n=[];return r(t),n.sort(mt);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function gt(e){let t=Object.create(null);return n(ht(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);ht(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new it(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(mt);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function _t(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function vt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function yt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function bt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function xt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new wt(e,r,t[r]);return n}var St=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=xt(e,n.attrs),this.defaultAttrs=vt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==it.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:yt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new tt(this,this.computeAttrs(e),N.from(t),P.setFrom(n))}createChecked(e=null,t,n){return t=N.from(t),this.checkContent(t),new tt(this,this.computeAttrs(e),t,P.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=N.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(N.empty,!0);return i?new tt(this,e,t.append(i),P.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){bt(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:P.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Ct(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var wt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Ct(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Tt=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=xt(e,r.attrs),this.excluded=null;let i=vt(this.attrs);this.instance=i?new P(this,i):null}create(e=null){return!e&&this.instance?this.instance:new P(this,yt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){bt(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Et=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=M.from(e.nodes),t.marks=M.from(e.marks||{}),this.nodes=St.compile(this.spec.nodes,this),this.marks=Tt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=it.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Dt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Dt(this,n.split(` `))}this.nodeFromJSON=e=>tt.fromJSON(this,e),this.markFromJSON=e=>P.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof St))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new nt(n,n.defaultAttrs,e,P.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Dt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Ot(e){return e.tag!=null}function kt(e){return e.style!=null}var At=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Ot(e))this.tags.push(e);else if(kt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new zt(this,t,!1);return n.addAll(e,P.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new zt(this,t,!0);return n.addAll(e,P.none,t.from,t.to),F.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Vt(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Ht(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Ht(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},jt={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Mt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Nt={ol:!0,ul:!0},Pt=1,Ft=2,It=4;function Lt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Pt:0)|(t===`full`?Ft:0)}var Rt=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=P.none,this.match=i||(a&It?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(N.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Pt)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=N.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(N.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!jt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},zt=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Lt(null,t.preserveWhitespace,0)|(n?It:0);i=r?new Rt(r.type,r.attrs,P.none,!0,t.topMatch||r.type.contentMatch,a):n?new Rt(null,null,P.none,!0,null,a):new Rt(e.schema.topNodeType,null,P.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Ft?`full`:this.localPreserveWS||(r.options&Pt)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
3
3
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Nt.hasOwnProperty(a)&&this.parser.normalizeLists&&Bt(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Mt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(jt.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=P.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Ut(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Lt(e,i,a.options);a.options&It&&a.content.length==0&&(o|=It);let s=P.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Ut(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new Rt(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Pt);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Bt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Nt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Vt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ht(e){let t={};for(let n in e)t[n]=e[n];return t}function Ut(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Wt=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Kt(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Kt(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Xt(Kt(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Xt(Kt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Xt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Gt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Gt(e.marks)}};function Gt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Kt(e){return e.document||window.document}var qt=new WeakMap;function Jt(e){let t=qt.get(e);return t===void 0&&qt.set(e,t=Yt(e)),t}function Yt(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Xt(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Jt(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Xt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Zt=65535,Qt=2**16;function $t(e,t){return e+t*Qt}function en(e){return e&Zt}function tn(e){return(e-(e&Zt))/Qt}var nn=1,rn=2,an=4,on=8,sn=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&on)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&an)>0}},cn=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=en(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+tn(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:$t(o/3,e-s),f=e==s?rn:e==u?nn:an;return(t<0?e!=s:e!=u)&&(f|=on),new sn(a,f,d)}r+=l-c}return n?e+r:new sn(e+r,0,null)}touches(e,t){let n=0,r=en(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};cn.empty=new cn([]);var ln=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new sn(e,r,null)}},un=Object.create(null),dn=class{getMap(){return cn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=un[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in un)throw RangeError(`Duplicate use of step JSON ID `+e);return un[e]=t,t.prototype.jsonID=e,t}},fn=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Ie)return e.fail(t.message);throw t}}};function pn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(pn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return N.fromArray(r)}var mn=class e extends dn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new F(pn(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return fn.fromReplace(e,this.from,this.to,i)}invert(){return new hn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};dn.jsonID(`addMark`,mn);var hn=class e extends dn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new F(pn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return fn.fromReplace(e,this.from,this.to,n)}invert(){return new mn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};dn.jsonID(`removeMark`,hn);var gn=class e extends dn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return fn.fromReplace(e,this.pos,this.pos+1,new F(N.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new _n(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};dn.jsonID(`addNodeMark`,gn);var _n=class e extends dn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return fn.fromReplace(e,this.pos,this.pos+1,new F(N.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new gn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};dn.jsonID(`removeNodeMark`,_n);var vn=class e extends dn{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&bn(e,this.from,this.to)?fn.fail(`Structure replace would overwrite content`):fn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new cn([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?F.empty:new F(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?F.empty:new F(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,F.fromJSON(t,n.slice),!!n.structure)}};vn.MAP_BIAS=1,dn.jsonID(`replace`,vn);var yn=class e extends dn{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(bn(e,this.from,this.gapFrom)||bn(e,this.gapTo,this.to)))return fn.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return fn.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?fn.fromReplace(e,this.from,this.to,n):fn.fail(`Content does not fit in gap`)}getMap(){return new cn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,F.fromJSON(t,n.slice),n.insert,!!n.structure)}};dn.jsonID(`replaceAround`,yn);function bn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function xn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new hn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new mn(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Sn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Tt){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new hn(t.from,t.to,t.style)))}function Cn(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new vn(s,l,F.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new hn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new F(N.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new vn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(N.empty,!0);e.replace(s,s,new F(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function wn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Tn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!wn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function En(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=N.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=N.from(r.node(e).copy(u)),d++):c--;let f=N.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=N.from(i.node(e).copy(f)),p++):l++;e.step(new yn(c,l,o,s,new F(u.append(f),d,p),u.size-d,!0))}function Dn(e,t,n=null,r=e){let i=kn(e,t),a=i&&An(r,t);return a?i.map(On).concat({type:t,attrs:n}).concat(a.map(On)):null}function On(e){return{type:e,attrs:null}}function kn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function An(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function jn(e,t,n){let r=N.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=N.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new yn(i,a,i,a,new F(r,0,0),n.length,!0))}function Mn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Fn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Pn(e,t,n,a),Cn(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new yn(c,l,c+1,l-1,new F(N.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Nn(e,t,n,a),!1}})}function Nn(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Pn(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-C-Hj-nXR.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./cloud-C4-yfnnk.js";import{t as l}from"./download-Dk-ZjtO6.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./globe-DSSGFWFn.js";import{t as f}from"./loader-circle-CifKLtgG.js";import{t as p}from"./copy-to-clipboard-HOJ79TWv.js";import{t as m}from"./messages-CTSgFlE4.js";import{a as h,i as g,n as _,r as v,s as y}from"./locale-store-CMZljTJx.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{n as S,r as C}from"./gateway-config-swr-BC3pgb_P.js";import{a as w,o as T,s as E}from"./form-field-width-DJw_jULe.js";import{Fi as D,Fl as O,Gs as k,Hs as A,Ii as j,Is as M,Ka as N,Ks as P,Li as F,Ol as I,Qa as L,Qt as R,Ss as z,Tl as B,Ts as V,bc as ee,cc as H,ec as U,eo as te,hl as W,ic as G,lc as ne,ms as re,ri as ie,sc as K,wl as ae}from"./index-B0WJL9N1.js";import{n as oe,r as se,t as ce}from"./settings-page-layout-BRQNel6r.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ue,t as q}from"./settings-form-section-DjWzRk4z.js";import{n as de,t as fe}from"./use-autosave-D88VGoyG.js";import{t as pe}from"./page-tabs-BaEQMYm_.js";import{t as me}from"./settings-advanced-gate-D4EMxWAZ.js";import{a as he,c as ge,d as _e,u as ve}from"./gateway-config-api-DM3poL22.js";import{t as ye}from"./tab-completion-input-D64VNmiA.js";var J=e(t(),1),Y=n(),X=r();function Z(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(){return b(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,E,`dark:border-edge`)}function be(){return b(T,w)}function xe(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function Se(e){let t=(0,Y.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,X.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=b(be(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(Ce),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,X.jsx)(a,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=i?(0,X.jsxs)(`button`,{type:`button`,className:b(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,X.jsx)(`span`,{children:s.browserGoToConfigure}),(0,X.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,X.jsx)(`span`,{className:b(`inline-block size-1.5 rounded-full`,xe(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function Ce(e){return(0,X.jsx)(o,{value:e.value,children:e.name},e.value)}function we(e){return`browser-focus-${e}`}function Te(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function Ee(e){let t=(0,Y.c)(95),{a:n,form:r,update:i}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=we(`runtime`),t[0]=s):s=t[0];let c;t[1]===n.browserBehaviorShow?c=t[2]:(c=(0,X.jsx)(ue,{icon:A,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=c);let l;t[3]===i?l=t[4]:(l=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=l);let u;t[5]!==r.browserHeadless||t[6]!==l?(u=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:l}),t[5]=r.browserHeadless,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n.browserHeadlessOn?d=t[9]:(d=(0,X.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=d);let f;t[10]!==u||t[11]!==d?(f=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==f?(p=(0,X.jsx)(Z,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:f}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=f,t[16]=p):p=t[16];let m=n.label.browserDialogPolicy,h=n.desc.browserDialogPolicy,g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=be(),t[17]=g):g=t[17];let _;t[18]===i?_=t[19]:(_=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=_);let v;t[20]===n.browserDialogPolicyMustRespond?v=t[21]:(v=(0,X.jsx)(o,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=v);let y;t[22]===n.browserDialogPolicyAutoDismiss?y=t[23]:(y=(0,X.jsx)(o,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=y);let b;t[24]===n.browserDialogPolicyAutoAccept?b=t[25]:(b=(0,X.jsx)(o,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=b);let x;t[26]!==r.browserDialogPolicy||t[27]!==_||t[28]!==v||t[29]!==y||t[30]!==b?(x=(0,X.jsxs)(a,{className:g,value:r.browserDialogPolicy,onChange:_,children:[v,y,b]}),t[26]=r.browserDialogPolicy,t[27]=_,t[28]=v,t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==x?(S=(0,X.jsx)(Z,{label:m,description:h,children:x}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=x,t[35]=S):S=t[35];let C=n.label.browserDialogTimeout,w=n.desc.browserDialogTimeout,T;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=Q(),t[36]=T):T=t[36];let E=r.browserDialogTimeout??``,D;t[37]===i?D=t[38]:(D=e=>i({browserDialogTimeout:Number.parseInt(e,10)}),t[37]=i,t[38]=D);let O;t[39]===i?O=t[40]:(O=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[39]=i,t[40]=O);let k;t[41]!==E||t[42]!==D||t[43]!==O?(k=(0,X.jsx)(ye,{type:`number`,className:T,min:1,value:E,suggestion:`300`,onAcceptSuggestion:D,placeholder:`300`,onChange:O}),t[41]=E,t[42]=D,t[43]=O,t[44]=k):k=t[44];let j;t[45]!==n.desc.browserDialogTimeout||t[46]!==n.label.browserDialogTimeout||t[47]!==k?(j=(0,X.jsx)(Z,{label:C,description:w,children:k}),t[45]=n.desc.browserDialogTimeout,t[46]=n.label.browserDialogTimeout,t[47]=k,t[48]=j):j=t[48];let M;t[49]!==S||t[50]!==j||t[51]!==p?(M=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,j]}),t[49]=S,t[50]=j,t[51]=p,t[52]=M):M=t[52];let N;t[53]!==c||t[54]!==M?(N=(0,X.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{children:[c,M]})}),t[53]=c,t[54]=M,t[55]=N):N=t[55];let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=we(`security`),t[56]=F):F=t[56];let I;t[57]===n.browserSecurityShow?I=t[58]:(I=(0,X.jsx)(ue,{icon:P,title:n.browserSecurityShow}),t[57]=n.browserSecurityShow,t[58]=I);let L;t[59]===i?L=t[60]:(L=e=>i({browserAllowPrivateUrls:e.target.checked}),t[59]=i,t[60]=L);let R;t[61]!==r.browserAllowPrivateUrls||t[62]!==L?(R=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:L}),t[61]=r.browserAllowPrivateUrls,t[62]=L,t[63]=R):R=t[63];let z;t[64]===n.browserAllowPrivateOn?z=t[65]:(z=(0,X.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[64]=n.browserAllowPrivateOn,t[65]=z);let B;t[66]!==R||t[67]!==z?(B=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[R,z]}),t[66]=R,t[67]=z,t[68]=B):B=t[68];let V;t[69]!==n.desc.browserAllowPrivateUrls||t[70]!==n.label.browserAllowPrivateUrls||t[71]!==B?(V=(0,X.jsx)(Z,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:B}),t[69]=n.desc.browserAllowPrivateUrls,t[70]=n.label.browserAllowPrivateUrls,t[71]=B,t[72]=V):V=t[72];let ee=n.label.browserCommandTimeout,H=n.desc.browserCommandTimeout,U;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(U=Q(),t[73]=U):U=t[73];let te=r.browserCommandTimeout??``,W;t[74]===i?W=t[75]:(W=e=>i({browserCommandTimeout:Number.parseInt(e,10)}),t[74]=i,t[75]=W);let G;t[76]===i?G=t[77]:(G=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[76]=i,t[77]=G);let ne;t[78]!==te||t[79]!==W||t[80]!==G?(ne=(0,X.jsx)(ye,{type:`number`,className:U,min:5,value:te,suggestion:`30`,onAcceptSuggestion:W,placeholder:`30`,onChange:G}),t[78]=te,t[79]=W,t[80]=G,t[81]=ne):ne=t[81];let re;t[82]!==n.desc.browserCommandTimeout||t[83]!==n.label.browserCommandTimeout||t[84]!==ne?(re=(0,X.jsx)(Z,{label:ee,description:H,children:ne}),t[82]=n.desc.browserCommandTimeout,t[83]=n.label.browserCommandTimeout,t[84]=ne,t[85]=re):re=t[85];let ie;t[86]!==V||t[87]!==re?(ie=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[V,re]}),t[86]=V,t[87]=re,t[88]=ie):ie=t[88];let K;t[89]!==I||t[90]!==ie?(K=(0,X.jsx)(`div`,{id:F,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{className:`border border-amber-500/20`,children:[I,ie]})}),t[89]=I,t[90]=ie,t[91]=K):K=t[91];let ae;return t[92]!==N||t[93]!==K?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[N,K]}),t[92]=N,t[93]=K,t[94]=ae):ae=t[94],ae}function De(e){let t=(0,Y.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=N(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=b(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(u,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==r||t[6]!==a||t[7]!==o?(c=(0,X.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,s]}),t[5]=r,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Oe(e){let t=(0,Y.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=b(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==a?(p=i&&a?(0,X.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:a}):null,t[5]=i,t[6]=a,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,X.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let x;return t[22]!==s||t[23]!==l||t[24]!==v||t[25]!==y?(x=(0,X.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[v,y]}),t[22]=s,t[23]=l,t[24]=v,t[25]=y,t[26]=x):x=t[26],x}function ke(e){let t=(0,Y.c)(25),{m:n,onStart:r}=e,i=R(Ae),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:G,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:k,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:ee,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:c,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>ve(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let l;t[12]===n.browserSetupSubtitle?l=t[13]:(l=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=l);let u;t[14]!==s||t[15]!==l?(u=(0,X.jsxs)(`div`,{children:[s,l]}),t[14]=s,t[15]=l,t[16]=u):u=t[16];let d;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(d=(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,X.jsx)(Oe,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=d):d=t[21];let f;return t[22]!==u||t[23]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[u,d]}),t[22]=u,t[23]=d,t[24]=f):f=t[24],f}function Ae(e){return e.mode}function je(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function Me(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Ne(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Pe(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Fe=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ie=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Le={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Re(e){let t=(e??``).trim();return t===`behavior`?`overview`:Fe.includes(t)?t:`overview`}function ze(e){return Ie.includes(e)}function Be(e){let t=(0,Y.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Ve,{kind:a,detail:o,m:u})}):(0,X.jsx)(`span`,{}),s?(0,X.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,X.jsx)(Ve,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,X.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ve(e){let t=(0,Y.c)(27),{kind:n,detail:r,m:i}=e,a,o,c,l;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:s,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:V,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:f,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:I,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:B,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=b(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=a,t[7]=o,t[8]=c,t[9]=l}else a=t[6],o=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=b(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let p;t[12]!==a||t[13]!==d?(p=(0,X.jsx)(a,{className:d}),t[12]=a,t[13]=d,t[14]=p):p=t[14];let m;t[15]===o?m=t[16]:(m=(0,X.jsx)(`span`,{children:o}),t[15]=o,t[16]=m);let h;t[17]!==c||t[18]!==p||t[19]!==m?(h=(0,X.jsxs)(`span`,{className:c,children:[p,m]}),t[17]=c,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===r?g=t[22]:(g=r?(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=g);let _;return t[23]!==l||t[24]!==h||t[25]!==g?(_=(0,X.jsxs)(`span`,{className:l,children:[h,g]}),t[23]=l,t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function He(e){let t=(0,Y.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,a;t[0]===i?a=t[1]:(a=b(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,X.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Ue={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function We({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,J.useReducer)(F,Ue),{instances:u,launchStatus:d,launchMessage:p,testStatus:m,testMessage:h,executablePath:g}=c,_=(0,J.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,J.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,J.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,J.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,J.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(Be,{icon:H,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[p?(0,X.jsx)(He,{kind:d===`error`?`error`:`success`,message:p}):null,(0,X.jsx)(Z,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,X.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,X.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,X.jsx)(M,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,X.jsxs)(Be,{icon:re,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||m===`pending`,onClick:()=>void b(),children:[m===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(K,{className:`size-3.5`}),m===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),h?(0,X.jsx)(He,{kind:m===`error`?`error`:`success`,message:h}):null]})]})}function Ge(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ke(e){let t=(0,Y.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Ge(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,X.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,X.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,X.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,X.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,X.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(qe)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function qe(e){return(0,X.jsx)(`div`,{className:`truncate`,children:e},e)}var Je={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ye({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:c,launchCloak:u,form:d,onChange:p,embedded:m=!1}){let[h,g]=(0,J.useReducer)(F,Je),{confirmOpen:_,installStatus:v,installMessage:y,openStatus:b,openMessage:x,runtime:S}=h,{progress:C,running:w,cancelling:T,run:E,reset:D,cancel:O}=i,A=t.kind===`ok`?t.data:null,j=A?.installed===!0,M=v===`installing`||w,N=(0,J.useCallback)(async()=>{if(j)try{g({type:`patch`,patch:{runtime:await c()}})}catch{}},[c,j]);(0,J.useEffect)(()=>{if(!j){g({type:`patch`,patch:{runtime:null}});return}N();let e=setInterval(()=>void N(),8e3);return()=>clearInterval(e)},[j,N]);let P=(0,J.useCallback)(async()=>{g({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),D();let t=await E({body:{cacheDir:d.cacheDir.trim()||void 0,binaryPath:d.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){g({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){g({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),D();return}g({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),g({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:d.cacheDir,binaryPath:d.binaryPath}),await N()},[r,d.binaryPath,d.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,N,D,E]),I=(0,J.useCallback)(async()=>{if(b!==`pending`){g({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await u();g({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){g({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[u,e.browserCloakOpenLaunched,e.browserCloakOpenReused,b]),L=t.kind===`loading`?`checking`:t.kind===`error`?`error`:j?`ready`:`not_installed`,R=j&&A?.version?`v${A.version} (${A.platform})`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{icon:k,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:L,statusDetail:R,m:e,embedded:m,primaryAction:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[j?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:b===`pending`,onClick:()=>void I(),children:[b===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),b===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:M,onClick:()=>g({type:`patch`,patch:{confirmOpen:!0}}),children:[M?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):j?(0,X.jsx)(U,{className:`size-3.5`}):v===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),M?e.browserCloakInstalling:j?e.browserReinstall:e.browserCloakDownload]})]}),children:[w?(0,X.jsx)(Ke,{m:e,progress:C,cancelling:T,onCancel:()=>void O()}):null,y?(0,X.jsx)(He,{kind:v===`failed`?`error`:`success`,message:y}):null,x?(0,X.jsx)(He,{kind:b===`error`?`error`:`success`,message:x}):null,j&&S?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:S.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(S.port)):e.browserCloakRuntimeOff})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:S.userDataDir})]}),(0,X.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),S.temporaryProfile?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.keepOpen,onChange:e=>p({keepOpen:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,X.jsx)(Z,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.temporaryProfile,onChange:e=>p({temporaryProfile:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.humanize,onChange:e=>p({humanize:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,X.jsxs)(a,{className:be(),value:d.humanPreset,onChange:e=>p({humanPreset:e.target.value}),children:[(0,X.jsx)(o,{value:`careful`,children:e.browserHumanPresetCareful}),(0,X.jsx)(o,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,X.jsxs)(q,{className:`mt-4`,children:[(0,X.jsx)(ue,{icon:k,title:e.browserCloakAdvancedShow}),(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsxs)(Z,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>p({cacheDir:e.target.value}),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,X.jsxs)(Z,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>p({binaryPath:e.target.value}),autoComplete:`off`}),d.binaryPath.trim()?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,X.jsx)(Z,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.timezone,placeholder:`America/New_York`,onChange:e=>p({timezone:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.locale,placeholder:`en-US`,onChange:e=>p({locale:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>p({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.fingerprintPlatform,placeholder:`macos`,onChange:e=>p({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(`div`,{className:`sm:col-span-2`,children:(0,X.jsx)(Z,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,X.jsx)(`textarea`,{className:Xe(),value:d.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>p({extraArgs:e.target.value})})})})]})]}),(0,X.jsx)(ie,{open:_,title:e.browserConfirmDownloadTitle,description:Ze(e,A),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void P(),onCancel:()=>g({type:`patch`,patch:{confirmOpen:!1}})})]})}function Xe(){return`${Q()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ze(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-C-Hj-nXR.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./cloud-C4-yfnnk.js";import{t as l}from"./download-Dk-ZjtO6.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./globe-DSSGFWFn.js";import{t as f}from"./loader-circle-CifKLtgG.js";import{t as p}from"./copy-to-clipboard-HOJ79TWv.js";import{t as m}from"./messages-CTSgFlE4.js";import{a as h,i as g,n as _,r as v,s as y}from"./locale-store-CMZljTJx.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{n as S,r as C}from"./gateway-config-swr-BC3pgb_P.js";import{a as w,o as T,s as E}from"./form-field-width-DJw_jULe.js";import{Fi as D,Fl as O,Gs as k,Hs as A,Ii as j,Is as M,Ka as N,Ks as P,Li as F,Ol as I,Qa as L,Qt as R,Ss as z,Tl as B,Ts as V,bc as ee,cc as H,ec as U,eo as te,hl as W,ic as G,lc as ne,ms as re,ri as ie,sc as K,wl as ae}from"./index-DUz0O54y.js";import{n as oe,r as se,t as ce}from"./settings-page-layout-BRQNel6r.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ue,t as q}from"./settings-form-section-DjWzRk4z.js";import{n as de,t as fe}from"./use-autosave-TwuAycG8.js";import{t as pe}from"./page-tabs-BaEQMYm_.js";import{t as me}from"./settings-advanced-gate-CSYy6SUa.js";import{a as he,c as ge,d as _e,u as ve}from"./gateway-config-api-DaYY1Gkn.js";import{t as ye}from"./tab-completion-input-D64VNmiA.js";var J=e(t(),1),Y=n(),X=r();function Z(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(){return b(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,E,`dark:border-edge`)}function be(){return b(T,w)}function xe(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function Se(e){let t=(0,Y.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,X.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=b(be(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(Ce),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,X.jsx)(a,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=i?(0,X.jsxs)(`button`,{type:`button`,className:b(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,X.jsx)(`span`,{children:s.browserGoToConfigure}),(0,X.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,X.jsx)(`span`,{className:b(`inline-block size-1.5 rounded-full`,xe(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function Ce(e){return(0,X.jsx)(o,{value:e.value,children:e.name},e.value)}function we(e){return`browser-focus-${e}`}function Te(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function Ee(e){let t=(0,Y.c)(95),{a:n,form:r,update:i}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=we(`runtime`),t[0]=s):s=t[0];let c;t[1]===n.browserBehaviorShow?c=t[2]:(c=(0,X.jsx)(ue,{icon:A,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=c);let l;t[3]===i?l=t[4]:(l=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=l);let u;t[5]!==r.browserHeadless||t[6]!==l?(u=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:l}),t[5]=r.browserHeadless,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n.browserHeadlessOn?d=t[9]:(d=(0,X.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=d);let f;t[10]!==u||t[11]!==d?(f=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==f?(p=(0,X.jsx)(Z,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:f}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=f,t[16]=p):p=t[16];let m=n.label.browserDialogPolicy,h=n.desc.browserDialogPolicy,g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=be(),t[17]=g):g=t[17];let _;t[18]===i?_=t[19]:(_=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=_);let v;t[20]===n.browserDialogPolicyMustRespond?v=t[21]:(v=(0,X.jsx)(o,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=v);let y;t[22]===n.browserDialogPolicyAutoDismiss?y=t[23]:(y=(0,X.jsx)(o,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=y);let b;t[24]===n.browserDialogPolicyAutoAccept?b=t[25]:(b=(0,X.jsx)(o,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=b);let x;t[26]!==r.browserDialogPolicy||t[27]!==_||t[28]!==v||t[29]!==y||t[30]!==b?(x=(0,X.jsxs)(a,{className:g,value:r.browserDialogPolicy,onChange:_,children:[v,y,b]}),t[26]=r.browserDialogPolicy,t[27]=_,t[28]=v,t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==x?(S=(0,X.jsx)(Z,{label:m,description:h,children:x}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=x,t[35]=S):S=t[35];let C=n.label.browserDialogTimeout,w=n.desc.browserDialogTimeout,T;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=Q(),t[36]=T):T=t[36];let E=r.browserDialogTimeout??``,D;t[37]===i?D=t[38]:(D=e=>i({browserDialogTimeout:Number.parseInt(e,10)}),t[37]=i,t[38]=D);let O;t[39]===i?O=t[40]:(O=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[39]=i,t[40]=O);let k;t[41]!==E||t[42]!==D||t[43]!==O?(k=(0,X.jsx)(ye,{type:`number`,className:T,min:1,value:E,suggestion:`300`,onAcceptSuggestion:D,placeholder:`300`,onChange:O}),t[41]=E,t[42]=D,t[43]=O,t[44]=k):k=t[44];let j;t[45]!==n.desc.browserDialogTimeout||t[46]!==n.label.browserDialogTimeout||t[47]!==k?(j=(0,X.jsx)(Z,{label:C,description:w,children:k}),t[45]=n.desc.browserDialogTimeout,t[46]=n.label.browserDialogTimeout,t[47]=k,t[48]=j):j=t[48];let M;t[49]!==S||t[50]!==j||t[51]!==p?(M=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,j]}),t[49]=S,t[50]=j,t[51]=p,t[52]=M):M=t[52];let N;t[53]!==c||t[54]!==M?(N=(0,X.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{children:[c,M]})}),t[53]=c,t[54]=M,t[55]=N):N=t[55];let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=we(`security`),t[56]=F):F=t[56];let I;t[57]===n.browserSecurityShow?I=t[58]:(I=(0,X.jsx)(ue,{icon:P,title:n.browserSecurityShow}),t[57]=n.browserSecurityShow,t[58]=I);let L;t[59]===i?L=t[60]:(L=e=>i({browserAllowPrivateUrls:e.target.checked}),t[59]=i,t[60]=L);let R;t[61]!==r.browserAllowPrivateUrls||t[62]!==L?(R=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:L}),t[61]=r.browserAllowPrivateUrls,t[62]=L,t[63]=R):R=t[63];let z;t[64]===n.browserAllowPrivateOn?z=t[65]:(z=(0,X.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[64]=n.browserAllowPrivateOn,t[65]=z);let B;t[66]!==R||t[67]!==z?(B=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[R,z]}),t[66]=R,t[67]=z,t[68]=B):B=t[68];let V;t[69]!==n.desc.browserAllowPrivateUrls||t[70]!==n.label.browserAllowPrivateUrls||t[71]!==B?(V=(0,X.jsx)(Z,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:B}),t[69]=n.desc.browserAllowPrivateUrls,t[70]=n.label.browserAllowPrivateUrls,t[71]=B,t[72]=V):V=t[72];let ee=n.label.browserCommandTimeout,H=n.desc.browserCommandTimeout,U;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(U=Q(),t[73]=U):U=t[73];let te=r.browserCommandTimeout??``,W;t[74]===i?W=t[75]:(W=e=>i({browserCommandTimeout:Number.parseInt(e,10)}),t[74]=i,t[75]=W);let G;t[76]===i?G=t[77]:(G=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[76]=i,t[77]=G);let ne;t[78]!==te||t[79]!==W||t[80]!==G?(ne=(0,X.jsx)(ye,{type:`number`,className:U,min:5,value:te,suggestion:`30`,onAcceptSuggestion:W,placeholder:`30`,onChange:G}),t[78]=te,t[79]=W,t[80]=G,t[81]=ne):ne=t[81];let re;t[82]!==n.desc.browserCommandTimeout||t[83]!==n.label.browserCommandTimeout||t[84]!==ne?(re=(0,X.jsx)(Z,{label:ee,description:H,children:ne}),t[82]=n.desc.browserCommandTimeout,t[83]=n.label.browserCommandTimeout,t[84]=ne,t[85]=re):re=t[85];let ie;t[86]!==V||t[87]!==re?(ie=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[V,re]}),t[86]=V,t[87]=re,t[88]=ie):ie=t[88];let K;t[89]!==I||t[90]!==ie?(K=(0,X.jsx)(`div`,{id:F,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{className:`border border-amber-500/20`,children:[I,ie]})}),t[89]=I,t[90]=ie,t[91]=K):K=t[91];let ae;return t[92]!==N||t[93]!==K?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[N,K]}),t[92]=N,t[93]=K,t[94]=ae):ae=t[94],ae}function De(e){let t=(0,Y.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=N(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=b(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(u,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==r||t[6]!==a||t[7]!==o?(c=(0,X.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,s]}),t[5]=r,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Oe(e){let t=(0,Y.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=b(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==a?(p=i&&a?(0,X.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:a}):null,t[5]=i,t[6]=a,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,X.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let x;return t[22]!==s||t[23]!==l||t[24]!==v||t[25]!==y?(x=(0,X.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[v,y]}),t[22]=s,t[23]=l,t[24]=v,t[25]=y,t[26]=x):x=t[26],x}function ke(e){let t=(0,Y.c)(25),{m:n,onStart:r}=e,i=R(Ae),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:G,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:k,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:ee,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:c,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>ve(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let l;t[12]===n.browserSetupSubtitle?l=t[13]:(l=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=l);let u;t[14]!==s||t[15]!==l?(u=(0,X.jsxs)(`div`,{children:[s,l]}),t[14]=s,t[15]=l,t[16]=u):u=t[16];let d;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(d=(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,X.jsx)(Oe,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=d):d=t[21];let f;return t[22]!==u||t[23]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[u,d]}),t[22]=u,t[23]=d,t[24]=f):f=t[24],f}function Ae(e){return e.mode}function je(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function Me(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Ne(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Pe(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Fe=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ie=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Le={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Re(e){let t=(e??``).trim();return t===`behavior`?`overview`:Fe.includes(t)?t:`overview`}function ze(e){return Ie.includes(e)}function Be(e){let t=(0,Y.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Ve,{kind:a,detail:o,m:u})}):(0,X.jsx)(`span`,{}),s?(0,X.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,X.jsx)(Ve,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,X.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ve(e){let t=(0,Y.c)(27),{kind:n,detail:r,m:i}=e,a,o,c,l;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:s,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:V,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:f,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:I,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:B,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=b(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=a,t[7]=o,t[8]=c,t[9]=l}else a=t[6],o=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=b(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let p;t[12]!==a||t[13]!==d?(p=(0,X.jsx)(a,{className:d}),t[12]=a,t[13]=d,t[14]=p):p=t[14];let m;t[15]===o?m=t[16]:(m=(0,X.jsx)(`span`,{children:o}),t[15]=o,t[16]=m);let h;t[17]!==c||t[18]!==p||t[19]!==m?(h=(0,X.jsxs)(`span`,{className:c,children:[p,m]}),t[17]=c,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===r?g=t[22]:(g=r?(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=g);let _;return t[23]!==l||t[24]!==h||t[25]!==g?(_=(0,X.jsxs)(`span`,{className:l,children:[h,g]}),t[23]=l,t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function He(e){let t=(0,Y.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,a;t[0]===i?a=t[1]:(a=b(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,X.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Ue={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function We({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,J.useReducer)(F,Ue),{instances:u,launchStatus:d,launchMessage:p,testStatus:m,testMessage:h,executablePath:g}=c,_=(0,J.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,J.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,J.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,J.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,J.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(Be,{icon:H,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[p?(0,X.jsx)(He,{kind:d===`error`?`error`:`success`,message:p}):null,(0,X.jsx)(Z,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,X.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,X.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,X.jsx)(M,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,X.jsxs)(Be,{icon:re,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||m===`pending`,onClick:()=>void b(),children:[m===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(K,{className:`size-3.5`}),m===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),h?(0,X.jsx)(He,{kind:m===`error`?`error`:`success`,message:h}):null]})]})}function Ge(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ke(e){let t=(0,Y.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Ge(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,X.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,X.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,X.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,X.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,X.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(qe)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function qe(e){return(0,X.jsx)(`div`,{className:`truncate`,children:e},e)}var Je={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ye({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:c,launchCloak:u,form:d,onChange:p,embedded:m=!1}){let[h,g]=(0,J.useReducer)(F,Je),{confirmOpen:_,installStatus:v,installMessage:y,openStatus:b,openMessage:x,runtime:S}=h,{progress:C,running:w,cancelling:T,run:E,reset:D,cancel:O}=i,A=t.kind===`ok`?t.data:null,j=A?.installed===!0,M=v===`installing`||w,N=(0,J.useCallback)(async()=>{if(j)try{g({type:`patch`,patch:{runtime:await c()}})}catch{}},[c,j]);(0,J.useEffect)(()=>{if(!j){g({type:`patch`,patch:{runtime:null}});return}N();let e=setInterval(()=>void N(),8e3);return()=>clearInterval(e)},[j,N]);let P=(0,J.useCallback)(async()=>{g({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),D();let t=await E({body:{cacheDir:d.cacheDir.trim()||void 0,binaryPath:d.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){g({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){g({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),D();return}g({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),g({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:d.cacheDir,binaryPath:d.binaryPath}),await N()},[r,d.binaryPath,d.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,N,D,E]),I=(0,J.useCallback)(async()=>{if(b!==`pending`){g({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await u();g({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){g({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[u,e.browserCloakOpenLaunched,e.browserCloakOpenReused,b]),L=t.kind===`loading`?`checking`:t.kind===`error`?`error`:j?`ready`:`not_installed`,R=j&&A?.version?`v${A.version} (${A.platform})`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{icon:k,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:L,statusDetail:R,m:e,embedded:m,primaryAction:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[j?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:b===`pending`,onClick:()=>void I(),children:[b===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),b===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:M,onClick:()=>g({type:`patch`,patch:{confirmOpen:!0}}),children:[M?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):j?(0,X.jsx)(U,{className:`size-3.5`}):v===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),M?e.browserCloakInstalling:j?e.browserReinstall:e.browserCloakDownload]})]}),children:[w?(0,X.jsx)(Ke,{m:e,progress:C,cancelling:T,onCancel:()=>void O()}):null,y?(0,X.jsx)(He,{kind:v===`failed`?`error`:`success`,message:y}):null,x?(0,X.jsx)(He,{kind:b===`error`?`error`:`success`,message:x}):null,j&&S?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:S.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(S.port)):e.browserCloakRuntimeOff})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:S.userDataDir})]}),(0,X.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),S.temporaryProfile?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.keepOpen,onChange:e=>p({keepOpen:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,X.jsx)(Z,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.temporaryProfile,onChange:e=>p({temporaryProfile:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.humanize,onChange:e=>p({humanize:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,X.jsxs)(a,{className:be(),value:d.humanPreset,onChange:e=>p({humanPreset:e.target.value}),children:[(0,X.jsx)(o,{value:`careful`,children:e.browserHumanPresetCareful}),(0,X.jsx)(o,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,X.jsxs)(q,{className:`mt-4`,children:[(0,X.jsx)(ue,{icon:k,title:e.browserCloakAdvancedShow}),(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsxs)(Z,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>p({cacheDir:e.target.value}),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,X.jsxs)(Z,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>p({binaryPath:e.target.value}),autoComplete:`off`}),d.binaryPath.trim()?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,X.jsx)(Z,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.timezone,placeholder:`America/New_York`,onChange:e=>p({timezone:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.locale,placeholder:`en-US`,onChange:e=>p({locale:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>p({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.fingerprintPlatform,placeholder:`macos`,onChange:e=>p({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(`div`,{className:`sm:col-span-2`,children:(0,X.jsx)(Z,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,X.jsx)(`textarea`,{className:Xe(),value:d.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>p({extraArgs:e.target.value})})})})]})]}),(0,X.jsx)(ie,{open:_,title:e.browserConfirmDownloadTitle,description:Ze(e,A),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void P(),onCancel:()=>g({type:`patch`,patch:{confirmOpen:!1}})})]})}function Xe(){return`${Q()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ze(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
2
  `)}function Qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,l]=(0,J.useState)(`idle`),[u,d]=(0,J.useState)(null),p=t.provider===`local`?`browserbase`:t.provider,h=m(_(e=>e.language)).providersSettings,g=L({show:h.show,hide:h.hide,copy:h.copy,copied:h.copied}),v=(0,J.useCallback)(()=>he().then(e=>e.apiKey??null),[]),y=(0,J.useCallback)(async()=>{l(`pending`),d(null);try{let n=await r(p,t.apiKey);n.reachable?(l(`ok`),d(e.browserCloudTestOk)):(l(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){l(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,p,r]);return(0,X.jsxs)(Be,{icon:c,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:s===`pending`,onClick:()=>void y(),children:[s===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(K,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,X.jsxs)(a,{className:be(),value:p,onChange:e=>n({provider:e.target.value}),children:[(0,X.jsx)(o,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,X.jsx)(o,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,X.jsx)(Z,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,X.jsx)(te,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:p===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:g,reveal:v,loadFailedLabel:`Failed to load key`})}),p===`browserbase`?(0,X.jsx)(Z,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,X.jsx)(Z,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),u?(0,X.jsx)(He,{kind:s===`error`?`error`:`success`,message:u}):null]})}function $e(e){let t=(0,Y.c)(48),{m:n,installed:r,extensionDir:i,connected:a,busy:o,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!i&&a,h;t[3]!==o||t[4]!==i||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(h=i?(0,X.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,X.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:c,children:n.browserExtensionOpenChrome}),(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:l,title:i,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:u,title:i,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=o,t[4]=i,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==a||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:a},t[20]=a,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,x;t[27]===y?x=t[28]:(x=y.filter(et),t[27]=y,t[28]=x);let S=x.length,C=n.browserExtensionInstallGuideTitle,w;t[29]===n.browserExtensionInstallGuideTitle?w=t[30]:(w=(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=w);let T;t[31]!==S||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(T=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(S)).replace(`{{total}}`,String(y.length)),t[31]=S,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=T):T=t[34];let E;t[35]===T?E=t[36]:(E=(0,X.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:T}),t[35]=T,t[36]=E);let D;t[37]!==E||t[38]!==w?(D=(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[w,E]}),t[37]=E,t[38]=w,t[39]=D):D=t[39];let O;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(O=(0,X.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,X.jsx)(s,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,X.jsx)(ae,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:b(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,X.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=O):O=t[43];let k;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==D||t[46]!==O?(k=(0,X.jsxs)(`div`,{"aria-label":C,className:`rounded-xl bg-surface-base p-3`,children:[D,O]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=D,t[46]=O,t[47]=k):k=t[47],k}function et(e){return e.done}var tt=19820,nt=3e4;function rt({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:u,revealExtensionFolder:d,form:m,embedded:h=!1}){let[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),S=m.port??tt,C=m.host||`127.0.0.1`,w=`ws://${C}:${S}/browser-ext`,T=t.kind===`ok`&&t.data.running,E=t.kind===`ok`&&t.data.connected,D=t.kind===`ok`&&t.data.bridgeHeld===!0,O=t.kind===`ok`&&t.data.portConflict===!0,k=T||D,A=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,j=A?.installed===!0,N=A?.extensionDir,P=A?.needsChromeReload===!0,F=t.kind===`ok`?E?{icon:ne,color:`text-green-500`,label:e.browserExtensionConnected}:T?{icon:K,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:z,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:z,color:`text-fg-muted`,label:`…`},I=F.icon,L=(0,J.useCallback)(async()=>{if(!g){_(`start`),y(null);try{await i({host:C,port:S})}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,C,S,i]),R=(0,J.useCallback)(async()=>{if(!g){_(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,a]),B=(0,J.useCallback)(async()=>{if(!g){_(`disconnect`),y(null);try{await o()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,o]),V=(0,J.useCallback)(async()=>{if(!g){_(`install`),y(null),x(null);try{let t=await s({force:j});t?.extensionDir?x(`${e.browserExtensionInstalled}: ${t.extensionDir}`):x(e.browserExtensionInstalled),await c()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,s,j,e.browserExtensionInstalled,c]),ee=(0,J.useCallback)(async()=>{if(!g){_(`open`),y(null);try{await u()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,u]),U=(0,J.useCallback)(async()=>{if(!(!N||g)){_(`path`),y(null),x(null);try{await p(N)?x(e.browserExtensionPathCopied):x(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,N,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),te=(0,J.useCallback)(async()=>{if(!(!N||g)){_(`folder`),y(null),x(null);try{await d(),x(e.browserExtensionFolderOpened)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,N,e.browserExtensionFolderOpened,d]),W=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void V(),children:[g===`install`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(l,{className:`size-3.5`}),g===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),k?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void R(),children:[g===`stop`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(M,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void L(),children:[g===`start`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),g===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),E?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void B(),children:[g===`disconnect`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(z,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,X.jsx)(Be,{icon:G,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:h,primaryAction:W,advancedTitle:e.browserAdvancedShow,advanced:(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,X.jsx)(ye,{type:`number`,className:Q(),min:1024,max:65535,value:m.port??``,suggestion:String(tt),onAcceptSuggestion:e=>r({port:Number.parseInt(e,10)}),placeholder:String(tt),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,X.jsx)(Z,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,X.jsx)(ye,{type:`text`,className:Q(),value:m.host,suggestion:`127.0.0.1`,onAcceptSuggestion:e=>r({host:e}),placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,X.jsx)(ye,{type:`number`,className:Q(),min:1,step:1,value:m.connectionTimeoutMs==null?``:Math.round(m.connectionTimeoutMs/1e3),placeholder:String(nt/1e3),suggestion:String(nt/1e3),onAcceptSuggestion:e=>r({connectionTimeoutMs:Number.parseInt(e,10)*1e3}),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:w}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${F.color}`,children:[(0,X.jsx)(I,{className:`size-3.5`}),(0,X.jsx)(`span`,{children:F.label})]})]}),(0,X.jsx)($e,{m:e,installed:j,extensionDir:N,connected:E,busy:g!==null,pathBusy:g===`path`,folderBusy:g===`folder`,onOpenChrome:()=>void ee(),onCopyPath:()=>void U(),onRevealFolder:()=>void te()}),P?(0,X.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,O?(0,X.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(S))}):null,b?(0,X.jsx)(He,{kind:`success`,message:b}):null,v?(0,X.jsx)(He,{kind:`error`,message:v}):null]})})}function it(e){let t=(0,Y.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:c}=e,u=c===void 0?!1:c,[d,p]=(0,J.useState)(`idle`),[m,h]=(0,J.useState)(null),{progress:g,running:_,cancelling:v,run:y,reset:b,cancel:x}=o,S;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==b||t[5]!==y?(S=async()=>{p(`installing`),h(null),b();let e=await y({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){p(`installing`);return}if(e.error===`cancelled`){p(`idle`),h(null),b();return}p(`failed`),h(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),p(`installed`),h(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=b,t[5]=y,t[6]=S):S=t[6];let C=S,w=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,T=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,E=r.kind===`ok`&&r.data.installed,D=d===`installing`||_,O;t[7]===C?O=t[8]:(O=()=>void C(),t[7]=C,t[8]=O);let k;t[9]!==E||t[10]!==D||t[11]!==d?(k=D?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):E?(0,X.jsx)(U,{className:`size-3.5`}):d===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),t[9]=E,t[10]=D,t[11]=d,t[12]=k):k=t[12];let A=D?n.browserPlaywrightInstalling:E?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==D||t[14]!==O||t[15]!==k||t[16]!==A?(j=(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:D,onClick:O,children:[k,A]}),t[13]=D,t[14]=O,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,X.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,X.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let F;t[23]!==x||t[24]!==v||t[25]!==n||t[26]!==g||t[27]!==_?(F=_?(0,X.jsx)(Ke,{m:n,progress:g,showLogs:!0,cancelling:v,onCancel:()=>void x()}):null,t[23]=x,t[24]=v,t[25]=n,t[26]=g,t[27]=_,t[28]=F):F=t[28];let I;t[29]!==m||t[30]!==d?(I=m?(0,X.jsx)(He,{kind:d===`failed`?`error`:`success`,message:m}):null,t[29]=m,t[30]=d,t[31]=I):I=t[31];let L;return t[32]!==u||t[33]!==n||t[34]!==T||t[35]!==w||t[36]!==F||t[37]!==I||t[38]!==j||t[39]!==P?(L=(0,X.jsxs)(Be,{icon:ee,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:w,statusDetail:T,m:n,embedded:u,primaryAction:j,children:[P,F,I]}),t[32]=u,t[33]=n,t[34]=T,t[35]=w,t[36]=F,t[37]=I,t[38]=j,t[39]=P,t[40]=L):L=t[40],L}async function at(e){let t=await g(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await g(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var ot={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function st(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function ct(e){let[t,n]=(0,J.useReducer)(st,ot),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,J.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await at(v(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,J.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await at(v(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),l=(0,J.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),u=(0,J.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),d=(0,J.useCallback)(async()=>at(v(`/api/browser/cloakbrowser/status`)),[]),f=(0,J.useCallback)(async()=>$(v(`/api/browser/cloakbrowser/launch`),{}),[]),p=e.browserEnabled===!0&&e.probeExtension===!0,m=e.browserEnabled===!0&&e.probeLocal===!0,h=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:_,extensionPort:y}=e,b=(0,J.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});_&&e.set(`host`,_),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await g(v(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[_,y]),x=(0,J.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await at(v(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,J.useCallback)(async e=>{let t=(await $(v(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/open`),{action:`folder`})},[]);(0,J.useEffect)(()=>{if(!m){n({type:`playwright-idle`});return}s()},[m,s]),(0,J.useEffect)(()=>{if(!h){n({type:`cloak-idle`});return}c()},[h,c]);let T=(0,J.useRef)(p);T.current!==p&&(T.current=p,p||n({type:`extension-idle`})),(0,J.useEffect)(()=>{if(!p)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[p,b,x]);let E=(0,J.useCallback)(async e=>{await $(v(`/api/browser/extension/start`),{host:e?.host??_,port:e?.port??y}),await b()},[_,y,b]),D=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!p||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${_}:${y??19820}`;k.current!==t&&(k.current=t,E({host:_,port:y}).catch(()=>{k.current=null}))},[p,a,_,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:u,fetchCloakRuntimeStatus:d,launchCloak:f,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,J.useCallback)(async e=>$(v(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,J.useCallback)(async(e,t)=>$(v(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,J.useCallback)(async e=>$(v(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,J.useCallback)(async e=>{await $(v(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,J.useCallback)(async()=>(await at(v(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var lt=`
3
3
 
4
4
  `,ut=/\r\n/g,dt={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},ft={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},pt=8;function mt(){return{phase:null,message:null,percent:null,lines:[]}}function ht(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>pt?r.slice(-8):r}return n}async function gt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{l as r}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as i}from"./pencil-DmIY3Oa-.js";import{n as a}from"./locale-store-CMZljTJx.js";import{t as o}from"./button-CtTvuElV.js";import{t as s}from"./skeleton-BwbyijEw.js";import{Al as c,Es as l,Gl as u,Is as d,cc as f,kl as p,oa as m,pl as h,xl as g}from"./index-B0WJL9N1.js";import{i as _,n as v,r as y,t as b}from"./browser-workflow-inputs-CRnkgZHI.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read_only:`Reads information`,account_write:`Changes account data`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read_only:`仅读取信息`,account_write:`会修改账户数据`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{l as r}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as i}from"./pencil-DmIY3Oa-.js";import{n as a}from"./locale-store-CMZljTJx.js";import{t as o}from"./button-CtTvuElV.js";import{t as s}from"./skeleton-BwbyijEw.js";import{Al as c,Es as l,Gl as u,Is as d,cc as f,kl as p,oa as m,pl as h,xl as g}from"./index-DUz0O54y.js";import{i as _,n as v,r as y,t as b}from"./browser-workflow-inputs-CRnkgZHI.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read_only:`Reads information`,account_write:`Changes account data`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read_only:`仅读取信息`,account_write:`会修改账户数据`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
2
2
  `):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${T(t)}`).join(`
3
3
  `):String(e)}function E(){let e=a(e=>e.language),t=C[e],n=r(),E=m(e=>e.setPageHeader),D=m(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.workflows),j(t=>t&&e.workflows.some(e=>e.id===t)?t:e.workflows[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(o,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(u,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,S.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:G}),()=>D()),[D,G,E,t.subtitle,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(s,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(s,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md rounded-2xl border border-edge bg-surface-base p-8 text-center`,children:[(0,S.jsx)(u,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(o,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(u,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(p,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(c,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(h,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(o,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(c,{className:`size-4`}):(0,S.jsx)(p,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(i,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{workflow:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(o,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(f,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(d,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(g,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(o,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(l,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserWorkflowsPage};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,p as o,r as s,t as c}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CpzYSoz7.js";import{n as g,r as _,t as v}from"./popover-select-C-Hj-nXR.js";import{t as y}from"./circle-check-C23XjkUj.js";import{t as b}from"./cloud-C4-yfnnk.js";import{t as x}from"./external-link-DjqjBmc3.js";import{t as S}from"./eye-CABVeTq0.js";import{t as C}from"./globe-DSSGFWFn.js";import{t as w}from"./loader-circle-CifKLtgG.js";import{t as T}from"./pencil-DmIY3Oa-.js";import{t as E}from"./plus-Q2yW6OE7.js";import{t as D}from"./search-DA7gz22f.js";import{t as O}from"./x-B_N4OPjy.js";import{t as k}from"./messages-CTSgFlE4.js";import{a as A,i as j,n as M,r as N,s as P}from"./locale-store-CMZljTJx.js";import{t as F}from"./cn-JdwAhgNB.js";import{i as I}from"./vendor-swr-BIWyz7Rc.js";import{t as L}from"./button-CtTvuElV.js";import{n as R,t as ee}from"./interaction-BmQogeqz.js";import{n as z,r as B}from"./gateway-config-swr-BC3pgb_P.js";import{a as V,o as H,s as U}from"./form-field-width-DJw_jULe.js";import{n as W}from"./is-masked-secret-DOkL5b_X.js";import{t as G}from"./skeleton-BwbyijEw.js";import{i as K,o as te}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as q,t as ne}from"./registry-api-CWOtPFrE.js";import{i as J,n as Y,r as X,t as re}from"./models-hub-cache-ZrbGRiGY.js";import{a as ie,i as ae,n as oe,o as se,r as ce,t as le}from"./oauth-api-4VeMbkTJ.js";import{$ as ue,$l as de,Ec as fe,Es as pe,Fi as me,Fl as he,Ga as ge,Gc as _e,Hs as ve,Ii as ye,Is as be,Ja as xe,Q as Se,Qa as Ce,Ql as we,Ts as Te,Vc as Ee,Wt as De,X as Oe,Xl as ke,Y as Ae,Ys as je,Z as Me,Za as Ne,_s as Pe,_t as Fe,ao as Ie,at as Le,cc as Re,co as ze,ct as Be,do as Ve,dt as He,ec as Ue,eo as We,et as Ge,ft as Ke,gs as qe,gt as Je,ht as Ye,it as Xe,lt as Ze,nt as Qe,oo as $e,ot as et,pt as tt,qa as nt,qt as rt,ri as it,ro as at,rt as ot,sc as st,so as ct,st as lt,tt as ut,uo as dt,ut as ft,vt as pt,xc as mt,yt as ht}from"./index-B0WJL9N1.js";import{n as gt,r as _t}from"./settings-page-layout-BRQNel6r.js";import{t as vt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as yt,t as bt}from"./settings-form-section-DjWzRk4z.js";import{n as xt,r as St,t as Ct}from"./oauth-authorization-window-Cdolr2wE.js";import{n as wt,t as Tt}from"./use-autosave-D88VGoyG.js";import{a as Et,c as Dt,d as Ot,f as kt,h as At,i as jt,l as Mt,n as Nt,o as Pt,p as Ft,r as It,t as Lt,u as Rt}from"./voice-config-api-MqyI6cgq.js";import{t as zt}from"./voice-api-key-field-CBHLsMcc.js";import{t as Bt}from"./page-tabs-BaEQMYm_.js";import{t as Vt}from"./settings-advanced-gate-D4EMxWAZ.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./image-generation-api-D1qlQA-A.js";var Z=n(),Q=e(t(),1),$=r(),Jt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Yt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Xt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Zt(e){let t=e.split(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,p as o,r as s,t as c}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CpzYSoz7.js";import{n as g,r as _,t as v}from"./popover-select-C-Hj-nXR.js";import{t as y}from"./circle-check-C23XjkUj.js";import{t as b}from"./cloud-C4-yfnnk.js";import{t as x}from"./external-link-DjqjBmc3.js";import{t as S}from"./eye-CABVeTq0.js";import{t as C}from"./globe-DSSGFWFn.js";import{t as w}from"./loader-circle-CifKLtgG.js";import{t as T}from"./pencil-DmIY3Oa-.js";import{t as E}from"./plus-Q2yW6OE7.js";import{t as D}from"./search-DA7gz22f.js";import{t as O}from"./x-B_N4OPjy.js";import{t as k}from"./messages-CTSgFlE4.js";import{a as A,i as j,n as M,r as N,s as P}from"./locale-store-CMZljTJx.js";import{t as F}from"./cn-JdwAhgNB.js";import{i as I}from"./vendor-swr-BIWyz7Rc.js";import{t as L}from"./button-CtTvuElV.js";import{n as R,t as ee}from"./interaction-BmQogeqz.js";import{n as z,r as B}from"./gateway-config-swr-BC3pgb_P.js";import{a as V,o as H,s as U}from"./form-field-width-DJw_jULe.js";import{n as W}from"./is-masked-secret-DOkL5b_X.js";import{t as G}from"./skeleton-BwbyijEw.js";import{i as K,o as te}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as q,t as ne}from"./registry-api-CWOtPFrE.js";import{i as J,n as Y,r as X,t as re}from"./models-hub-cache-ZrbGRiGY.js";import{a as ie,i as ae,n as oe,o as se,r as ce,t as le}from"./oauth-api-4VeMbkTJ.js";import{$ as ue,$l as de,Ec as fe,Es as pe,Fi as me,Fl as he,Ga as ge,Gc as _e,Hs as ve,Ii as ye,Is as be,Ja as xe,Q as Se,Qa as Ce,Ql as we,Ts as Te,Vc as Ee,Wt as De,X as Oe,Xl as ke,Y as Ae,Ys as je,Z as Me,Za as Ne,_s as Pe,_t as Fe,ao as Ie,at as Le,cc as Re,co as ze,ct as Be,do as Ve,dt as He,ec as Ue,eo as We,et as Ge,ft as Ke,gs as qe,gt as Je,ht as Ye,it as Xe,lt as Ze,nt as Qe,oo as $e,ot as et,pt as tt,qa as nt,qt as rt,ri as it,ro as at,rt as ot,sc as st,so as ct,st as lt,tt as ut,uo as dt,ut as ft,vt as pt,xc as mt,yt as ht}from"./index-DUz0O54y.js";import{n as gt,r as _t}from"./settings-page-layout-BRQNel6r.js";import{t as vt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as yt,t as bt}from"./settings-form-section-DjWzRk4z.js";import{n as xt,r as St,t as Ct}from"./oauth-authorization-window-Cdolr2wE.js";import{n as wt,t as Tt}from"./use-autosave-TwuAycG8.js";import{a as Et,c as Dt,d as Ot,f as kt,h as At,i as jt,l as Mt,n as Nt,o as Pt,p as Ft,r as It,t as Lt,u as Rt}from"./voice-config-api-MqyI6cgq.js";import{t as zt}from"./voice-api-key-field-CzwG5plu.js";import{t as Bt}from"./page-tabs-BaEQMYm_.js";import{t as Vt}from"./settings-advanced-gate-CSYy6SUa.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./image-generation-api-D1qlQA-A.js";var Z=n(),Q=e(t(),1),$=r(),Jt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Yt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Xt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Zt(e){let t=e.split(`
2
2
  `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Qt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Jt[i],[s,c]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,C]=(0,Q.useState)(`bearer`),[T,D]=(0,Q.useState)(`x-api-key`),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[I,R]=(0,Q.useState)(`/images/generations`),[ee,z]=(0,Q.useState)(`/images/edits`),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[G,q]=(0,Q.useState)([Xt()]),[ne,J]=(0,Q.useState)(``),[Y,X]=(0,Q.useState)(),[re,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(),[se,ce]=(0,Q.useState)(),[le,ue]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),_(t?.name??``),b(n?.baseUrl??``),C(t?.auth.type??`bearer`),D(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),A(r?`••••••••••••`:``),M(t?.apiKeyUrl??``),P(t?.documentationUrl??``),R(t?.paths?.generations??`/images/generations`),z(t?.paths?.edits??`/images/edits`),V(t?.network?.allowedHosts.join(`
3
3
  `)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
4
4
  `)),q(t?.models.map(Xt)??[Xt()]),J(t?.defaultModel??``),ce(void 0),X(void 0),ie(!1),oe(void 0),ue(void 0)},[r,e,n]);let de=(0,Q.useMemo)(()=>G.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[G]),fe=(e,t)=>{q(n=>n.map((n,r)=>r===e?{...n,...t}:n))},me=()=>{let e=s.trim(),t=G.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!g.trim()||!y.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Zt(H)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:y.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:g.trim(),...N.trim()?{documentationUrl:N.trim()}:{},...j.trim()?{apiKeyUrl:j.trim()}:{},defaultModel:n,auth:x===`header`?{type:`header`,headerName:T.trim()}:{type:x},paths:{...I.trim()?{generations:I.trim()}:{},...ee.trim()?{edits:ee.trim()}:{}},...B.trim()?{network:{allowedHosts:B.split(`