@xopcai/xopc 0.0.241 → 0.0.242

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 (116) 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/{activity-store-CLnbVm9G.js → activity-store-MU5XrVv8.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DuBewmbW.js → agent-avatar-dicebear-B_Wc0wuL.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DbdgX6AA.js → agent-defaults-settings-panel-Cf7U2aUi.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agents-BX3uRVm4.js → agents-Ce9oOnwE.js} +1 -1
  7. package/dist/gateway/static/root/assets/{api-DjBZe303.js → api-DLyc8BQp.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-D8evZyFQ.js → app-management-settings-panel-CACOOS-a.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-B-iul0RG.js → appearance-settings-DB5gEQhN.js} +1 -1
  10. package/dist/gateway/static/root/assets/{apps-page-CoZd_cZu.js → apps-page-BaTFOCmR.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Cfk1lwBo.js → attachment-load-CYnYIyLr.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-BTSGvaeS.js → automations-page-ChTflpmA.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-workspace-C8RRKT-a.js → automations-workspace-DK6EreCr.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-ChZyZK45.js → binary-plugins-BjbLfNwG.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-DCH9b2Ht.js → block-editor-DgAs5aJc.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-D1GPwIfx.js → browser-settings-page-CHStw5UW.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-jvfcgFG-.js → browser-workflow-inputs-DGQxD0vD.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-DrHW7XNi.js → browser-workflows-page-B9gfdd7L.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CrXB1Q-l.js → capabilities-settings-panel-JGH6Kfkr.js} +6 -6
  20. package/dist/gateway/static/root/assets/{channels-settings-DWMSYaNZ.js → channels-settings-YkUaaWkY.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-status-swr-CC9MFway.js → channels-status-swr-TkU42f-W.js} +1 -1
  22. package/dist/gateway/static/root/assets/{chat-terminal-dock-DeeZrVbV.js → chat-terminal-dock-CWMPcnoN.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-DXTl1fNB.js → connectors-page-BI0FG3gA.js} +1 -1
  24. package/dist/gateway/static/root/assets/{cron-expression-CiqQOeQ3.js → cron-expression-3h3rR0cf.js} +1 -1
  25. package/dist/gateway/static/root/assets/{date-picker-CGAMGPfU.js → date-picker-Bz1sLBEx.js} +1 -1
  26. package/dist/gateway/static/root/assets/{dependency-picker-CxWeUTsc.js → dependency-picker-p9DWR8uU.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-C3QmYO75.js → desktop-pet-D1TDB_gR.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-CAADkWYy.js → desktop-pet-settings-DWPZpoB7.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-debug-page-FQXjDJ8P.js → extension-debug-page-BrRbK2rJ.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-page-BJE1D5Ji.js → extension-page-CD65czfS.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-settings-page-5Ik2tNry.js → extension-settings-page-BRDDKhpi.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-config-api-cTj71t2a.js → gateway-config-api-CjbBsr5M.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-swr-Bxe_R-JH.js → gateway-config-swr-HT7sLeO9.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-settings-KXBUjNcx.js → gateway-settings-BQjmfYD4.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-DJG-I0wW.js → gateway-startup-retry-iBCtaAuT.js} +1 -1
  36. package/dist/gateway/static/root/assets/{heartbeat-settings-C8cVzIcs.js → heartbeat-settings-BzZxLgrw.js} +1 -1
  37. package/dist/gateway/static/root/assets/{home-page-NdWtBda5.js → home-page--9fKq0mL.js} +1 -1
  38. package/dist/gateway/static/root/assets/{image-generation-api-Dc_ojQuj.js → image-generation-api-dj9TNEn2.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-D499B1qS.css +2 -0
  40. package/dist/gateway/static/root/assets/{index-7i2P3312.js → index-J3FsIvTs.js} +8 -8
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-pOKl7blR.js → keyboard-shortcuts-settings-BEnuEPD3.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-app-workbench-page-C_j_od5f.js → local-app-workbench-page-FqG00zS1.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-apps-page-Bi6wwKgm.js → local-apps-page-DXQtppWq.js} +1 -1
  44. package/dist/gateway/static/root/assets/{locale-store-C5wr3_pc.js → locale-store-DVzTJSj2.js} +1 -1
  45. package/dist/gateway/static/root/assets/{logs-page-D6PDZEVP.js → logs-page-c6CfZ8PA.js} +1 -1
  46. package/dist/gateway/static/root/assets/{management-settings-DGlVizWi.js → management-settings-DIpBMWrA.js} +1 -1
  47. package/dist/gateway/static/root/assets/{markdown-split-CXP5zBx_.js → markdown-split-BFHyGwNF.js} +1 -1
  48. package/dist/gateway/static/root/assets/{markdown-view-D6LxlDxr.js → markdown-view-DR3yVwtV.js} +1 -1
  49. package/dist/gateway/static/root/assets/{media-plugins-BsENGLr2.js → media-plugins-BjjMxC5_.js} +1 -1
  50. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DcEz7qcX.js → mobile-pairing-wizard-CHnXZTwb.js} +1 -1
  51. package/dist/gateway/static/root/assets/models-hub-cache-DiXjKuuY.js +1 -0
  52. package/dist/gateway/static/root/assets/{notes-page-D2EqpDyo.js → notes-page-BbvtelJa.js} +1 -1
  53. package/dist/gateway/static/root/assets/notes-workbench-DIR37b-K.js +4 -0
  54. package/dist/gateway/static/root/assets/{oauth-api-C5NVcsKE.js → oauth-api-BB-VYJ5j.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DMhf1rdz.js → product-open-page-CRm9Q66h.js} +1 -1
  56. package/dist/gateway/static/root/assets/{project-detail-page-DDHi0Y4Q.js → project-detail-page-DHiLTiRW.js} +1 -1
  57. package/dist/gateway/static/root/assets/{projects-page-CVMFKpmu.js → projects-page-God7NCcI.js} +1 -1
  58. package/dist/gateway/static/root/assets/{registry-api-FXdFaoWM.js → registry-api-DXsR8oGN.js} +1 -1
  59. package/dist/gateway/static/root/assets/{remote-access-hub-B74aErBY.js → remote-access-hub-YpF0-mx2.js} +1 -1
  60. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DoEfLjPB.js +5 -0
  61. package/dist/gateway/static/root/assets/{schema-form-BUzdHWx6.js → schema-form-BsqpbBDv.js} +1 -1
  62. package/dist/gateway/static/root/assets/{sessions-page-D2wmGNZE.js → sessions-page-CP8O1TxR.js} +1 -1
  63. package/dist/gateway/static/root/assets/settings-advanced-gate-DzdbK3j9.js +1 -0
  64. package/dist/gateway/static/root/assets/{settings-page-C0OBLqpu.js → settings-page-CE7ZcCTK.js} +1 -1
  65. package/dist/gateway/static/root/assets/{setup-status-panel-NpLQkFCh.js → setup-status-panel-CGlne9i0.js} +1 -1
  66. package/dist/gateway/static/root/assets/{share-preview-page-BtbPYaYC.js → share-preview-page-Bn0qMX8V.js} +1 -1
  67. package/dist/gateway/static/root/assets/{shares-settings-rf8f1OGq.js → shares-settings-B7NeVl4g.js} +1 -1
  68. package/dist/gateway/static/root/assets/skill-reload-api-DDTmi4a7.js +1 -0
  69. package/dist/gateway/static/root/assets/{skills-page-CYk8pN97.js → skills-page-dRkeYh5P.js} +1 -1
  70. package/dist/gateway/static/root/assets/{skills-page.utils-DGjnz-NG.js → skills-page.utils--q8p7MAn.js} +1 -1
  71. package/dist/gateway/static/root/assets/{system-settings-panel-DmCRSvtd.js → system-settings-panel-C0ZCuCM4.js} +1 -1
  72. package/dist/gateway/static/root/assets/{task-detail-page-6a2RdDl2.js → task-detail-page-yiMzii2b.js} +1 -1
  73. package/dist/gateway/static/root/assets/{theme-store-DUko1ZnE.js → theme-store-Cth-eChE.js} +1 -1
  74. package/dist/gateway/static/root/assets/{tunnel-api-Chfiba_x.js → tunnel-api-CC3jOB4n.js} +1 -1
  75. package/dist/gateway/static/root/assets/{use-autosave-W_P8Kiv4.js → use-autosave-PSV89QuQ.js} +1 -1
  76. package/dist/gateway/static/root/assets/user-context-page-Vtwg7fQc.js +1 -0
  77. package/dist/gateway/static/root/assets/{voice-api-key-field-BZD0j1jc.js → voice-api-key-field-DXWdJ8cR.js} +1 -1
  78. package/dist/gateway/static/root/assets/{voice-config-api-BO6A8V3Z.js → voice-config-api-BDoeXgww.js} +1 -1
  79. package/dist/gateway/static/root/assets/{work-discovery-overlay-BfwEoOGL.js → work-discovery-overlay-BV_Jj5iD.js} +1 -1
  80. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-X7Z5_lRX.js → workflow-run-setup-panel-DNHbWGPq.js} +1 -1
  81. package/dist/gateway/static/root/assets/{workflows-page-BklMzkg8.js → workflows-page-BkFIbMrz.js} +2 -2
  82. package/dist/gateway/static/root/index.html +11 -11
  83. package/dist/package.js +1 -1
  84. package/dist/src/agent/agent-manager.js +1 -0
  85. package/dist/src/agent/skills/installer.d.ts +1 -0
  86. package/dist/src/agent/skills/installer.js +9 -6
  87. package/dist/src/agent/tools/factory.d.ts +2 -0
  88. package/dist/src/agent/tools/factory.js +5 -1
  89. package/dist/src/config/schema.js +5 -3
  90. package/dist/src/extensions/install.js +1 -1
  91. package/dist/src/gateway/hono/routes/runtime-tools.js +7 -1
  92. package/dist/src/gateway/hono/routes/voice.js +1 -1
  93. package/dist/src/runtime-tools/archive.js +17 -3
  94. package/dist/src/runtime-tools/command.d.ts +1 -0
  95. package/dist/src/runtime-tools/command.js +29 -8
  96. package/dist/src/runtime-tools/environment.d.ts +1 -0
  97. package/dist/src/runtime-tools/environment.js +11 -16
  98. package/dist/src/runtime-tools/install-lock.d.ts +1 -1
  99. package/dist/src/runtime-tools/install-lock.js +34 -21
  100. package/dist/src/runtime-tools/manager.d.ts +1 -1
  101. package/dist/src/runtime-tools/manager.js +99 -64
  102. package/dist/src/runtime-tools/manifest-store.d.ts +2 -0
  103. package/dist/src/runtime-tools/manifest-store.js +29 -8
  104. package/dist/src/runtime-tools/paths.d.ts +2 -1
  105. package/dist/src/runtime-tools/paths.js +19 -8
  106. package/dist/src/runtime-tools/probe.d.ts +2 -0
  107. package/dist/src/runtime-tools/probe.js +13 -1
  108. package/dist/src/runtime-tools/prune.js +21 -7
  109. package/package.json +2 -2
  110. package/dist/gateway/static/root/assets/index-DTo3IcbW.css +0 -2
  111. package/dist/gateway/static/root/assets/models-hub-cache-Y7GUjxHx.js +0 -1
  112. package/dist/gateway/static/root/assets/notes-workbench-Bu0a83Oj.js +0 -4
  113. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Bv-akndY.js +0 -5
  114. package/dist/gateway/static/root/assets/settings-advanced-gate-CYCCUMEt.js +0 -1
  115. package/dist/gateway/static/root/assets/skill-reload-api-BkvclZ_o.js +0 -1
  116. package/dist/gateway/static/root/assets/user-context-page-SeOHP6XO.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-D6LxlDxr.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./pencil-DmIY3Oa-.js";import{t as h}from"./cn-JdwAhgNB.js";import{t as g}from"./copy-to-clipboard-HOJ79TWv.js";import{t as _}from"./messages-_tYhRAHD.js";import{n as v}from"./locale-store-C5wr3_pc.js";import{a as y,d as b,i as x,l as S,n as C,o as w,s as T,t as E,u as D}from"./floating-ui.dom-B7uQOZZW.js";import{s as O}from"./vendor-swr-BIWyz7Rc.js";import{Gs as ee,Hc as te,Ks as ne,Lc as re,Lr as ie,Mr as ae,Nc as oe,Qs as se,Sc as ce,Uc as le,Vr as ue,Wc as de,fc as fe,jr as pe,kr as me,ll as he,ms as ge,ps as _e,rc as ve,wc as ye,xc as be,xs as xe,yc as Se,zl as Ce}from"./index-7i2P3312.js";import{C as we,S as Te}from"./vendor-codemirror--gTq3YAI.js";import{t as Ee}from"./with-selector-aYPsXwdl.js";import{n as De}from"./notes-workbench-Bu0a83Oj.js";var k=e(r(),1),Oe=e(i(),1),A=o(),ke=O();function j(e){this.content=e}j.prototype={constructor:j,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 j(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 j(n)},addToStart:function(e,t){return new j([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new j(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 j(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=j.from(e),e.size?new j(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=j.from(e),e.size?new j(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=j.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}},j.from=function(e){if(e instanceof j)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new j(t)};function Ae(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&&Ne(e.charCodeAt(r-1))&&Me(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Ae(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function je(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&&Ne(e.charCodeAt(i-1))&&Me(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=je(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Me(e){return e>=56320&&e<57344}function Ne(e){return e>=55296&&e<56320}var M=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 Ae(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return je(this,e,t,n)}findIndex(e){if(e==0)return Fe(0,e);if(e==this.size)return Fe(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?Fe(t+1,i):Fe(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)`:``))}};M.empty=new M([],0);var Pe={index:0,offset:0};function Fe(e,t){return Pe.index=e,Pe.offset=t,Pe}function Ie(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(!Ie(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Ie(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var N=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&&Ie(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}};N.none=[];var Le=class extends Error{},P=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=ze(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(Re(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(M.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)}};P.empty=new P(M.empty,0,0);function Re(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(Re(a.content,t-i-1,n-i-1)))}function ze(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=ze(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 Be(e,t,n){if(n.openStart>e.depth)throw new Le(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Le(`Inconsistent open depths`);return Ve(e,t,n,0)}function Ve(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=Ve(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Ke(a,Je(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Ke(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Ye(n,e);return Ke(a,qe(e,i,o,t,r))}}function He(e,t){if(!t.type.compatibleContent(e.type))throw new Le(`Cannot join `+t.type.name+` onto `+e.type.name)}function Ue(e,t,n){let r=e.node(n);return He(r,t.node(n)),r}function We(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 Ge(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&&(We(e.nodeAfter,r),a++));for(let e=a;e<o;e++)We(i.child(e),r);t&&t.depth==n&&t.textOffset&&We(t.nodeBefore,r)}function Ke(e,t){if(!e.type.validContent(t))throw new Le(`Invalid content for node `+e.type.name);return e.copy(t)}function qe(e,t,n,r,i){let a=e.depth>i&&Ue(e,t,i+1),o=r.depth>i&&Ue(n,r,i+1),s=[];return Ge(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(He(a,o),We(Ke(a,qe(e,t,n,r,i+1)),s)):(a&&We(Ke(a,Je(e,t,i+1)),s),Ge(t,n,i,s),o&&We(Ke(o,Je(n,r,i+1)),s)),Ge(r,null,i,s),new M(s)}function Je(e,t,n){let r=[];return Ge(null,e,n,r),e.depth>n&&We(Ke(Ue(e,t,n+1),Je(e,t,n+1)),r),Ge(t,null,n,r),new M(r)}function Ye(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(M.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Xe=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 N.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 et(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=$e.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 $e.set(t,r=new Ze);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Qe,i}},Ze=class{constructor(){this.elts=[],this.i=0}},Qe=12,$e=new WeakMap,et=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)}},tt=Object.create(null),nt=class e{constructor(e,t,n,r=N.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||M.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&&Ie(this.attrs,t||e.defaultAttrs||tt)&&N.sameSet(this.marks,n||N.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 P.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new P(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Be(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 Xe.resolveCached(this,e)}resolveNoCache(e){return Xe.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()+`)`),it(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=M.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=N.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(!N.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=M.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};nt.prototype.text=void 0;var rt=class e extends nt{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):it(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 it(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var at=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new ot(t,n);if(r.next==null)return e.empty;let i=st(r);r.next&&r.err(`Unexpected trailing text`);let a=_t(mt(i));return vt(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 M.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-DR3yVwtV.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./pencil-DmIY3Oa-.js";import{t as h}from"./cn-JdwAhgNB.js";import{t as g}from"./copy-to-clipboard-HOJ79TWv.js";import{t as _}from"./messages-_tYhRAHD.js";import{n as v}from"./locale-store-DVzTJSj2.js";import{a as y,d as b,i as x,l as S,n as C,o as w,s as T,t as E,u as D}from"./floating-ui.dom-B7uQOZZW.js";import{s as O}from"./vendor-swr-BIWyz7Rc.js";import{Gs as ee,Hc as te,Ks as ne,Lc as re,Lr as ie,Mr as ae,Nc as oe,Qs as se,Sc as ce,Uc as le,Vr as ue,Wc as de,fc as fe,jr as pe,kr as me,ll as he,ms as ge,ps as _e,rc as ve,wc as ye,xc as be,xs as xe,yc as Se,zl as Ce}from"./index-J3FsIvTs.js";import{C as we,S as Te}from"./vendor-codemirror--gTq3YAI.js";import{t as Ee}from"./with-selector-aYPsXwdl.js";import{n as De}from"./notes-workbench-DIR37b-K.js";var k=e(r(),1),Oe=e(i(),1),A=o(),ke=O();function j(e){this.content=e}j.prototype={constructor:j,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 j(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 j(n)},addToStart:function(e,t){return new j([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new j(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 j(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=j.from(e),e.size?new j(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=j.from(e),e.size?new j(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=j.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}},j.from=function(e){if(e instanceof j)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new j(t)};function Ae(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&&Ne(e.charCodeAt(r-1))&&Me(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Ae(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function je(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&&Ne(e.charCodeAt(i-1))&&Me(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=je(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Me(e){return e>=56320&&e<57344}function Ne(e){return e>=55296&&e<56320}var M=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 Ae(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return je(this,e,t,n)}findIndex(e){if(e==0)return Fe(0,e);if(e==this.size)return Fe(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?Fe(t+1,i):Fe(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)`:``))}};M.empty=new M([],0);var Pe={index:0,offset:0};function Fe(e,t){return Pe.index=e,Pe.offset=t,Pe}function Ie(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(!Ie(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Ie(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var N=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&&Ie(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}};N.none=[];var Le=class extends Error{},P=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=ze(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(Re(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(M.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)}};P.empty=new P(M.empty,0,0);function Re(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(Re(a.content,t-i-1,n-i-1)))}function ze(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=ze(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 Be(e,t,n){if(n.openStart>e.depth)throw new Le(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Le(`Inconsistent open depths`);return Ve(e,t,n,0)}function Ve(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=Ve(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Ke(a,Je(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Ke(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Ye(n,e);return Ke(a,qe(e,i,o,t,r))}}function He(e,t){if(!t.type.compatibleContent(e.type))throw new Le(`Cannot join `+t.type.name+` onto `+e.type.name)}function Ue(e,t,n){let r=e.node(n);return He(r,t.node(n)),r}function We(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 Ge(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&&(We(e.nodeAfter,r),a++));for(let e=a;e<o;e++)We(i.child(e),r);t&&t.depth==n&&t.textOffset&&We(t.nodeBefore,r)}function Ke(e,t){if(!e.type.validContent(t))throw new Le(`Invalid content for node `+e.type.name);return e.copy(t)}function qe(e,t,n,r,i){let a=e.depth>i&&Ue(e,t,i+1),o=r.depth>i&&Ue(n,r,i+1),s=[];return Ge(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(He(a,o),We(Ke(a,qe(e,t,n,r,i+1)),s)):(a&&We(Ke(a,Je(e,t,i+1)),s),Ge(t,n,i,s),o&&We(Ke(o,Je(n,r,i+1)),s)),Ge(r,null,i,s),new M(s)}function Je(e,t,n){let r=[];return Ge(null,e,n,r),e.depth>n&&We(Ke(Ue(e,t,n+1),Je(e,t,n+1)),r),Ge(t,null,n,r),new M(r)}function Ye(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(M.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Xe=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 N.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 et(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=$e.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 $e.set(t,r=new Ze);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Qe,i}},Ze=class{constructor(){this.elts=[],this.i=0}},Qe=12,$e=new WeakMap,et=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)}},tt=Object.create(null),nt=class e{constructor(e,t,n,r=N.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||M.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&&Ie(this.attrs,t||e.defaultAttrs||tt)&&N.sameSet(this.marks,n||N.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 P.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new P(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Be(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 Xe.resolveCached(this,e)}resolveNoCache(e){return Xe.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()+`)`),it(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=M.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=N.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(!N.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=M.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};nt.prototype.text=void 0;var rt=class e extends nt{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):it(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 it(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var at=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new ot(t,n);if(r.next==null)return e.empty;let i=st(r);r.next&&r.err(`Unexpected trailing text`);let a=_t(mt(i));return vt(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 M.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
  `)}};at.empty=new at(!0);var ot=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 st(e){let t=[];do t.push(ct(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function ct(e){let t=[];do t.push(lt(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function lt(e){let t=pt(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=dt(e,t);else break;return t}function ut(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function dt(e,t){let n=ut(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:ut(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function ft(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 pt(e){if(e.eat(`(`)){let t=st(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=ft(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 mt(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 ht(e,t){return t-e}function gt(e,t){let n=[];return r(t),n.sort(ht);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 _t(e){let t=Object.create(null);return n(gt(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]);gt(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new at(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ht);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function vt(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 yt(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 bt(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 xt(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 St(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Tt(e,r,t[r]);return n}var Ct=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=St(e,n.attrs),this.defaultAttrs=yt(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==at.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:bt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new nt(this,this.computeAttrs(e),M.from(t),N.setFrom(n))}createChecked(e=null,t,n){return t=M.from(t),this.checkContent(t),new nt(this,this.computeAttrs(e),t,N.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=M.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(M.empty,!0);return i?new nt(this,e,t.append(i),N.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){xt(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:N.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 wt(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 Tt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?wt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Et=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=St(e,r.attrs),this.excluded=null;let i=yt(this.attrs);this.instance=i?new N(this,i):null}create(e=null){return!e&&this.instance?this.instance:new N(this,bt(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){xt(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Dt=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=j.from(e.nodes),t.marks=j.from(e.marks||{}),this.nodes=Ct.compile(this.spec.nodes,this),this.marks=Et.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]=at.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?Ot(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==``?[]:Ot(this,n.split(` `))}this.nodeFromJSON=e=>nt.fromJSON(this,e),this.markFromJSON=e=>N.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 Ct))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 rt(n,n.defaultAttrs,e,N.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 Ot(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 kt(e){return e.tag!=null}function At(e){return e.style!=null}var jt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(kt(e))this.tags.push(e);else if(At(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 Bt(this,t,!1);return n.addAll(e,N.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Bt(this,t,!0);return n.addAll(e,N.none,t.from,t.to),P.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(Ht(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=Ut(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=Ut(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)))}},Mt={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},Nt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pt={ol:!0,ul:!0},Ft=1,It=2,Lt=4;function Rt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Ft:0)|(t===`full`?It:0)}var zt=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=N.none,this.match=i||(a&Lt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.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&Ft)){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=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.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&&!Mt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Bt=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=Rt(null,t.preserveWhitespace,0)|(n?Lt:0);i=r?new zt(r.type,r.attrs,N.none,!0,t.topMatch||r.type.contentMatch,a):n?new zt(null,null,N.none,!0,null,a):new zt(e.schema.topNodeType,null,N.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&It?`full`:this.localPreserveWS||(r.options&Ft)>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;Pt.hasOwnProperty(a)&&this.parser.normalizeLists&&Vt(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Nt.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(Mt.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=N.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Wt(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=Rt(e,i,a.options);a.options&Lt&&a.content.length==0&&(o|=Lt);let s=N.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Wt(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new zt(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|=Ft);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 Vt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Pt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ht(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ut(e){let t={};for(let n in e)t[n]=e[n];return t}function Wt(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 Gt=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=qt(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 qt(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Zt(qt(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&&Zt(qt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Zt(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=Kt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Kt(e.marks)}};function Kt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function qt(e){return e.document||window.document}var Jt=new WeakMap;function Yt(e){let t=Jt.get(e);return t===void 0&&Jt.set(e,t=Xt(e)),t}function Xt(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 Zt(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=Yt(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}=Zt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Qt=a(),$t=65535,en=2**16;function tn(e,t){return e+t*en}function nn(e){return e&$t}function rn(e){return(e-(e&$t))/en}var an=1,on=2,sn=4,cn=8,ln=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&cn)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&sn)>0}},un=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=nn(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+rn(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:tn(o/3,e-s),f=e==s?on:e==u?an:sn;return(t<0?e!=s:e!=u)&&(f|=cn),new ln(a,f,d)}r+=l-c}return n?e+r:new ln(e+r,0,null)}touches(e,t){let n=0,r=nn(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])}};un.empty=new un([]);var dn=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 ln(e,r,null)}},fn=Object.create(null),pn=class{getMap(){return un.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=fn[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in fn)throw RangeError(`Duplicate use of step JSON ID `+e);return fn[e]=t,t.prototype.jsonID=e,t}},mn=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 Le)return e.fail(t.message);throw t}}};function hn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(hn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return M.fromArray(r)}var gn=class e extends pn{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 P(hn(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 mn.fromReplace(e,this.from,this.to,i)}invert(){return new _n(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))}};pn.jsonID(`addMark`,gn);var _n=class e extends pn{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 P(hn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return mn.fromReplace(e,this.from,this.to,n)}invert(){return new gn(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))}};pn.jsonID(`removeMark`,_n);var vn=class e extends pn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return mn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return mn.fromReplace(e,this.pos,this.pos+1,new P(M.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 yn(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))}};pn.jsonID(`addNodeMark`,vn);var yn=class e extends pn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return mn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return mn.fromReplace(e,this.pos,this.pos+1,new P(M.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new vn(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))}};pn.jsonID(`removeNodeMark`,yn);var bn=class e extends pn{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Sn(e,this.from,this.to)?mn.fail(`Structure replace would overwrite content`):mn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new un([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?P.empty:new P(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?P.empty:new P(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,P.fromJSON(t,n.slice),!!n.structure)}};bn.MAP_BIAS=1,pn.jsonID(`replace`,bn);var xn=class e extends pn{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&&(Sn(e,this.from,this.gapFrom)||Sn(e,this.gapTo,this.to)))return mn.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return mn.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?mn.fromReplace(e,this.from,this.to,n):mn.fail(`Content does not fit in gap`)}getMap(){return new un([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,P.fromJSON(t,n.slice),n.insert,!!n.structure)}};pn.jsonID(`replaceAround`,xn);function Sn(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 Cn(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 _n(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new gn(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function wn(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 Et){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 _n(t.from,t.to,t.style)))}function Tn(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 bn(s,l,P.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new _n(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 P(M.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new bn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(M.empty,!0);e.replace(s,s,new P(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function En(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Dn(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||!En(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function On(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=M.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=M.from(r.node(e).copy(u)),d++):c--;let f=M.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=M.from(i.node(e).copy(f)),p++):l++;e.step(new xn(c,l,o,s,new P(u.append(f),d,p),u.size-d,!0))}function kn(e,t,n=null,r=e){let i=jn(e,t),a=i&&Mn(r,t);return a?i.map(An).concat({type:t,attrs:n}).concat(a.map(An)):null}function An(e){return{type:e,attrs:null}}function jn(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 Mn(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 Nn(e,t,n){let r=M.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=M.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new xn(i,a,i,a,new P(r,0,0),n.length,!0))}function Pn(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)&&Ln(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&&In(e,t,n,a),Tn(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 xn(c,l,c+1,l-1,new P(M.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Fn(e,t,n,a),!1}})}function Fn(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 In(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-DrILF6mR.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"./cn-JdwAhgNB.js";import{t as m}from"./button-CSEbl4zT.js";import{a as h,o as g,s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-_tYhRAHD.js";import{a as b,i as x,n as S,r as C,s as w}from"./locale-store-C5wr3_pc.js";import{n as T,r as E}from"./gateway-config-swr-Bxe_R-JH.js";import{$s as D,El as O,Es as k,Fa as A,Fs as j,Is as M,Js as N,Ko as P,Ms as F,Na as I,Pa as L,Qo as R,Qs as z,Ws as B,Zn as V,Zs as H,dc as ee,es as U,fs as te,gl as W,hl as ne,hs as G,is as K,ol as re,ta as ie,yl as ae}from"./index-7i2P3312.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-W_P8Kiv4.js";import{t as pe}from"./page-tabs-BaEQMYm_.js";import{t as me}from"./settings-advanced-gate-CYCCUMEt.js";import{a as he,c as ge,d as _e,u as ve}from"./gateway-config-api-cTj71t2a.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 p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function be(){return p(g,h)}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=p(be(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let m;t[16]===r?m=t[17]:(m=e=>r(e.target.value),t[16]=r,t[17]=m);let h=s.browserPickerTitle,g;t[18]===o?g=t[19]:(g=o.map(Ce),t[18]=o,t[19]=g);let _;t[20]!==s.browserPickerTitle||t[21]!==m||t[22]!==g||t[23]!==n?(_=(0,X.jsx)(a,{id:`browser-backend-select`,className:f,value:n,onChange:m,"aria-label":h,children:g}),t[20]=s.browserPickerTitle,t[21]=m,t[22]=g,t[23]=n,t[24]=_):_=t[24];let v=i?(0,X.jsxs)(`button`,{type:`button`,className:p(`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,y;t[25]!==v||t[26]!==_?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[_,v]}),t[25]=v,t[26]=_,t[27]=y):y=t[27],c=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,y,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:p(`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:F,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 A;t[45]!==n.desc.browserDialogTimeout||t[46]!==n.label.browserDialogTimeout||t[47]!==k?(A=(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]=A):A=t[48];let j;t[49]!==S||t[50]!==A||t[51]!==p?(j=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,A]}),t[49]=S,t[50]=A,t[51]=p,t[52]=j):j=t[52];let N;t[53]!==c||t[54]!==j?(N=(0,X.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{children:[c,j]})}),t[53]=c,t[54]=j,t[55]=N):N=t[55];let P;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(P=we(`security`),t[56]=P):P=t[56];let I;t[57]===n.browserSecurityShow?I=t[58]:(I=(0,X.jsx)(ue,{icon:M,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 H=n.label.browserCommandTimeout,ee=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 ne;t[76]===i?ne=t[77]:(ne=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[76]=i,t[77]=ne);let G;t[78]!==te||t[79]!==W||t[80]!==ne?(G=(0,X.jsx)(ye,{type:`number`,className:U,min:5,value:te,suggestion:`30`,onAcceptSuggestion:W,placeholder:`30`,onChange:ne}),t[78]=te,t[79]=W,t[80]=ne,t[81]=G):G=t[81];let K;t[82]!==n.desc.browserCommandTimeout||t[83]!==n.label.browserCommandTimeout||t[84]!==G?(K=(0,X.jsx)(Z,{label:H,description:ee,children:G}),t[82]=n.desc.browserCommandTimeout,t[83]=n.label.browserCommandTimeout,t[84]=G,t[85]=K):K=t[85];let re;t[86]!==V||t[87]!==K?(re=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[V,K]}),t[86]=V,t[87]=K,t[88]=re):re=t[88];let ie;t[89]!==I||t[90]!==re?(ie=(0,X.jsx)(`div`,{id:P,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{className:`border border-amber-500/20`,children:[I,re]})}),t[89]=I,t[90]=re,t[91]=ie):ie=t[91];let ae;return t[92]!==N||t[93]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[N,ie]}),t[92]=N,t[93]=ie,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=P(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=p(`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=p(`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 m;t[5]!==i||t[6]!==a?(m=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]=m):m=t[7];let h;t[8]!==f||t[9]!==m?(h=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(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]=v):v=t[16];let y;t[17]!==d||t[18]!==_?(y=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,_,v]}),t[17]=d,t[18]=_,t[19]=y):y=t[19];let b;t[20]===c?b=t[21]:(b=(0,X.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=b);let x;return t[22]!==s||t[23]!==l||t[24]!==y||t[25]!==b?(x=(0,X.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[y,b]}),t[22]=s,t[23]=l,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function ke(e){let t=(0,Y.c)(25),{m:n,onStart:r}=e,i=V(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:N,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:j,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:G,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:f,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:ae,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:W,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=p(`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=p(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let m;t[12]!==a||t[13]!==d?(m=(0,X.jsx)(a,{className:d}),t[12]=a,t[13]=d,t[14]=m):m=t[14];let h;t[15]===o?h=t[16]:(h=(0,X.jsx)(`span`,{children:o}),t[15]=o,t[16]=h);let g;t[17]!==c||t[18]!==m||t[19]!==h?(g=(0,X.jsxs)(`span`,{className:c,children:[m,h]}),t[17]=c,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=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]=_);let v;return t[23]!==l||t[24]!==g||t[25]!==_?(v=(0,X.jsxs)(`span`,{className:l,children:[g,_]}),t[23]=l,t[24]=g,t[25]=_,t[26]=v):v=t[26],v}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=p(`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)(A,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:z,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)(z,{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)(k,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,X.jsxs)(Be,{icon:K,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)(H,{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)(A,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,k=t.kind===`ok`?t.data:null,M=k?.installed===!0,N=v===`installing`||w,P=(0,J.useCallback)(async()=>{if(M)try{g({type:`patch`,patch:{runtime:await c()}})}catch{}},[c,M]);(0,J.useEffect)(()=>{if(!M){g({type:`patch`,patch:{runtime:null}});return}P();let e=setInterval(()=>void P(),8e3);return()=>clearInterval(e)},[M,P]);let F=(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 P()},[r,d.binaryPath,d.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,P,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`:M?`ready`:`not_installed`,R=M&&k?.version?`v${k.version} (${k.platform})`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{icon:j,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:[M?(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)(z,{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:N,onClick:()=>g({type:`patch`,patch:{confirmOpen:!0}}),children:[N?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):M?(0,X.jsx)(B,{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`}),N?e.browserCloakInstalling:M?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,M&&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:j,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,k),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void F(),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-DrILF6mR.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"./cn-JdwAhgNB.js";import{t as m}from"./button-CSEbl4zT.js";import{a as h,o as g,s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-_tYhRAHD.js";import{a as b,i as x,n as S,r as C,s as w}from"./locale-store-DVzTJSj2.js";import{n as T,r as E}from"./gateway-config-swr-HT7sLeO9.js";import{$s as D,El as O,Es as k,Fa as A,Fs as j,Is as M,Js as N,Ko as P,Ms as F,Na as I,Pa as L,Qo as R,Qs as z,Ws as B,Zn as V,Zs as H,dc as ee,es as U,fs as te,gl as W,hl as ne,hs as G,is as K,ol as re,ta as ie,yl as ae}from"./index-J3FsIvTs.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-PSV89QuQ.js";import{t as pe}from"./page-tabs-BaEQMYm_.js";import{t as me}from"./settings-advanced-gate-DzdbK3j9.js";import{a as he,c as ge,d as _e,u as ve}from"./gateway-config-api-CjbBsr5M.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 p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function be(){return p(g,h)}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=p(be(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let m;t[16]===r?m=t[17]:(m=e=>r(e.target.value),t[16]=r,t[17]=m);let h=s.browserPickerTitle,g;t[18]===o?g=t[19]:(g=o.map(Ce),t[18]=o,t[19]=g);let _;t[20]!==s.browserPickerTitle||t[21]!==m||t[22]!==g||t[23]!==n?(_=(0,X.jsx)(a,{id:`browser-backend-select`,className:f,value:n,onChange:m,"aria-label":h,children:g}),t[20]=s.browserPickerTitle,t[21]=m,t[22]=g,t[23]=n,t[24]=_):_=t[24];let v=i?(0,X.jsxs)(`button`,{type:`button`,className:p(`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,y;t[25]!==v||t[26]!==_?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[_,v]}),t[25]=v,t[26]=_,t[27]=y):y=t[27],c=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,y,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:p(`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:F,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 A;t[45]!==n.desc.browserDialogTimeout||t[46]!==n.label.browserDialogTimeout||t[47]!==k?(A=(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]=A):A=t[48];let j;t[49]!==S||t[50]!==A||t[51]!==p?(j=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,A]}),t[49]=S,t[50]=A,t[51]=p,t[52]=j):j=t[52];let N;t[53]!==c||t[54]!==j?(N=(0,X.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{children:[c,j]})}),t[53]=c,t[54]=j,t[55]=N):N=t[55];let P;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(P=we(`security`),t[56]=P):P=t[56];let I;t[57]===n.browserSecurityShow?I=t[58]:(I=(0,X.jsx)(ue,{icon:M,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 H=n.label.browserCommandTimeout,ee=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 ne;t[76]===i?ne=t[77]:(ne=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[76]=i,t[77]=ne);let G;t[78]!==te||t[79]!==W||t[80]!==ne?(G=(0,X.jsx)(ye,{type:`number`,className:U,min:5,value:te,suggestion:`30`,onAcceptSuggestion:W,placeholder:`30`,onChange:ne}),t[78]=te,t[79]=W,t[80]=ne,t[81]=G):G=t[81];let K;t[82]!==n.desc.browserCommandTimeout||t[83]!==n.label.browserCommandTimeout||t[84]!==G?(K=(0,X.jsx)(Z,{label:H,description:ee,children:G}),t[82]=n.desc.browserCommandTimeout,t[83]=n.label.browserCommandTimeout,t[84]=G,t[85]=K):K=t[85];let re;t[86]!==V||t[87]!==K?(re=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[V,K]}),t[86]=V,t[87]=K,t[88]=re):re=t[88];let ie;t[89]!==I||t[90]!==re?(ie=(0,X.jsx)(`div`,{id:P,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{className:`border border-amber-500/20`,children:[I,re]})}),t[89]=I,t[90]=re,t[91]=ie):ie=t[91];let ae;return t[92]!==N||t[93]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[N,ie]}),t[92]=N,t[93]=ie,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=P(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=p(`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=p(`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 m;t[5]!==i||t[6]!==a?(m=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]=m):m=t[7];let h;t[8]!==f||t[9]!==m?(h=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(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]=v):v=t[16];let y;t[17]!==d||t[18]!==_?(y=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,_,v]}),t[17]=d,t[18]=_,t[19]=y):y=t[19];let b;t[20]===c?b=t[21]:(b=(0,X.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=b);let x;return t[22]!==s||t[23]!==l||t[24]!==y||t[25]!==b?(x=(0,X.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[y,b]}),t[22]=s,t[23]=l,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function ke(e){let t=(0,Y.c)(25),{m:n,onStart:r}=e,i=V(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:N,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:j,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:G,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:f,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:ae,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:W,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=p(`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=p(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let m;t[12]!==a||t[13]!==d?(m=(0,X.jsx)(a,{className:d}),t[12]=a,t[13]=d,t[14]=m):m=t[14];let h;t[15]===o?h=t[16]:(h=(0,X.jsx)(`span`,{children:o}),t[15]=o,t[16]=h);let g;t[17]!==c||t[18]!==m||t[19]!==h?(g=(0,X.jsxs)(`span`,{className:c,children:[m,h]}),t[17]=c,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=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]=_);let v;return t[23]!==l||t[24]!==g||t[25]!==_?(v=(0,X.jsxs)(`span`,{className:l,children:[g,_]}),t[23]=l,t[24]=g,t[25]=_,t[26]=v):v=t[26],v}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=p(`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)(A,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:z,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)(z,{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)(k,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,X.jsxs)(Be,{icon:K,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)(H,{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)(A,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,k=t.kind===`ok`?t.data:null,M=k?.installed===!0,N=v===`installing`||w,P=(0,J.useCallback)(async()=>{if(M)try{g({type:`patch`,patch:{runtime:await c()}})}catch{}},[c,M]);(0,J.useEffect)(()=>{if(!M){g({type:`patch`,patch:{runtime:null}});return}P();let e=setInterval(()=>void P(),8e3);return()=>clearInterval(e)},[M,P]);let F=(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 P()},[r,d.binaryPath,d.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,P,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`:M?`ready`:`not_installed`,R=M&&k?.version?`v${k.version} (${k.platform})`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{icon:j,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:[M?(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)(z,{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:N,onClick:()=>g({type:`patch`,patch:{confirmOpen:!0}}),children:[N?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):M?(0,X.jsx)(B,{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`}),N?e.browserCloakInstalling:M?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,M&&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:j,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,k),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void F(),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,m=y(S(e=>e.language)).providersSettings,h=R({show:m.show,hide:m.hide,copy:m.copy,copied:m.copied}),g=(0,J.useCallback)(()=>he().then(e=>e.apiKey??null),[]),_=(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 _(),children:[s===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{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)(U,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:p===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:h,reveal:g,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,m;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(m={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=m):m=t[2];let h=!!i&&a,g;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?(g=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]=g):g=t[15];let _;t[16]!==n.browserExtensionInstallStep2||t[17]!==h||t[18]!==g?(_={id:`load`,label:n.browserExtensionInstallStep2,done:h,detail:g},t[16]=n.browserExtensionInstallStep2,t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==a||t[21]!==n.browserExtensionInstallStep3?(v={id:`connect`,label:n.browserExtensionInstallStep3,done:a},t[20]=a,t[21]=n.browserExtensionInstallStep3,t[22]=v):v=t[22];let y;t[23]!==m||t[24]!==_||t[25]!==v?(y=[m,_,v],t[23]=m,t[24]=_,t[25]=v,t[26]=y):y=t[26];let b=y,x;t[27]===b?x=t[28]:(x=b.filter(et),t[27]=b,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]!==b.length?(T=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(S)).replace(`{{total}}`,String(b.length)),t[31]=S,t[32]=n.browserExtensionChecklistProgress,t[33]=b.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]!==b?(O=(0,X.jsx)(`ol`,{className:`flex flex-col gap-3`,children:b.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)(ne,{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:p(`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]=b,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:p,embedded:m=!1}){let[h,g]=(0,J.useState)(null),[_,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),S=p.port??tt,C=p.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,O=t.kind===`ok`&&t.data.bridgeHeld===!0,A=t.kind===`ok`&&t.data.portConflict===!0,j=T||O,M=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,P=M?.installed===!0,F=M?.extensionDir,I=M?.needsChromeReload===!0,L=t.kind===`ok`?E?{icon:D,color:`text-green-500`,label:e.browserExtensionConnected}:T?{icon:H,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:te,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:te,color:`text-fg-muted`,label:`…`},R=L.icon,B=(0,J.useCallback)(async()=>{if(!h){g(`start`),y(null);try{await i({host:C,port:S})}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,C,S,i]),V=(0,J.useCallback)(async()=>{if(!h){g(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,a]),ee=(0,J.useCallback)(async()=>{if(!h){g(`disconnect`),y(null);try{await o()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,o]),U=(0,J.useCallback)(async()=>{if(!h){g(`install`),y(null),x(null);try{let t=await s({force:P});t?.extensionDir?x(`${e.browserExtensionInstalled}: ${t.extensionDir}`):x(e.browserExtensionInstalled),await c()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,s,P,e.browserExtensionInstalled,c]),W=(0,J.useCallback)(async()=>{if(!h){g(`open`),y(null);try{await u()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,u]),ne=(0,J.useCallback)(async()=>{if(!(!F||h)){g(`path`),y(null),x(null);try{await v(F)?x(e.browserExtensionPathCopied):x(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,F,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),G=(0,J.useCallback)(async()=>{if(!(!F||h)){g(`folder`),y(null),x(null);try{await d(),x(e.browserExtensionFolderOpened)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,F,e.browserExtensionFolderOpened,d]),K=(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:h!==null,onClick:()=>void U(),children:[h===`install`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(l,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),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:h!==null,onClick:()=>void V(),children:[h===`stop`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(k,{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:h!==null,onClick:()=>void B(),children:[h===`start`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(z,{className:`size-3.5`}),h===`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:h!==null,onClick:()=>void ee(),children:[h===`disconnect`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(te,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,X.jsx)(Be,{icon:N,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:m,primaryAction:K,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:p.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:p.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:p.connectionTimeoutMs==null?``:Math.round(p.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 ${L.color}`,children:[(0,X.jsx)(R,{className:`size-3.5`}),(0,X.jsx)(`span`,{children:L.label})]})]}),(0,X.jsx)($e,{m:e,installed:P,extensionDir:F,connected:E,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void W(),onCopyPath:()=>void ne(),onRevealFolder:()=>void G()}),I?(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,A?(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,_?(0,X.jsx)(He,{kind:`error`,message:_}):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)(B,{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 x(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 x(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(C(`/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(C(`/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(C(`/api/browser/cloakbrowser/status`)),[]),f=(0,J.useCallback)(async()=>$(C(`/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:g,extensionPort:_}=e,v=(0,J.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});g&&e.set(`host`,g),_!==void 0&&e.set(`port`,String(_)),n({type:`extension-start-probe`});try{let t=await x(C(`/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)}})}},[g,_]),y=(0,J.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await at(C(`/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}},[]),b=(0,J.useCallback)(async e=>{let t=(await $(C(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await v(),t},[v]),S=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,J.useCallback)(async()=>{await $(C(`/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;v(),y();let e=setInterval(()=>void v(),5e3);return()=>clearInterval(e)},[p,v,y]);let E=(0,J.useCallback)(async e=>{await $(C(`/api/browser/extension/start`),{host:e?.host??g,port:e?.port??_}),await v()},[g,_,v]),D=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/stop`),{}),await v()},[v]),O=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/disconnect`),{}),await v()},[v]),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=`${g}:${_??19820}`;k.current!==t&&(k.current=t,E({host:g,port:_}).catch(()=>{k.current=null}))},[p,a,g,_,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:u,fetchCloakRuntimeStatus:d,launchCloak:f,refetchExtension:v,refetchExtensionArtifacts:y,installExtensionArtifacts:b,openExtensionChrome:S,revealExtensionFolder:w,pingCdp:(0,J.useCallback)(async e=>$(C(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,J.useCallback)(async(e,t)=>$(C(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,J.useCallback)(async e=>$(C(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,J.useCallback)(async e=>{await $(C(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,J.useCallback)(async()=>(await at(C(`/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 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-DrILF6mR.js";import{a as r,r as i}from"./locale-store-C5wr3_pc.js";var a={list:()=>r(i(`/api/browser/workflows`)),setEnabled:(e,t)=>r(i(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({enabled:t})}),remove:e=>r(i(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/workflows/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/workflow-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/workflow-runs?workflowId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/workflow-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function o(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function s(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var c=e(),l=t();function u(e){let t=(0,c.c)(54),{name:r,input:i,value:a,yes:o,no:s,onChange:u}=e,f;t[0]!==i.description||t[1]!==r?(f=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=f):f=t[2];let p=f;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(d),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,l.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=c);let f;t[10]===u?f=t[11]:(f=e=>u(JSON.parse(e)),t[10]=u,t[11]=f);let m;t[12]!==p||t[13]!==r||t[14]!==c||t[15]!==f?(m=(0,l.jsx)(n,{value:c,options:r,placeholder:p,onChange:f}),t[12]=p,t[13]=r,t[14]=c,t[15]=f,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,l.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,l.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let c=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===u?h=t[31]:(h=e=>u(e===`true`),t[30]=u,t[31]=h);let g;t[32]!==p||t[33]!==c||t[34]!==m||t[35]!==h?(g=(0,l.jsx)(n,{value:c,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=c,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,l.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`||i.type===`integer`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,l.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=i.type===`integer`?1:void 0,y=a===void 0?``:String(a),b;t[43]!==m||t[44]!==u?(b=e=>u(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=u,t[45]=b):b=t[45];let x;t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b?(x=(0,l.jsx)(`input`,{type:_,step:v,value:y,onChange:b,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x):x=t[50];let S;return t[51]!==g||t[52]!==x?(S=(0,l.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,x]}),t[51]=g,t[52]=x,t[53]=S):S=t[53],S}function d(e){return{value:JSON.stringify(e),label:String(e)}}function f(e){let t=(0,c.c)(7),{workflow:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,l.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,l.jsx)(u,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{a as i,s as n,o as r,f as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-DrILF6mR.js";import{a as r,r as i}from"./locale-store-DVzTJSj2.js";var a={list:()=>r(i(`/api/browser/workflows`)),setEnabled:(e,t)=>r(i(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({enabled:t})}),remove:e=>r(i(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/workflows/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/workflow-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/workflow-runs?workflowId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/workflow-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function o(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function s(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var c=e(),l=t();function u(e){let t=(0,c.c)(54),{name:r,input:i,value:a,yes:o,no:s,onChange:u}=e,f;t[0]!==i.description||t[1]!==r?(f=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=f):f=t[2];let p=f;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(d),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,l.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=c);let f;t[10]===u?f=t[11]:(f=e=>u(JSON.parse(e)),t[10]=u,t[11]=f);let m;t[12]!==p||t[13]!==r||t[14]!==c||t[15]!==f?(m=(0,l.jsx)(n,{value:c,options:r,placeholder:p,onChange:f}),t[12]=p,t[13]=r,t[14]=c,t[15]=f,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,l.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,l.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let c=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===u?h=t[31]:(h=e=>u(e===`true`),t[30]=u,t[31]=h);let g;t[32]!==p||t[33]!==c||t[34]!==m||t[35]!==h?(g=(0,l.jsx)(n,{value:c,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=c,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,l.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`||i.type===`integer`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,l.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=i.type===`integer`?1:void 0,y=a===void 0?``:String(a),b;t[43]!==m||t[44]!==u?(b=e=>u(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=u,t[45]=b):b=t[45];let x;t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b?(x=(0,l.jsx)(`input`,{type:_,step:v,value:y,onChange:b,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x):x=t[50];let S;return t[51]!==g||t[52]!==x?(S=(0,l.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,x]}),t[51]=g,t[52]=x,t[53]=S):S=t[53],S}function d(e){return{value:JSON.stringify(e),label:String(e)}}function f(e){let t=(0,c.c)(7),{workflow:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,l.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,l.jsx)(u,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{a as i,s as n,o as r,f as t};
@@ -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{t as a}from"./button-CSEbl4zT.js";import{n as o}from"./locale-store-C5wr3_pc.js";import{t as s}from"./skeleton-BwbyijEw.js";import{Es as c,Il as l,Qs as u,bl as d,fl as f,gs as p,il as m,oo as h,xl as g}from"./index-7i2P3312.js";import{i as _,n as v,r as y,t as b}from"./browser-workflow-inputs-jvfcgFG-.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{t as a}from"./button-CSEbl4zT.js";import{n as o}from"./locale-store-DVzTJSj2.js";import{t as s}from"./skeleton-BwbyijEw.js";import{Es as c,Il as l,Qs as u,bl as d,fl as f,gs as p,il as m,oo as h,xl as g}from"./index-J3FsIvTs.js";import{i as _,n as v,r as y,t as b}from"./browser-workflow-inputs-DGQxD0vD.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=o(e=>e.language),t=C[e],n=r(),E=h(e=>e.setPageHeader),D=h(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)(a,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(l,{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)(l,{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)(a,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(l,{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)(d,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(g,{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)(m,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(a,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(g,{className:`size-4`}):(0,S.jsx)(d,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(a,{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)(a,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(u,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(a,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(c,{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)(f,{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)(a,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(p,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserWorkflowsPage};