@decocms/mesh 2.57.0 → 2.58.0

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 (138) hide show
  1. package/dist/client/assets/{AlertCircle-C8rO0b-G.js → AlertCircle-Yil9qnEH.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-vpWbkp4-.js → ArrowLeft-OdEDEe_C.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-agI-7Ntt.js → ArrowUp-Dal03NKa.js} +1 -1
  4. package/dist/client/assets/{Check-bsESkKfK.js → Check-oakDJ2AF.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-BrpZ0bUP.js → ChevronDown-Bap_L0Uk.js} +1 -1
  6. package/dist/client/assets/{Code01-oTyk1HsI.js → Code01-BG3tlXRj.js} +1 -1
  7. package/dist/client/assets/{Copy01-BUXP8R1a.js → Copy01-Bu63nBOw.js} +1 -1
  8. package/dist/client/assets/{DotsHorizontal-B4Dbs24g.js → DotsHorizontal-B811S-jI.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-0N_Gcgn2.js → DotsVertical-fX_KnNQj.js} +1 -1
  10. package/dist/client/assets/{Download01-C42qXmzc.js → Download01-DJ7F6m36.js} +1 -1
  11. package/dist/client/assets/{Edit01-CK-Jy3GQ.js → Edit01-CSIvGo0w.js} +1 -1
  12. package/dist/client/assets/{File06-DGGRuK65.js → File06-ElvtcbN_.js} +1 -1
  13. package/dist/client/assets/{FilterLines-BjbUYSYQ.js → FilterLines-CJ4ielUL.js} +1 -1
  14. package/dist/client/assets/{FlipBackward-Dor7d84a.js → FlipBackward-fTp7bHML.js} +1 -1
  15. package/dist/client/assets/{Grid01-0lEGvhxe.js → Grid01-Dr_KfxW1.js} +1 -1
  16. package/dist/client/assets/{Home02-uaWRHUbo.js → Home02-BzOZNY7Z.js} +1 -1
  17. package/dist/client/assets/{Image01-Da7t4wio.js → Image01-5eXX0GAe.js} +1 -1
  18. package/dist/client/assets/{Inbox01-CYTXANsF.js → Inbox01-BQOiy5jS.js} +1 -1
  19. package/dist/client/assets/{InfoCircle-C6HReCuL.js → InfoCircle-DgTzF72q.js} +1 -1
  20. package/dist/client/assets/{Key01-ChugVlXz.js → Key01-BOAbiw2j.js} +1 -1
  21. package/dist/client/assets/{LinkExternal01-C0CJeznV.js → LinkExternal01-CbRS6SXy.js} +1 -1
  22. package/dist/client/assets/{List-1gtHxod5.js → List-BaJmRjKO.js} +1 -1
  23. package/dist/client/assets/{Loading01-CH0UJYYG.js → Loading01-BbK7X7pB.js} +1 -1
  24. package/dist/client/assets/{Lock01-CG48-_ZX.js → Lock01-BCLUX2Yw.js} +1 -1
  25. package/dist/client/assets/{Pin01-GLAYpRsP.js → Pin01-Cmat2KYq.js} +1 -1
  26. package/dist/client/assets/{Play-EKJU7zcf.js → Play-DSNBv8J3.js} +1 -1
  27. package/dist/client/assets/{Plus-DJQVkgt_.js → Plus-DUZn7G9j.js} +1 -1
  28. package/dist/client/assets/{SearchMd-Cz_YV08V.js → SearchMd-Dqpb7vw_.js} +1 -1
  29. package/dist/client/assets/{Share07-pR36fyiF.js → Share07-0pxdeJ9F.js} +1 -1
  30. package/dist/client/assets/{Terminal-CVwldn8M.js → Terminal-DGX7jD8k.js} +1 -1
  31. package/dist/client/assets/{Trash01-CmkjDFiw.js → Trash01-FyRIWKSN.js} +1 -1
  32. package/dist/client/assets/{Upload01-ZVXhuS8k.js → Upload01-DlAhpCPh.js} +1 -1
  33. package/dist/client/assets/{Users03-DU4-bWO4.js → Users03-CPhtgAec.js} +1 -1
  34. package/dist/client/assets/{X-DTfiDKsP.js → X-DUs80l2J.js} +1 -1
  35. package/dist/client/assets/{XClose-DXOCJ4jd.js → XClose-r2Q3_LuT.js} +1 -1
  36. package/dist/client/assets/{agent-detail-5YwCG3Vp.js → agent-detail-DX2lnojP.js} +1 -1
  37. package/dist/client/assets/{agents-B65hVwk1.js → agents-Dpwv3Az5.js} +1 -1
  38. package/dist/client/assets/{alert-dialog-DSN82CoS.js → alert-dialog-JqkmaZeq.js} +1 -1
  39. package/dist/client/assets/{auth-catchall-D3VD9fSQ.js → auth-catchall-DK5cw059.js} +1 -1
  40. package/dist/client/assets/{avatar-hGKwXmmo.js → avatar-DbbO_Vrc.js} +1 -1
  41. package/dist/client/assets/{badge-COYJ-Pmf.js → badge-Ai9GD5PG.js} +1 -1
  42. package/dist/client/assets/{binder-Qfx9JiTV.js → binder-BrVJi0Ik.js} +1 -1
  43. package/dist/client/assets/{button-C27O1Tep.js → button-B-LIjJ0d.js} +1 -1
  44. package/dist/client/assets/{card-Bh-0IVmq.js → card-XaHspUBI.js} +1 -1
  45. package/dist/client/assets/{checkbox-ByIz1hp1.js → checkbox-D75pxaXU.js} +1 -1
  46. package/dist/client/assets/{circle-alert-Bcrtrele.js → circle-alert-CgaIPI4d.js} +1 -1
  47. package/dist/client/assets/collection-detail-deMJDjhU.js +26 -0
  48. package/dist/client/assets/{collection-display-button-C5guuNpQ.js → collection-display-button-DdFsgETm.js} +1 -1
  49. package/dist/client/assets/{collection-header-DuFFC04Y.js → collection-header-DyDhieJC.js} +1 -1
  50. package/dist/client/assets/{collection-page-CvjkGAp9.js → collection-page-CuQgqDaq.js} +1 -1
  51. package/dist/client/assets/{collection-search-cE-wVILm.js → collection-search-BdprEFJN.js} +1 -1
  52. package/dist/client/assets/{collection-tab-DtYAS3be.js → collection-tab-BiI-iMq7.js} +1 -1
  53. package/dist/client/assets/{collection-table-wrapper-0Bo8TIAS.js → collection-table-wrapper-CaRdow_V.js} +1 -1
  54. package/dist/client/assets/{connect-DsZ06Bb_.js → connect-Dz8kXZ1B.js} +1 -1
  55. package/dist/client/assets/{connection-card-BliQqhzM.js → connection-card-Bzv2t0pV.js} +1 -1
  56. package/dist/client/assets/{connection-detail-BgFKGBjf.js → connection-detail-Dt0WxfOL.js} +1 -1
  57. package/dist/client/assets/{connections-DN_d5sPG.js → connections-5IaK481x.js} +1 -1
  58. package/dist/client/assets/{constants-BhXVXoda.js → constants-C7esE5S6.js} +1 -1
  59. package/dist/client/assets/constants-DqcZdoXa.js +1 -0
  60. package/dist/client/assets/{create-organization-dialog-DyGXl4j0.js → create-organization-dialog-KKPKWuSg.js} +1 -1
  61. package/dist/client/assets/{dialog-2RChHFVc.js → dialog-UCxLeO_h.js} +1 -1
  62. package/dist/client/assets/{dropdown-menu-CvjQt0JX.js → dropdown-menu-kuIIANP5.js} +1 -1
  63. package/dist/client/assets/{dynamic-plugin-layout-D3laiYgI.js → dynamic-plugin-layout-DtVaKRRj.js} +1 -1
  64. package/dist/client/assets/{empty-state-BDPhhANS.js → empty-state-Ba47ZVsf.js} +1 -1
  65. package/dist/client/assets/{empty-state-Cu78wcTh.js → empty-state-DA7yVTaN.js} +1 -1
  66. package/dist/client/assets/{env-vars-editor-X_CtF2mI.js → env-vars-editor-BZSzAH_1.js} +1 -1
  67. package/dist/client/assets/{error-boundary-CGthXXIx.js → error-boundary-BkEvrItd.js} +1 -1
  68. package/dist/client/assets/{estree-BOE5AzoZ.js → estree-CwOGYdhi.js} +2 -2
  69. package/dist/client/assets/{extract-connection-data-pGIt-HCV.js → extract-connection-data-D2dnQRcn.js} +1 -1
  70. package/dist/client/assets/{file-browser-BEObwBCu.js → file-browser-B5MIQRKs.js} +2 -2
  71. package/dist/client/assets/{form-A9uXvCEC.js → form-BHWppF5B.js} +1 -1
  72. package/dist/client/assets/{grid-view-BxgPINem.js → grid-view-Dg5b3VA4.js} +1 -1
  73. package/dist/client/assets/{home-B0HLf5WC.js → home-yc1dQ9Lq.js} +1 -1
  74. package/dist/client/assets/index-B05deeSQ.js +25 -0
  75. package/dist/client/assets/{index-7s6a8H7V.js → index-BDV46Exd.js} +1 -1
  76. package/dist/client/assets/{index-DHeWc5sz.js → index-BKkW7Unn.js} +1 -1
  77. package/dist/client/assets/{index-VpvRFsKi.js → index-BcoUfGs8.js} +1 -1
  78. package/dist/client/assets/{index-BFTvKmE8.js → index-Ci9wq6UB.js} +3 -3
  79. package/dist/client/assets/{index-BdwaCz7c.js → index-DCr6r7Yw.js} +28 -28
  80. package/dist/client/assets/{infiniteQueryObserver-BpMFJQC9.js → infiniteQueryObserver-CcbuhEfP.js} +1 -1
  81. package/dist/client/assets/{input-B2fcjFgH.js → input-BdbOsF-m.js} +1 -1
  82. package/dist/client/assets/{layout-V0w1joLG.js → layout-SO6IbyRc.js} +1 -1
  83. package/dist/client/assets/{localstorage-keys-BoCVyY3G.js → localstorage-keys-DOkcu8sQ.js} +1 -1
  84. package/dist/client/assets/{login-CEUn-CbC.js → login-BUUR0ZN-.js} +1 -1
  85. package/dist/client/assets/mcp-oauth-B8scVlEC.js +1 -0
  86. package/dist/client/assets/{mcp-server-card-CDNnOm93.js → mcp-server-card-DxAeYt3X.js} +1 -1
  87. package/dist/client/assets/{mcp-server-detail-DqETrep8.js → mcp-server-detail-ByStzsBB.js} +2 -2
  88. package/dist/client/assets/{members--3-zQV-m.js → members-DvIXCABj.js} +1 -1
  89. package/dist/client/assets/{monaco-editor-bUy3gNfD.js → monaco-editor-B5Aw8k_-.js} +2 -2
  90. package/dist/client/assets/{monitoring--Lt0OEis.js → monitoring-Bqe3CbDW.js} +3 -3
  91. package/dist/client/assets/{oauth-callback-CWMI_jqz.js → oauth-callback-CNu9C9Oo.js} +1 -1
  92. package/dist/client/assets/{page-DmJBsO35.js → page-BUqDaU45.js} +1 -1
  93. package/dist/client/assets/{page-BMc7AjMv.js → page-CsSxMAlL.js} +1 -1
  94. package/dist/client/assets/{pin-to-sidebar-button-C_ntSSpu.js → pin-to-sidebar-button-BZ72nAEL.js} +1 -1
  95. package/dist/client/assets/{plugin-empty-state-zpVHwWxb.js → plugin-empty-state-DLdyL-mH.js} +1 -1
  96. package/dist/client/assets/{plugin-header-CiGDp9KW.js → plugin-header-CTUed0gr.js} +1 -1
  97. package/dist/client/assets/{plugins-Z7IP48vQ.js → plugins-Db0sY8EK.js} +1 -1
  98. package/dist/client/assets/{popover-C8uYVooB.js → popover-DisoFbn-.js} +1 -1
  99. package/dist/client/assets/{registry-utils-CB5x8oYd.js → registry-utils-Xp067sQn.js} +1 -1
  100. package/dist/client/assets/{resizable-DQZOCv1H.js → resizable-C2Utw1an.js} +1 -1
  101. package/dist/client/assets/{resource-tabs-CP0lLGDW.js → resource-tabs-BgCbfh1Q.js} +1 -1
  102. package/dist/client/assets/{select-BmzAyfSh.js → select-DcK9kiBG.js} +1 -1
  103. package/dist/client/assets/{settings-JDMz0Z4O.js → settings-nHPuWPgH.js} +1 -1
  104. package/dist/client/assets/{shell-layout-Tl_6ulPY.js → shell-layout-DvYtMesy.js} +1 -1
  105. package/dist/client/assets/{spinner-DH0n918C.js → spinner-CoVqlI-k.js} +1 -1
  106. package/dist/client/assets/{store-invite-BCxxdn9a.js → store-invite-A94F9maS.js} +1 -1
  107. package/dist/client/assets/{switch-BPW4w7jh.js → switch-7a4IJCL5.js} +1 -1
  108. package/dist/client/assets/{textarea-Cs9upqtn.js → textarea-DHc00T9T.js} +1 -1
  109. package/dist/client/assets/{tool-set-selector-ZwSI3WCu.js → tool-set-selector-CzVhPzY2.js} +1 -1
  110. package/dist/client/assets/{tools-list-D1w1Wvt6.js → tools-list-dmNFSBw9.js} +1 -1
  111. package/dist/client/assets/{tooltip-M_zJvkrH.js → tooltip-C6LqelJl.js} +1 -1
  112. package/dist/client/assets/{typewriter-title-Cloxvukg.js → typewriter-title-DsIR7tcg.js} +1 -1
  113. package/dist/client/assets/{use-binding-DlyhBSt1.js → use-binding-fpuk0ApB.js} +1 -1
  114. package/dist/client/assets/{use-collections-D2rJigVT.js → use-collections-OpbhFLgE.js} +1 -1
  115. package/dist/client/assets/{use-connection-Cs8I3Sqh.js → use-connection-eyF66tJm.js} +1 -1
  116. package/dist/client/assets/{use-create-virtual-mcp-BYgqXltX.js → use-create-virtual-mcp-Dlso4n1S.js} +1 -1
  117. package/dist/client/assets/{use-list-state-Cuf87gC8.js → use-list-state-DkhtaHnD.js} +1 -1
  118. package/dist/client/assets/{use-mcp-prompts-BFYoJVx6.js → use-mcp-prompts-Cw_2aGFv.js} +1 -1
  119. package/dist/client/assets/{use-members-C6mz3rh9.js → use-members-Ckcz_xnb.js} +1 -1
  120. package/dist/client/assets/{use-mobile-B6xU0L_K.js → use-mobile-DhlorgRC.js} +1 -1
  121. package/dist/client/assets/{use-organization-settings-B5ysVx5V.js → use-organization-settings-QaQjoeNw.js} +1 -1
  122. package/dist/client/assets/{use-virtual-mcp-D3TmehE_.js → use-virtual-mcp-DtuFFUUi.js} +1 -1
  123. package/dist/client/assets/useInfiniteQuery-DFmo1FzW.js +1 -0
  124. package/dist/client/assets/{useMutation-DwH4Ggns.js → useMutation-DjlaCojA.js} +1 -1
  125. package/dist/client/assets/useQuery-Bs28vQtV.js +1 -0
  126. package/dist/client/assets/{view-mode-toggle-CI36GSoa.js → view-mode-toggle-4IXqr_wc.js} +1 -1
  127. package/dist/client/assets/{workflow-BR3adw-D.js → workflow-BEYp-bPo.js} +1 -1
  128. package/dist/client/index.html +1 -1
  129. package/dist/server/cli.js +188 -188
  130. package/dist/server/migrate.js +156 -156
  131. package/dist/server/server.js +173 -173
  132. package/package.json +2 -2
  133. package/dist/client/assets/collection-detail-Bw_JnEEW.js +0 -26
  134. package/dist/client/assets/constants-DK8mJXHI.js +0 -1
  135. package/dist/client/assets/index-DdXwvhtT.js +0 -25
  136. package/dist/client/assets/mcp-oauth-ZRHNetS-.js +0 -1
  137. package/dist/client/assets/useInfiniteQuery-C8FPbzAp.js +0 -1
  138. package/dist/client/assets/useQuery-DttwUpIb.js +0 -1
@@ -1,10 +1,10 @@
1
- import{r as P,c as ne,j as S,bW as zO,bX as jO,E as qO,ag as jt,s as te,bY as ro,bZ as o_,bq as GO,br as VO,bo as WO,ad as Ot,ae as La,n as ts,o as Ie,bp as de,af as Zn,b_ as YO,b$ as Be,_ as KO,bz as ul,u as wn,a as l_,K as ns,Y as Gg,ab as ln,g as u_,h as XO,k as ZO,Z as c_,c0 as d_,bT as QO,bE as Lt,c1 as JO,c2 as e2,a_ as p_,c3 as t2,c4 as vn,c5 as Xl,c6 as n2,c7 as Zl,c8 as r2,c9 as i2,ca as a2,cb as s2,q as o2,cc as l2,cd as u2,ce as c2,cf as d2,l as f_,bS as io,al as Vg,am as p2,ao as f2,ah as h2,aj as m2,ak as g2,be as b2,at as E2}from"./index-BdwaCz7c.js";import{c as me,B as gt}from"./button-C27O1Tep.js";import{i as y2}from"./X-DTfiDKsP.js";import{u as Qr,a as Wg,b as T2,e as S2}from"./constants-BhXVXoda.js";import{b as h_}from"./use-virtual-mcp-D3TmehE_.js";import{b as m_}from"./use-collections-D2rJigVT.js";import{b as g_,a as A2}from"./use-connection-Cs8I3Sqh.js";import{a as k2}from"./use-binding-DlyhBSt1.js";import{u as x2,M as b_,s as $E}from"./monaco-editor-bUy3gNfD.js";import{u as ao,L as Yg}from"./localstorage-keys-BoCVyY3G.js";import{I as Kg}from"./input-B2fcjFgH.js";import{P as rs,a as is,b as as}from"./popover-C8uYVooB.js";import{S as v2,a as _2,b as C2,c as N2,d as I2}from"./select-BmzAyfSh.js";import{t as so}from"./ChevronDown-BrpZ0bUP.js";import{i as w2}from"./File06-DGGRuK65.js";import{c as R2,i as E_}from"./Grid01-0lEGvhxe.js";import{a as O2}from"./Image01-Da7t4wio.js";import{i as cl}from"./SearchMd-Cz_YV08V.js";import{S as dl}from"./spinner-DH0n918C.js";import{c as Jr,T as ei,a as ti,b as Xg}from"./tooltip-M_zJvkrH.js";import{u as L2,g as y_,l as zE,a as jE,r as D2}from"./use-mcp-prompts-BFYoJVx6.js";import{E as M2,i as P2}from"./error-boundary-CGthXXIx.js";import{c as F2,b as B2,e as U2,a as H2,D as $2}from"./dialog-2RChHFVc.js";import{a as z2,F as j2,b as q2,c as G2,d as V2,f as W2}from"./form-A9uXvCEC.js";import{I as Zg,E as Y2}from"./empty-state-BDPhhANS.js";import{i as T_}from"./AlertCircle-C8rO0b-G.js";import{i as K2}from"./ArrowUp-agI-7Ntt.js";import{i as X2}from"./Edit01-CK-Jy3GQ.js";import{t as Qg}from"./Users03-DU4-bWO4.js";import{i as pl}from"./Check-bsESkKfK.js";import{a as Jg}from"./Copy01-BUXP8R1a.js";import{i as Z2}from"./Terminal-CVwldn8M.js";import{g as Q2}from"./generate-id-Dyweu44Y.js";import{s as J2}from"./Trash01-CmkjDFiw.js";import{u as eL}from"./use-create-virtual-mcp-BYgqXltX.js";import{s as tL}from"./Plus-DJQVkgt_.js";var Da;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Da||(Da={}));var qE;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(qE||(qE={}));Da.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Da.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class oo extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},r={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let o=r,l=0;for(;l<s.path.length;){const u=s.path[l];l===s.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(s))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return i(this),r}static assert(e){if(!(e instanceof oo))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Da.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const a=i.path[0];n[a]=n[a]||[],n[a].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}oo.create=t=>new oo(t);var GE;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(GE||(GE={}));var ge;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ge||(ge={}));const S_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));S_.displayName="Atom02";const A_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"}));A_.displayName="ChevronSelectorVertical";const k_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));k_.displayName="Coins01";const x_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M6 16a4 4 0 0 0 4 4h4a4 4 0 0 0 0-8h-4a4 4 0 0 1 0-8h4a4 4 0 0 1 4 4m-6-6v20"}));x_.displayName="CurrencyDollar";const v_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));v_.displayName="Lightbulb01";const __=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m18 8 4 4m0 0-4 4m4-4H9m6-7.796A8.383 8.383 0 0 0 10.667 3C5.88 3 2 7.03 2 12s3.88 9 8.667 9A8.384 8.384 0 0 0 15 19.796"}));__.displayName="LogOut04";const fl=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m6.5 13 .784 1.569c.266.53.399.796.576 1.026a3 3 0 0 0 .545.545c.23.177.495.31 1.026.575L11 17.5l-1.569.785c-.53.265-.796.398-1.026.575a3 3 0 0 0-.545.545c-.177.23-.31.495-.576 1.026L6.5 22l-.784-1.569c-.266-.53-.399-.796-.576-1.026a3 3 0 0 0-.545-.545c-.23-.177-.495-.31-1.026-.575L2 17.5l1.569-.785c.53-.265.796-.398 1.026-.575a3 3 0 0 0 .545-.545c.177-.23.31-.495.576-1.026L6.5 13ZM15 2l1.179 3.064c.282.734.423 1.1.642 1.409a3 3 0 0 0 .706.706c.309.22.675.36 1.409.642L22 9l-3.064 1.179c-.734.282-1.1.423-1.409.642a3 3 0 0 0-.706.706c-.22.309-.36.675-.642 1.409L15 16l-1.179-3.064c-.282-.734-.423-1.1-.642-1.409a3 3 0 0 0-.706-.706c-.309-.22-.675-.36-1.409-.642L8 9l3.064-1.179c.734-.282 1.1-.423 1.409-.642a3 3 0 0 0 .706-.706c.22-.309.36-.675.642-1.409L15 2Z"}));fl.displayName="Stars01";const C_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));C_.displayName="Stop";const N_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));N_.displayName="Target04";const I_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));I_.displayName="XCircle";function yt(t){const e=ne.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=me("bg-accent animate-pulse rounded-md",n),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==i?(a=S.jsx("div",{"data-slot":"skeleton",className:i,...r}),e[5]=r,e[6]=i,e[7]=a):a=e[7],a}function nL(){const t=ne.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Yg.developerMode(),t[0]=e):e=t[0],ao(e,!1)}var w_="vercel.ai.error",rL=Symbol.for(w_),VE,WE,Cn=class R_ extends(WE=Error,VE=rL,WE){constructor({name:e,message:n,cause:r}){super(n),this[VE]=!0,this.name=e,this.cause=r}static isInstance(e){return R_.hasMarker(e,w_)}static hasMarker(e,n){const r=Symbol.for(n);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function O_(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var L_="AI_InvalidArgumentError",D_=`vercel.ai.error.${L_}`,iL=Symbol.for(D_),YE,KE,aL=class extends(KE=Cn,YE=iL,KE){constructor({message:t,cause:e,argument:n}){super({name:L_,message:t,cause:e}),this[YE]=!0,this.argument=n}static isInstance(t){return Cn.hasMarker(t,D_)}},M_="AI_JSONParseError",P_=`vercel.ai.error.${M_}`,sL=Symbol.for(P_),XE,ZE,QE=class extends(ZE=Cn,XE=sL,ZE){constructor({text:t,cause:e}){super({name:M_,message:`JSON parsing failed: Text: ${t}.
1
+ import{r as P,c as ne,j as S,bW as zO,bX as jO,E as qO,ag as jt,s as te,bY as ro,bZ as o_,bq as GO,br as VO,bo as WO,ad as Ot,ae as La,n as ts,o as Ie,bp as de,af as Zn,b_ as YO,b$ as Be,_ as KO,bz as ul,u as wn,a as l_,K as ns,Y as Gg,ab as ln,g as u_,h as XO,k as ZO,Z as c_,c0 as d_,bT as QO,bE as Lt,c1 as JO,c2 as e2,a_ as p_,c3 as t2,c4 as vn,c5 as Xl,c6 as n2,c7 as Zl,c8 as r2,c9 as i2,ca as a2,cb as s2,q as o2,cc as l2,cd as u2,ce as c2,cf as d2,l as f_,bS as io,al as Vg,am as p2,ao as f2,ah as h2,aj as m2,ak as g2,be as b2,at as E2}from"./index-DCr6r7Yw.js";import{c as me,B as gt}from"./button-B-LIjJ0d.js";import{i as y2}from"./X-DUs80l2J.js";import{u as Qr,a as Wg,b as T2,e as S2}from"./constants-C7esE5S6.js";import{b as h_}from"./use-virtual-mcp-DtuFFUUi.js";import{b as m_}from"./use-collections-OpbhFLgE.js";import{b as g_,a as A2}from"./use-connection-eyF66tJm.js";import{a as k2}from"./use-binding-fpuk0ApB.js";import{u as x2,M as b_,s as $E}from"./monaco-editor-B5Aw8k_-.js";import{u as ao,L as Yg}from"./localstorage-keys-DOkcu8sQ.js";import{I as Kg}from"./input-BdbOsF-m.js";import{P as rs,a as is,b as as}from"./popover-DisoFbn-.js";import{S as v2,a as _2,b as C2,c as N2,d as I2}from"./select-DcK9kiBG.js";import{t as so}from"./ChevronDown-Bap_L0Uk.js";import{i as w2}from"./File06-ElvtcbN_.js";import{c as R2,i as E_}from"./Grid01-Dr_KfxW1.js";import{a as O2}from"./Image01-5eXX0GAe.js";import{i as cl}from"./SearchMd-Dqpb7vw_.js";import{S as dl}from"./spinner-CoVqlI-k.js";import{c as Jr,T as ei,a as ti,b as Xg}from"./tooltip-C6LqelJl.js";import{u as L2,g as y_,l as zE,a as jE,r as D2}from"./use-mcp-prompts-Cw_2aGFv.js";import{E as M2,i as P2}from"./error-boundary-BkEvrItd.js";import{c as F2,b as B2,e as U2,a as H2,D as $2}from"./dialog-UCxLeO_h.js";import{a as z2,F as j2,b as q2,c as G2,d as V2,f as W2}from"./form-BHWppF5B.js";import{I as Zg,E as Y2}from"./empty-state-Ba47ZVsf.js";import{i as T_}from"./AlertCircle-Yil9qnEH.js";import{i as K2}from"./ArrowUp-Dal03NKa.js";import{i as X2}from"./Edit01-CSIvGo0w.js";import{t as Qg}from"./Users03-CPhtgAec.js";import{i as pl}from"./Check-oakDJ2AF.js";import{a as Jg}from"./Copy01-Bu63nBOw.js";import{i as Z2}from"./Terminal-DGX7jD8k.js";import{g as Q2}from"./generate-id-Dyweu44Y.js";import{s as J2}from"./Trash01-FyRIWKSN.js";import{u as eL}from"./use-create-virtual-mcp-Dlso4n1S.js";import{s as tL}from"./Plus-DUZn7G9j.js";var Da;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Da||(Da={}));var qE;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(qE||(qE={}));Da.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Da.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class oo extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},r={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let o=r,l=0;for(;l<s.path.length;){const u=s.path[l];l===s.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(s))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return i(this),r}static assert(e){if(!(e instanceof oo))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Da.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const a=i.path[0];n[a]=n[a]||[],n[a].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}oo.create=t=>new oo(t);var GE;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(GE||(GE={}));var ge;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ge||(ge={}));const S_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));S_.displayName="Atom02";const A_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"}));A_.displayName="ChevronSelectorVertical";const k_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));k_.displayName="Coins01";const x_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M6 16a4 4 0 0 0 4 4h4a4 4 0 0 0 0-8h-4a4 4 0 0 1 0-8h4a4 4 0 0 1 4 4m-6-6v20"}));x_.displayName="CurrencyDollar";const v_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));v_.displayName="Lightbulb01";const __=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m18 8 4 4m0 0-4 4m4-4H9m6-7.796A8.383 8.383 0 0 0 10.667 3C5.88 3 2 7.03 2 12s3.88 9 8.667 9A8.384 8.384 0 0 0 15 19.796"}));__.displayName="LogOut04";const fl=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m6.5 13 .784 1.569c.266.53.399.796.576 1.026a3 3 0 0 0 .545.545c.23.177.495.31 1.026.575L11 17.5l-1.569.785c-.53.265-.796.398-1.026.575a3 3 0 0 0-.545.545c-.177.23-.31.495-.576 1.026L6.5 22l-.784-1.569c-.266-.53-.399-.796-.576-1.026a3 3 0 0 0-.545-.545c-.23-.177-.495-.31-1.026-.575L2 17.5l1.569-.785c.53-.265.796-.398 1.026-.575a3 3 0 0 0 .545-.545c.177-.23.31-.495.576-1.026L6.5 13ZM15 2l1.179 3.064c.282.734.423 1.1.642 1.409a3 3 0 0 0 .706.706c.309.22.675.36 1.409.642L22 9l-3.064 1.179c-.734.282-1.1.423-1.409.642a3 3 0 0 0-.706.706c-.22.309-.36.675-.642 1.409L15 16l-1.179-3.064c-.282-.734-.423-1.1-.642-1.409a3 3 0 0 0-.706-.706c-.309-.22-.675-.36-1.409-.642L8 9l3.064-1.179c.734-.282 1.1-.423 1.409-.642a3 3 0 0 0 .706-.706c.22-.309.36-.675.642-1.409L15 2Z"}));fl.displayName="Stars01";const C_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));C_.displayName="Stop";const N_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));N_.displayName="Target04";const I_=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));I_.displayName="XCircle";function yt(t){const e=ne.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=me("bg-accent animate-pulse rounded-md",n),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==i?(a=S.jsx("div",{"data-slot":"skeleton",className:i,...r}),e[5]=r,e[6]=i,e[7]=a):a=e[7],a}function nL(){const t=ne.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Yg.developerMode(),t[0]=e):e=t[0],ao(e,!1)}var w_="vercel.ai.error",rL=Symbol.for(w_),VE,WE,Cn=class R_ extends(WE=Error,VE=rL,WE){constructor({name:e,message:n,cause:r}){super(n),this[VE]=!0,this.name=e,this.cause=r}static isInstance(e){return R_.hasMarker(e,w_)}static hasMarker(e,n){const r=Symbol.for(n);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function O_(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var L_="AI_InvalidArgumentError",D_=`vercel.ai.error.${L_}`,iL=Symbol.for(D_),YE,KE,aL=class extends(KE=Cn,YE=iL,KE){constructor({message:t,cause:e,argument:n}){super({name:L_,message:t,cause:e}),this[YE]=!0,this.argument=n}static isInstance(t){return Cn.hasMarker(t,D_)}},M_="AI_JSONParseError",P_=`vercel.ai.error.${M_}`,sL=Symbol.for(P_),XE,ZE,QE=class extends(ZE=Cn,XE=sL,ZE){constructor({text:t,cause:e}){super({name:M_,message:`JSON parsing failed: Text: ${t}.
2
2
  Error message: ${O_(e)}`,cause:e}),this[XE]=!0,this.text=t}static isInstance(t){return Cn.hasMarker(t,P_)}},F_="AI_TypeValidationError",B_=`vercel.ai.error.${F_}`,oL=Symbol.for(B_),JE,e0,Ci=class Mm extends(e0=Cn,JE=oL,e0){constructor({value:e,cause:n}){super({name:F_,message:`Type validation failed: Value: ${JSON.stringify(e)}.
3
3
  Error message: ${O_(n)}`,cause:n}),this[JE]=!0,this.value=e}static isInstance(e){return Cn.hasMarker(e,B_)}static wrap({value:e,cause:n}){return Mm.isInstance(n)&&n.value===e?n:new Mm({value:e,cause:n})}},ss=({prefix:t,size:e=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const a=n.length,s=new Array(e);for(let o=0;o<e;o++)s[o]=n[Math.random()*a|0];return s.join("")};if(t==null)return i;if(n.includes(r))throw new aL({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${t}${r}${i()}`},lL=ss();function t0(t=globalThis){var e,n,r;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(r=(n=t.process)==null?void 0:n.versions)!=null&&r.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function wr(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((n,r)=>{e[r.toLowerCase()]=n});else{Array.isArray(t)||(t=Object.entries(t));for(const[n,r]of t)r!=null&&(e[n.toLowerCase()]=r)}return e}function n0(t,...e){const n=new Headers(wr(t)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...e].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var uL=/"__proto__"\s*:/,cL=/"constructor"\s*:/;function r0(t){const e=JSON.parse(t);return e===null||typeof e!="object"||uL.test(t)===!1&&cL.test(t)===!1?e:dL(e)}function dL(t){let e=[t];for(;e.length;){const n=e;e=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in r){const a=r[i];a&&typeof a=="object"&&e.push(a)}}}return t}function pL(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return r0(t)}try{return r0(t)}finally{Error.stackTraceLimit=e}}function eb(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:n}=t;if(n!=null)for(const r of Object.keys(n))n[r]=Cr(n[r])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(Cr):Cr(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(Cr)),t.allOf!=null&&(t.allOf=t.allOf.map(Cr)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(Cr));const{definitions:e}=t;if(e!=null)for(const n of Object.keys(e))e[n]=Cr(e[n]);return t}function Cr(t){return typeof t=="boolean"?t:eb(t)}var fL=Symbol("Let zodToJsonSchema decide on which parser to use"),i0={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},hL=t=>typeof t=="string"?{...i0,name:t}:{...i0,...t};function Qt(){return{}}function mL(t,e){var n,r,i;const a={type:"array"};return(n=t.type)!=null&&n._def&&((i=(r=t.type)==null?void 0:r._def)==null?void 0:i.typeName)!==ge.ZodAny&&(a.items=Re(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(a.minItems=t.minLength.value),t.maxLength&&(a.maxItems=t.maxLength.value),t.exactLength&&(a.minItems=t.exactLength.value,a.maxItems=t.exactLength.value),a}function gL(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function bL(){return{type:"boolean"}}function U_(t,e){return Re(t.type._def,e)}var EL=(t,e)=>Re(t.innerType._def,e);function H_(t,e,n){const r=n??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,a)=>H_(t,e,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return yL(t)}}var yL=t=>{const e={type:"integer",format:"unix-time"};for(const n of t.checks)switch(n.kind){case"min":e.minimum=n.value;break;case"max":e.maximum=n.value;break}return e};function TL(t,e){return{...Re(t.innerType._def,e),default:t.defaultValue()}}function SL(t,e){return e.effectStrategy==="input"?Re(t.schema._def,e):Qt()}function AL(t){return{type:"string",enum:Array.from(t.values)}}var kL=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function xL(t,e){const n=[Re(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Re(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(kL(i))r.push(...i.allOf);else{let a=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:s,...o}=i;a=o}r.push(a)}}),r.length?{allOf:r}:void 0}function vL(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var Ql=void 0,dn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Ql===void 0&&(Ql=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ql),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function $_(t,e){const n={type:"string"};if(t.checks)for(const r of t.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(e.emailStrategy){case"format:email":pn(n,"email",r.message,e);break;case"format:idn-email":pn(n,"idn-email",r.message,e);break;case"pattern:zod":Rt(n,dn.email,r.message,e);break}break;case"url":pn(n,"uri",r.message,e);break;case"uuid":pn(n,"uuid",r.message,e);break;case"regex":Rt(n,r.regex,r.message,e);break;case"cuid":Rt(n,dn.cuid,r.message,e);break;case"cuid2":Rt(n,dn.cuid2,r.message,e);break;case"startsWith":Rt(n,RegExp(`^${Jl(r.value,e)}`),r.message,e);break;case"endsWith":Rt(n,RegExp(`${Jl(r.value,e)}$`),r.message,e);break;case"datetime":pn(n,"date-time",r.message,e);break;case"date":pn(n,"date",r.message,e);break;case"time":pn(n,"time",r.message,e);break;case"duration":pn(n,"duration",r.message,e);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{Rt(n,RegExp(Jl(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&&pn(n,"ipv4",r.message,e),r.version!=="v4"&&pn(n,"ipv6",r.message,e);break}case"base64url":Rt(n,dn.base64url,r.message,e);break;case"jwt":Rt(n,dn.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&Rt(n,dn.ipv4Cidr,r.message,e),r.version!=="v4"&&Rt(n,dn.ipv6Cidr,r.message,e);break}case"emoji":Rt(n,dn.emoji(),r.message,e);break;case"ulid":{Rt(n,dn.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{pn(n,"binary",r.message,e);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Rt(n,dn.base64,r.message,e);break}}break}case"nanoid":Rt(n,dn.nanoid,r.message,e)}return n}function Jl(t,e){return e.patternStrategy==="escape"?CL(t):t}var _L=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function CL(t){let e="";for(let n=0;n<t.length;n++)_L.has(t[n])||(e+="\\"),e+=t[n];return e}function pn(t,e,n,r){var i;t.format||(i=t.anyOf)!=null&&i.some(a=>a.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...n&&r.errorMessages&&{errorMessage:{format:n}}})):t.format=e}function Rt(t,e,n,r){var i;t.pattern||(i=t.allOf)!=null&&i.some(a=>a.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:a0(e,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):t.pattern=a0(e,r)}function a0(t,e){var n;if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source;let a="",s=!1,o=!1,l=!1;for(let u=0;u<i.length;u++){if(s){a+=i[u],s=!1;continue}if(r.i){if(o){if(i[u].match(/[a-z]/)){l?(a+=i[u],a+=`${i[u-2]}-${i[u]}`.toUpperCase(),l=!1):i[u+1]==="-"&&((n=i[u+2])!=null&&n.match(/[a-z]/))?(a+=i[u],l=!0):a+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){a+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(r.m){if(i[u]==="^"){a+=`(^|(?<=[\r
4
4
  ]))`;continue}else if(i[u]==="$"){a+=`($|(?=[\r
5
5
  ]))`;continue}}if(r.s&&i[u]==="."){a+=o?`${i[u]}\r
6
6
  `:`[${i[u]}\r
7
- ]`;continue}a+=i[u],i[u]==="\\"?s=!0:o&&i[u]==="]"?o=!1:!o&&i[u]==="["&&(o=!0)}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return a}function z_(t,e){var n,r,i,a,s,o;const l={type:"object",additionalProperties:(n=Re(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?n:e.allowedAdditionalProperties};if(((r=t.keyType)==null?void 0:r._def.typeName)===ge.ZodString&&((i=t.keyType._def.checks)!=null&&i.length)){const{type:u,...c}=$_(t.keyType._def,e);return{...l,propertyNames:c}}else{if(((a=t.keyType)==null?void 0:a._def.typeName)===ge.ZodEnum)return{...l,propertyNames:{enum:t.keyType._def.values}};if(((s=t.keyType)==null?void 0:s._def.typeName)===ge.ZodBranded&&t.keyType._def.type._def.typeName===ge.ZodString&&((o=t.keyType._def.type._def.checks)!=null&&o.length)){const{type:u,...c}=U_(t.keyType._def,e);return{...l,propertyNames:c}}}return l}function NL(t,e){if(e.mapStrategy==="record")return z_(t,e);const n=Re(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Qt(),r=Re(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Qt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function IL(t){const e=t.values,r=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),i=Array.from(new Set(r.map(a=>typeof a)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function wL(){return{not:Qt()}}function RL(){return{type:"null"}}var Pm={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function OL(t,e){const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Pm&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,a)=>{const s=Pm[a._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,a)=>{const s=typeof a._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(a._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((a,s,o)=>o.indexOf(a)===s);return{type:i.length>1?i:i[0],enum:n.reduce((a,s)=>a.includes(s._def.value)?a:[...a,s._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(a=>!r.includes(a))],[])};return LL(t,e)}var LL=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>Re(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function DL(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Pm[t.innerType._def.typeName],"null"]};const n=Re(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function ML(t){const e={type:"number"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"int":e.type="integer";break;case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function PL(t,e){const n={type:"object",properties:{}},r=[],i=t.shape();for(const s in i){let o=i[s];if(o===void 0||o._def===void 0)continue;const l=BL(o),u=Re(o._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});u!==void 0&&(n.properties[s]=u,l||r.push(s))}r.length&&(n.required=r);const a=FL(t,e);return a!==void 0&&(n.additionalProperties=a),n}function FL(t,e){if(t.catchall._def.typeName!=="ZodNever")return Re(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function BL(t){try{return t.isOptional()}catch{return!0}}var UL=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return Re(t.innerType._def,e);const r=Re(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Qt()},r]}:Qt()},HL=(t,e)=>{if(e.pipeStrategy==="input")return Re(t.in._def,e);if(e.pipeStrategy==="output")return Re(t.out._def,e);const n=Re(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=Re(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function $L(t,e){return Re(t.type._def,e)}function zL(t,e){const r={type:"array",uniqueItems:!0,items:Re(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(r.minItems=t.minSize.value),t.maxSize&&(r.maxItems=t.maxSize.value),r}function jL(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Re(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Re(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Re(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function qL(){return{not:Qt()}}function GL(){return Qt()}var VL=(t,e)=>Re(t.innerType._def,e),WL=(t,e,n)=>{switch(e){case ge.ZodString:return $_(t,n);case ge.ZodNumber:return ML(t);case ge.ZodObject:return PL(t,n);case ge.ZodBigInt:return gL(t);case ge.ZodBoolean:return bL();case ge.ZodDate:return H_(t,n);case ge.ZodUndefined:return qL();case ge.ZodNull:return RL();case ge.ZodArray:return mL(t,n);case ge.ZodUnion:case ge.ZodDiscriminatedUnion:return OL(t,n);case ge.ZodIntersection:return xL(t,n);case ge.ZodTuple:return jL(t,n);case ge.ZodRecord:return z_(t,n);case ge.ZodLiteral:return vL(t);case ge.ZodEnum:return AL(t);case ge.ZodNativeEnum:return IL(t);case ge.ZodNullable:return DL(t,n);case ge.ZodOptional:return UL(t,n);case ge.ZodMap:return NL(t,n);case ge.ZodSet:return zL(t,n);case ge.ZodLazy:return()=>t.getter()._def;case ge.ZodPromise:return $L(t,n);case ge.ZodNaN:case ge.ZodNever:return wL();case ge.ZodEffects:return SL(t,n);case ge.ZodAny:return Qt();case ge.ZodUnknown:return GL();case ge.ZodDefault:return TL(t,n);case ge.ZodBranded:return U_(t,n);case ge.ZodReadonly:return VL(t,n);case ge.ZodCatch:return EL(t,n);case ge.ZodPipeline:return HL(t,n);case ge.ZodFunction:case ge.ZodVoid:case ge.ZodSymbol:return;default:return(r=>{})()}},YL=(t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")};function Re(t,e,n=!1){var r;const i=e.seen.get(t);if(e.override){const l=(r=e.override)==null?void 0:r.call(e,t,e,i,n);if(l!==fL)return l}if(i&&!n){const l=KL(i,e);if(l!==void 0)return l}const a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);const s=WL(t,t.typeName,e),o=typeof s=="function"?Re(s(),e):s;if(o&&XL(t,e,o),e.postProcess){const l=e.postProcess(o,t,e);return a.jsonSchema=o,l}return a.jsonSchema=o,o}var KL=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:YL(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Qt()):e.$refStrategy==="seen"?Qt():void 0}},XL=(t,e,n)=>(t.description&&(n.description=t.description),n),ZL=t=>{const e=hL(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}},QL=(t,e)=>{var n;const r=ZL(e);let i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[c,d])=>{var p;return{...u,[c]:(p=Re(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0))!=null?p:Qt()}},{}):void 0;const a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=(n=Re(t._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))!=null?n:Qt(),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(s.title=o);const l=a===void 0?i?{...s,[r.definitionPath]:i}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,a].join("/"),[r.definitionPath]:{...i,[a]:s}};return l.$schema="http://json-schema.org/draft-07/schema#",l},Fm=Symbol.for("vercel.ai.schema");function JL(t){let e;return()=>(e==null&&(e=t()),e)}function hl(t,{validate:e}={}){return{[Fm]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function eD(t){return typeof t=="object"&&t!==null&&Fm in t&&t[Fm]===!0&&"jsonSchema"in t&&"validate"in t}function tb(t){return t==null?hl({properties:{},additionalProperties:!1}):eD(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?j_(t):tD(t):t()}function tD(t){return hl(()=>eb(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const n=await t["~standard"].validate(e);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new Ci({value:e,cause:n.issues})}}})}function nD(t,e){var n;const r=(n=void 0)!=null?n:!1;return hl(()=>QL(t,{$refStrategy:r?"root":"none"}),{validate:async i=>{const a=await t.safeParseAsync(i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function rD(t,e){var n;const r=(n=void 0)!=null?n:!1;return hl(()=>eb(qO(t,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const a=await jO(t,i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function iD(t){return"_zod"in t}function j_(t,e){return iD(t)?rD(t):nD(t)}async function s0({value:t,schema:e}){const n=await Ma({value:t,schema:e});if(!n.success)throw Ci.wrap({value:t,cause:n.error});return n.value}async function Ma({value:t,schema:e}){const n=tb(e);try{if(n.validate==null)return{success:!0,value:t,rawValue:t};const r=await n.validate(t);return r.success?{success:!0,value:r.value,rawValue:t}:{success:!1,error:Ci.wrap({value:t,cause:r.error}),rawValue:t}}catch(r){return{success:!1,error:Ci.wrap({value:t,cause:r}),rawValue:t}}}async function qr({text:t,schema:e}){try{const n=pL(t);return e==null?{success:!0,value:n,rawValue:n}:await Ma({value:n,schema:e})}catch(n){return{success:!1,error:QE.isInstance(n)?n:new QE({text:t,cause:n}),rawValue:void 0}}}function aD({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new zO).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await qr({text:n,schema:e}))}}))}async function nr(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var sD=Object.defineProperty,oD=(t,e)=>{for(var n in e)sD(t,n,{get:e[n],enumerable:!0})},q_="AI_NoObjectGeneratedError",G_=`vercel.ai.error.${q_}`,lD=Symbol.for(G_),V_,fr=class extends Cn{constructor({message:t="No object generated.",cause:e,text:n,response:r,usage:i,finishReason:a}){super({name:q_,message:t,cause:e}),this[V_]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Cn.hasMarker(t,G_)}};V_=lD;var W_="AI_UIMessageStreamError",Y_=`vercel.ai.error.${W_}`,uD=Symbol.for(Y_),K_,ui=class extends Cn{constructor({chunkType:t,chunkId:e,message:n}){super({name:W_,message:n}),this[K_]=!0,this.chunkType=t,this.chunkId=e}static isInstance(t){return Cn.hasMarker(t,Y_)}};K_=uD;var o0="6.0.55",X_=jt([te(),ro(Uint8Array),ro(ArrayBuffer),o_(t=>{var e,n;return(n=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?n:!1},{message:"Must be a Buffer"})]),Pa=GO(()=>jt([VO(),te(),WO(),Ot(),La(te(),Pa.optional()),ts(Pa)])),ke=La(te(),La(te(),Pa.optional())),Z_=Ie({type:de("text"),text:te(),providerOptions:ke.optional()}),cD=Ie({type:de("image"),image:jt([X_,ro(URL)]),mediaType:te().optional(),providerOptions:ke.optional()}),Q_=Ie({type:de("file"),data:jt([X_,ro(URL)]),filename:te().optional(),mediaType:te(),providerOptions:ke.optional()}),dD=Ie({type:de("reasoning"),text:te(),providerOptions:ke.optional()}),pD=Ie({type:de("tool-call"),toolCallId:te(),toolName:te(),input:Zn(),providerOptions:ke.optional(),providerExecuted:Ot().optional()}),fD=YO("type",[Ie({type:de("text"),value:te(),providerOptions:ke.optional()}),Ie({type:de("json"),value:Pa,providerOptions:ke.optional()}),Ie({type:de("execution-denied"),reason:te().optional(),providerOptions:ke.optional()}),Ie({type:de("error-text"),value:te(),providerOptions:ke.optional()}),Ie({type:de("error-json"),value:Pa,providerOptions:ke.optional()}),Ie({type:de("content"),value:ts(jt([Ie({type:de("text"),text:te(),providerOptions:ke.optional()}),Ie({type:de("media"),data:te(),mediaType:te()}),Ie({type:de("file-data"),data:te(),mediaType:te(),filename:te().optional(),providerOptions:ke.optional()}),Ie({type:de("file-url"),url:te(),providerOptions:ke.optional()}),Ie({type:de("file-id"),fileId:jt([te(),La(te(),te())]),providerOptions:ke.optional()}),Ie({type:de("image-data"),data:te(),mediaType:te(),providerOptions:ke.optional()}),Ie({type:de("image-url"),url:te(),providerOptions:ke.optional()}),Ie({type:de("image-file-id"),fileId:jt([te(),La(te(),te())]),providerOptions:ke.optional()}),Ie({type:de("custom"),providerOptions:ke.optional()})]))})]),J_=Ie({type:de("tool-result"),toolCallId:te(),toolName:te(),output:fD,providerOptions:ke.optional()}),hD=Ie({type:de("tool-approval-request"),approvalId:te(),toolCallId:te()}),mD=Ie({type:de("tool-approval-response"),approvalId:te(),approved:Ot(),reason:te().optional()}),gD=Ie({role:de("system"),content:te(),providerOptions:ke.optional()}),bD=Ie({role:de("user"),content:jt([te(),ts(jt([Z_,cD,Q_]))]),providerOptions:ke.optional()}),ED=Ie({role:de("assistant"),content:jt([te(),ts(jt([Z_,Q_,dD,pD,J_,hD]))]),providerOptions:ke.optional()}),yD=Ie({role:de("tool"),content:ts(jt([J_,mD])),providerOptions:ke.optional()});jt([gD,bD,ED,yD]);function eC(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const n={...t};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];if(i===void 0)continue;const a=r in t?t[r]:void 0,s=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),o=a!=null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);s&&o?n[r]=eC(a,i):n[r]=i}return n}var TD={};oD(TD,{array:()=>xD,choice:()=>vD,json:()=>_D,object:()=>kD,text:()=>AD});function SD(t){const e=["ROOT"];let n=-1,r=null;function i(l,u,c){switch(l){case'"':{n=u,e.pop(),e.push(c),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,e.pop(),e.push(c),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(c),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,e.pop(),e.push(c),e.push("INSIDE_NUMBER");break}case"{":{n=u,e.pop(),e.push(c),e.push("INSIDE_OBJECT_START");break}case"[":{n=u,e.pop(),e.push(c),e.push("INSIDE_ARRAY_START");break}}}function a(l,u){switch(l){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,e.pop();break}}}function s(l,u){switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,e.pop();break}}}for(let l=0;l<t.length;l++){const u=t[l];switch(e[e.length-1]){case"ROOT":i(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{a(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{e.pop(),n=l;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=l,e.pop();break}default:{n=l,i(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,e.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(u,l),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(u,l);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(u,l);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(u,l);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const d=t.substring(r,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?a(u,l):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(u,l)):n=l;break}}}let o=t.slice(0,n+1);for(let l=e.length-1;l>=0;l--)switch(e[l]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const c=t.substring(r,t.length);"true".startsWith(c)?o+="true".slice(c.length):"false".startsWith(c)?o+="false".slice(c.length):"null".startsWith(c)&&(o+="null".slice(c.length))}}return o}async function ls(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await qr({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await qr({text:SD(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var AD=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),kD=({schema:t,name:e,description:n})=>{const r=tb(t);return{name:"object",responseFormat:nr(r.jsonSchema).then(i=>({type:"json",schema:i,...e!=null&&{name:e},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},a){const s=await qr({text:i});if(!s.success)throw new fr({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const o=await Ma({value:s.value,schema:r});if(!o.success)throw new fr({message:"No object generated: response did not match schema.",cause:o.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});return o.value},async parsePartialOutput({text:i}){const a=await ls(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:a.value}}},createElementStreamTransform(){}}},xD=({element:t,name:e,description:n})=>{const r=tb(t);return{name:"array",responseFormat:nr(r.jsonSchema).then(i=>{const{$schema:a,...s}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:s}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},a){const s=await qr({text:i});if(!s.success)throw new fr({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const o=s.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new fr({message:"No object generated: response did not match schema.",cause:new Ci({value:o,cause:"response must be an object with an elements array"}),text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});for(const l of o.elements){const u=await Ma({value:l,schema:r});if(!u.success)throw new fr({message:"No object generated: response did not match schema.",cause:u.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason})}return o.elements},async parsePartialOutput({text:i}){const a=await ls(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=a.value;if(s==null||typeof s!="object"||!("elements"in s)||!Array.isArray(s.elements))return;const o=a.state==="repaired-parse"&&s.elements.length>0?s.elements.slice(0,-1):s.elements,l=[];for(const u of o){const c=await Ma({value:u,schema:r});c.success&&l.push(c.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:a},s){if(a!=null)for(;i<a.length;i++)s.enqueue(a[i])}})}}},vD=({options:t,name:e,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const a=await qr({text:r});if(!a.success)throw new fr({message:"No object generated: could not parse the response.",cause:a.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const s=a.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string"||!t.includes(s.result))throw new fr({message:"No object generated: response did not match schema.",cause:new Ci({value:s,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return s.result},async parsePartialOutput({text:r}){const i=await ls(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=i.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string")return;const s=t.filter(o=>o.startsWith(a.result));return i.state==="successful-parse"?s.includes(a.result)?{partial:a.result}:void 0:s.length===1?{partial:s[0]}:void 0}}},createElementStreamTransform(){}}),_D=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:n},r){const i=await qr({text:n});if(!i.success)throw new fr({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await ls(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}},createElementStreamTransform(){}});ss({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
7
+ ]`;continue}a+=i[u],i[u]==="\\"?s=!0:o&&i[u]==="]"?o=!1:!o&&i[u]==="["&&(o=!0)}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return a}function z_(t,e){var n,r,i,a,s,o;const l={type:"object",additionalProperties:(n=Re(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?n:e.allowedAdditionalProperties};if(((r=t.keyType)==null?void 0:r._def.typeName)===ge.ZodString&&((i=t.keyType._def.checks)!=null&&i.length)){const{type:u,...c}=$_(t.keyType._def,e);return{...l,propertyNames:c}}else{if(((a=t.keyType)==null?void 0:a._def.typeName)===ge.ZodEnum)return{...l,propertyNames:{enum:t.keyType._def.values}};if(((s=t.keyType)==null?void 0:s._def.typeName)===ge.ZodBranded&&t.keyType._def.type._def.typeName===ge.ZodString&&((o=t.keyType._def.type._def.checks)!=null&&o.length)){const{type:u,...c}=U_(t.keyType._def,e);return{...l,propertyNames:c}}}return l}function NL(t,e){if(e.mapStrategy==="record")return z_(t,e);const n=Re(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Qt(),r=Re(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Qt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function IL(t){const e=t.values,r=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),i=Array.from(new Set(r.map(a=>typeof a)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function wL(){return{not:Qt()}}function RL(){return{type:"null"}}var Pm={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function OL(t,e){const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Pm&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,a)=>{const s=Pm[a._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,a)=>{const s=typeof a._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(a._def.value===null)return[...i,"null"];default:return i}},[]);if(r.length===n.length){const i=r.filter((a,s,o)=>o.indexOf(a)===s);return{type:i.length>1?i:i[0],enum:n.reduce((a,s)=>a.includes(s._def.value)?a:[...a,s._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(a=>!r.includes(a))],[])};return LL(t,e)}var LL=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>Re(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function DL(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Pm[t.innerType._def.typeName],"null"]};const n=Re(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function ML(t){const e={type:"number"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"int":e.type="integer";break;case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function PL(t,e){const n={type:"object",properties:{}},r=[],i=t.shape();for(const s in i){let o=i[s];if(o===void 0||o._def===void 0)continue;const l=BL(o),u=Re(o._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});u!==void 0&&(n.properties[s]=u,l||r.push(s))}r.length&&(n.required=r);const a=FL(t,e);return a!==void 0&&(n.additionalProperties=a),n}function FL(t,e){if(t.catchall._def.typeName!=="ZodNever")return Re(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function BL(t){try{return t.isOptional()}catch{return!0}}var UL=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return Re(t.innerType._def,e);const r=Re(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Qt()},r]}:Qt()},HL=(t,e)=>{if(e.pipeStrategy==="input")return Re(t.in._def,e);if(e.pipeStrategy==="output")return Re(t.out._def,e);const n=Re(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=Re(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function $L(t,e){return Re(t.type._def,e)}function zL(t,e){const r={type:"array",uniqueItems:!0,items:Re(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(r.minItems=t.minSize.value),t.maxSize&&(r.maxItems=t.maxSize.value),r}function jL(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Re(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Re(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Re(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function qL(){return{not:Qt()}}function GL(){return Qt()}var VL=(t,e)=>Re(t.innerType._def,e),WL=(t,e,n)=>{switch(e){case ge.ZodString:return $_(t,n);case ge.ZodNumber:return ML(t);case ge.ZodObject:return PL(t,n);case ge.ZodBigInt:return gL(t);case ge.ZodBoolean:return bL();case ge.ZodDate:return H_(t,n);case ge.ZodUndefined:return qL();case ge.ZodNull:return RL();case ge.ZodArray:return mL(t,n);case ge.ZodUnion:case ge.ZodDiscriminatedUnion:return OL(t,n);case ge.ZodIntersection:return xL(t,n);case ge.ZodTuple:return jL(t,n);case ge.ZodRecord:return z_(t,n);case ge.ZodLiteral:return vL(t);case ge.ZodEnum:return AL(t);case ge.ZodNativeEnum:return IL(t);case ge.ZodNullable:return DL(t,n);case ge.ZodOptional:return UL(t,n);case ge.ZodMap:return NL(t,n);case ge.ZodSet:return zL(t,n);case ge.ZodLazy:return()=>t.getter()._def;case ge.ZodPromise:return $L(t,n);case ge.ZodNaN:case ge.ZodNever:return wL();case ge.ZodEffects:return SL(t,n);case ge.ZodAny:return Qt();case ge.ZodUnknown:return GL();case ge.ZodDefault:return TL(t,n);case ge.ZodBranded:return U_(t,n);case ge.ZodReadonly:return VL(t,n);case ge.ZodCatch:return EL(t,n);case ge.ZodPipeline:return HL(t,n);case ge.ZodFunction:case ge.ZodVoid:case ge.ZodSymbol:return;default:return(r=>{})()}},YL=(t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")};function Re(t,e,n=!1){var r;const i=e.seen.get(t);if(e.override){const l=(r=e.override)==null?void 0:r.call(e,t,e,i,n);if(l!==fL)return l}if(i&&!n){const l=KL(i,e);if(l!==void 0)return l}const a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);const s=WL(t,t.typeName,e),o=typeof s=="function"?Re(s(),e):s;if(o&&XL(t,e,o),e.postProcess){const l=e.postProcess(o,t,e);return a.jsonSchema=o,l}return a.jsonSchema=o,o}var KL=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:YL(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Qt()):e.$refStrategy==="seen"?Qt():void 0}},XL=(t,e,n)=>(t.description&&(n.description=t.description),n),ZL=t=>{const e=hL(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}},QL=(t,e)=>{var n;const r=ZL(e);let i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[c,d])=>{var p;return{...u,[c]:(p=Re(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0))!=null?p:Qt()}},{}):void 0;const a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=(n=Re(t._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))!=null?n:Qt(),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(s.title=o);const l=a===void 0?i?{...s,[r.definitionPath]:i}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,a].join("/"),[r.definitionPath]:{...i,[a]:s}};return l.$schema="http://json-schema.org/draft-07/schema#",l},Fm=Symbol.for("vercel.ai.schema");function JL(t){let e;return()=>(e==null&&(e=t()),e)}function hl(t,{validate:e}={}){return{[Fm]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function eD(t){return typeof t=="object"&&t!==null&&Fm in t&&t[Fm]===!0&&"jsonSchema"in t&&"validate"in t}function tb(t){return t==null?hl({properties:{},additionalProperties:!1}):eD(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?j_(t):tD(t):t()}function tD(t){return hl(()=>eb(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const n=await t["~standard"].validate(e);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new Ci({value:e,cause:n.issues})}}})}function nD(t,e){var n;const r=(n=void 0)!=null?n:!1;return hl(()=>QL(t,{$refStrategy:r?"root":"none"}),{validate:async i=>{const a=await t.safeParseAsync(i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function rD(t,e){var n;const r=(n=void 0)!=null?n:!1;return hl(()=>eb(qO(t,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const a=await jO(t,i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function iD(t){return"_zod"in t}function j_(t,e){return iD(t)?rD(t):nD(t)}async function s0({value:t,schema:e}){const n=await Ma({value:t,schema:e});if(!n.success)throw Ci.wrap({value:t,cause:n.error});return n.value}async function Ma({value:t,schema:e}){const n=tb(e);try{if(n.validate==null)return{success:!0,value:t,rawValue:t};const r=await n.validate(t);return r.success?{success:!0,value:r.value,rawValue:t}:{success:!1,error:Ci.wrap({value:t,cause:r.error}),rawValue:t}}catch(r){return{success:!1,error:Ci.wrap({value:t,cause:r}),rawValue:t}}}async function qr({text:t,schema:e}){try{const n=pL(t);return e==null?{success:!0,value:n,rawValue:n}:await Ma({value:n,schema:e})}catch(n){return{success:!1,error:QE.isInstance(n)?n:new QE({text:t,cause:n}),rawValue:void 0}}}function aD({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new zO).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await qr({text:n,schema:e}))}}))}async function nr(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var sD=Object.defineProperty,oD=(t,e)=>{for(var n in e)sD(t,n,{get:e[n],enumerable:!0})},q_="AI_NoObjectGeneratedError",G_=`vercel.ai.error.${q_}`,lD=Symbol.for(G_),V_,fr=class extends Cn{constructor({message:t="No object generated.",cause:e,text:n,response:r,usage:i,finishReason:a}){super({name:q_,message:t,cause:e}),this[V_]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Cn.hasMarker(t,G_)}};V_=lD;var W_="AI_UIMessageStreamError",Y_=`vercel.ai.error.${W_}`,uD=Symbol.for(Y_),K_,ui=class extends Cn{constructor({chunkType:t,chunkId:e,message:n}){super({name:W_,message:n}),this[K_]=!0,this.chunkType=t,this.chunkId=e}static isInstance(t){return Cn.hasMarker(t,Y_)}};K_=uD;var o0="6.0.56",X_=jt([te(),ro(Uint8Array),ro(ArrayBuffer),o_(t=>{var e,n;return(n=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?n:!1},{message:"Must be a Buffer"})]),Pa=GO(()=>jt([VO(),te(),WO(),Ot(),La(te(),Pa.optional()),ts(Pa)])),ke=La(te(),La(te(),Pa.optional())),Z_=Ie({type:de("text"),text:te(),providerOptions:ke.optional()}),cD=Ie({type:de("image"),image:jt([X_,ro(URL)]),mediaType:te().optional(),providerOptions:ke.optional()}),Q_=Ie({type:de("file"),data:jt([X_,ro(URL)]),filename:te().optional(),mediaType:te(),providerOptions:ke.optional()}),dD=Ie({type:de("reasoning"),text:te(),providerOptions:ke.optional()}),pD=Ie({type:de("tool-call"),toolCallId:te(),toolName:te(),input:Zn(),providerOptions:ke.optional(),providerExecuted:Ot().optional()}),fD=YO("type",[Ie({type:de("text"),value:te(),providerOptions:ke.optional()}),Ie({type:de("json"),value:Pa,providerOptions:ke.optional()}),Ie({type:de("execution-denied"),reason:te().optional(),providerOptions:ke.optional()}),Ie({type:de("error-text"),value:te(),providerOptions:ke.optional()}),Ie({type:de("error-json"),value:Pa,providerOptions:ke.optional()}),Ie({type:de("content"),value:ts(jt([Ie({type:de("text"),text:te(),providerOptions:ke.optional()}),Ie({type:de("media"),data:te(),mediaType:te()}),Ie({type:de("file-data"),data:te(),mediaType:te(),filename:te().optional(),providerOptions:ke.optional()}),Ie({type:de("file-url"),url:te(),providerOptions:ke.optional()}),Ie({type:de("file-id"),fileId:jt([te(),La(te(),te())]),providerOptions:ke.optional()}),Ie({type:de("image-data"),data:te(),mediaType:te(),providerOptions:ke.optional()}),Ie({type:de("image-url"),url:te(),providerOptions:ke.optional()}),Ie({type:de("image-file-id"),fileId:jt([te(),La(te(),te())]),providerOptions:ke.optional()}),Ie({type:de("custom"),providerOptions:ke.optional()})]))})]),J_=Ie({type:de("tool-result"),toolCallId:te(),toolName:te(),output:fD,providerOptions:ke.optional()}),hD=Ie({type:de("tool-approval-request"),approvalId:te(),toolCallId:te()}),mD=Ie({type:de("tool-approval-response"),approvalId:te(),approved:Ot(),reason:te().optional()}),gD=Ie({role:de("system"),content:te(),providerOptions:ke.optional()}),bD=Ie({role:de("user"),content:jt([te(),ts(jt([Z_,cD,Q_]))]),providerOptions:ke.optional()}),ED=Ie({role:de("assistant"),content:jt([te(),ts(jt([Z_,Q_,dD,pD,J_,hD]))]),providerOptions:ke.optional()}),yD=Ie({role:de("tool"),content:ts(jt([J_,mD])),providerOptions:ke.optional()});jt([gD,bD,ED,yD]);function eC(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const n={...t};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];if(i===void 0)continue;const a=r in t?t[r]:void 0,s=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),o=a!=null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);s&&o?n[r]=eC(a,i):n[r]=i}return n}var TD={};oD(TD,{array:()=>xD,choice:()=>vD,json:()=>_D,object:()=>kD,text:()=>AD});function SD(t){const e=["ROOT"];let n=-1,r=null;function i(l,u,c){switch(l){case'"':{n=u,e.pop(),e.push(c),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,e.pop(),e.push(c),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(c),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,e.pop(),e.push(c),e.push("INSIDE_NUMBER");break}case"{":{n=u,e.pop(),e.push(c),e.push("INSIDE_OBJECT_START");break}case"[":{n=u,e.pop(),e.push(c),e.push("INSIDE_ARRAY_START");break}}}function a(l,u){switch(l){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,e.pop();break}}}function s(l,u){switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,e.pop();break}}}for(let l=0;l<t.length;l++){const u=t[l];switch(e[e.length-1]){case"ROOT":i(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{u==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{u==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{u===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{a(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{e.pop(),n=l;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{u==="]"?(n=l,e.pop()):(n=l,i(u,l,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,e.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(u,l),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(u,l);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(u,l);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(u,l);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const d=t.substring(r,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?a(u,l):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(u,l)):n=l;break}}}let o=t.slice(0,n+1);for(let l=e.length-1;l>=0;l--)switch(e[l]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const c=t.substring(r,t.length);"true".startsWith(c)?o+="true".slice(c.length):"false".startsWith(c)?o+="false".slice(c.length):"null".startsWith(c)&&(o+="null".slice(c.length))}}return o}async function ls(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await qr({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await qr({text:SD(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var AD=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),kD=({schema:t,name:e,description:n})=>{const r=tb(t);return{name:"object",responseFormat:nr(r.jsonSchema).then(i=>({type:"json",schema:i,...e!=null&&{name:e},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},a){const s=await qr({text:i});if(!s.success)throw new fr({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const o=await Ma({value:s.value,schema:r});if(!o.success)throw new fr({message:"No object generated: response did not match schema.",cause:o.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});return o.value},async parsePartialOutput({text:i}){const a=await ls(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:a.value}}},createElementStreamTransform(){}}},xD=({element:t,name:e,description:n})=>{const r=tb(t);return{name:"array",responseFormat:nr(r.jsonSchema).then(i=>{const{$schema:a,...s}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:s}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},a){const s=await qr({text:i});if(!s.success)throw new fr({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const o=s.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new fr({message:"No object generated: response did not match schema.",cause:new Ci({value:o,cause:"response must be an object with an elements array"}),text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});for(const l of o.elements){const u=await Ma({value:l,schema:r});if(!u.success)throw new fr({message:"No object generated: response did not match schema.",cause:u.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason})}return o.elements},async parsePartialOutput({text:i}){const a=await ls(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=a.value;if(s==null||typeof s!="object"||!("elements"in s)||!Array.isArray(s.elements))return;const o=a.state==="repaired-parse"&&s.elements.length>0?s.elements.slice(0,-1):s.elements,l=[];for(const u of o){const c=await Ma({value:u,schema:r});c.success&&l.push(c.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:a},s){if(a!=null)for(;i<a.length;i++)s.enqueue(a[i])}})}}},vD=({options:t,name:e,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const a=await qr({text:r});if(!a.success)throw new fr({message:"No object generated: could not parse the response.",cause:a.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const s=a.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string"||!t.includes(s.result))throw new fr({message:"No object generated: response did not match schema.",cause:new Ci({value:s,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return s.result},async parsePartialOutput({text:r}){const i=await ls(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=i.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string")return;const s=t.filter(o=>o.startsWith(a.result));return i.state==="successful-parse"?s.includes(a.result)?{partial:a.result}:void 0:s.length===1?{partial:s[0]}:void 0}}},createElementStreamTransform(){}}),_D=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:n},r){const i=await qr({text:n});if(!i.success)throw new fr({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await ls(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}},createElementStreamTransform(){}});ss({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
8
8
 
9
9
  `)},flush(t){t.enqueue(`data: [DONE]
10
10
 
@@ -31,7 +31,7 @@ ${i}`}]}catch(i){console.error("Failed to decode text file:",i)}return[{type:"fi
31
31
  `);return{dom:l,text:p,slice:e}}function yN(t,e,n,r,i){let a=i.parent.type.spec.code,s,o;if(!n&&!e)return null;let l=!!e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,a||r,t)}),a)return o=new se(K.from(t.state.schema.text(e.replace(/\r\n?/g,`
32
32
  `))),0,0),t.someProp("transformPasted",p=>{o=p(o,t,!0)}),o;let d=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(d)o=d;else{let p=i.marks(),{schema:f}=t.state,h=ni.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let b=s.appendChild(document.createElement("p"));g&&b.appendChild(h.serializeNode(f.text(g,p)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=RP(n),ds&&OP(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let p=s.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;s=p}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||mr.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||c),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!NP.test(p.parentNode.nodeName)?{ignore:!0}:null}})),c)o=LP(Q0(o,+c[1],+c[2]),c[4]);else if(o=se.maxOpen(IP(o.content,i),!0),o.openStart||o.openEnd){let d=0,p=0;for(let f=o.content.firstChild;d<o.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=o.content.lastChild;p<o.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);o=Q0(o,d,p)}return t.someProp("transformPasted",d=>{o=d(o,t,l)}),o}const NP=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function IP(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,s=[];if(t.forEach(o=>{if(!s)return;let l=i.findWrapping(o.type),u;if(!l)return s=null;if(u=s.length&&a.length&&SN(l,a,o,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=AN(s[s.length-1],a.length));let c=TN(o,l);s.push(c),i=i.matchType(c.type),a=l}}),s)return K.from(s)}return t}function TN(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,K.from(t));return t}function SN(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=SN(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(K.from(TN(n,t,i+1))))}}function AN(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,AN(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(K.empty,!0);return t.copy(n.append(r))}function rg(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),i<r-1&&(o=rg(o,e,n,r,i+1,a)),i>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=i).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(K.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function Q0(t,e,n){return e<t.openStart&&(t=new se(rg(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new se(rg(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const kN={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let J0=null;function xN(){return J0||(J0=document.implementation.createHTMLDocument("title"))}let du=null;function wP(t){let e=window.trustedTypes;return e?(du||(du=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),du.createHTML(t)):t}function RP(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=xN().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&kN[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=wP(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function OP(t){let e=t.querySelectorAll(ct?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function LP(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:s}=t;for(let o=r.length-2;o>=0;o-=2){let l=n.nodes[r[o]];if(!l||l.hasRequiredAttrs())break;i=K.from(l.create(r[o+1],i)),a++,s++}return new se(i,a,s)}const Pt={},Ft={},DP={touchstart:!0,touchmove:!0};class MP{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function PP(t){for(let e in Pt){let n=Pt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{BP(t,r)&&!bb(t,r)&&(t.editable||!(r.type in Ft))&&n(t,r)},DP[e]?{passive:!0}:void 0)}bt&&t.dom.addEventListener("input",()=>null),ig(t)}function cr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function FP(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ig(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>bb(t,r))})}function bb(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function BP(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function UP(t,e){!bb(t,e)&&Pt[e.type]&&(t.editable||!(e.type in Ft))&&Pt[e.type](t,e)}Ft.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!_N(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!($n&&ct&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ri&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Rr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||CP(t,n)?n.preventDefault():cr(t,"key")};Ft.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ft.keypress=(t,e)=>{let n=e;if(_N(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||rn&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof fe)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function Sl(t){return{left:t.clientX,top:t.clientY}}function HP(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Eb(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),i,!0):o(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function vi(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function $P(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ue.isSelectable(r)?(vi(t,new ue(n)),!0):!1}function zP(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof ue&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(ue.isSelectable(o)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(vi(t,ue.create(t.state.doc,i)),!0):!1}function jP(t,e,n,r,i){return Eb(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?zP(t,n):$P(t,n))}function qP(t,e,n,r){return Eb(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function GP(t,e,n,r){return Eb(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||VP(t,n,r)}function VP(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(vi(t,fe.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),o=i.before(a);if(s.inlineContent)vi(t,fe.create(r,o+1,o+1+s.content.size));else if(ue.isSelectable(s))vi(t,ue.create(r,o));else continue;return!0}}function yb(t){return go(t)}const vN=rn?"metaKey":"ctrlKey";Pt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=yb(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&HP(n,t.input.lastClick)&&!n[vN]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let s=t.posAtCoords(Sl(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new WP(t,s,n,!!r)):(a=="doubleClick"?qP:GP)(t,s.pos,s.inside,n)?n.preventDefault():cr(t,"pointer"))};class WP{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[vN],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let c=e.state.doc.resolve(n.pos);a=c.parent,s=c.depth?c.before():0}const o=i?null:r.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof ue&&u.from<=s&&u.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&un&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),cr(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Gn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Sl(e))),this.updateAllowDefault(e),this.allowDefault||!n?cr(this.view,"pointer"):jP(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||bt&&this.mightDrag&&!this.mightDrag.node.isAtom||ct&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(vi(this.view,ye.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):cr(this.view,"pointer")}move(e){this.updateAllowDefault(e),cr(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Pt.touchstart=t=>{t.input.lastTouch=Date.now(),yb(t),cr(t,"pointer")};Pt.touchmove=t=>{t.input.lastTouch=Date.now(),cr(t,"pointer")};Pt.contextmenu=t=>yb(t);function _N(t,e){return t.composing?!0:bt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const YP=$n?5e3:-1;Ft.compositionstart=Ft.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof fe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ct&&rN&&KP(t)))t.markCursor=t.state.storedMarks||n.marks(),go(t,!0),t.markCursor=null;else if(go(t,!e.selection.empty),un&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}CN(t,YP)};function KP(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ft.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,CN(t,20))};function CN(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>go(t),e))}function NN(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ZP());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function XP(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=z3(e.focusNode,e.focusOffset),r=j3(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function ZP(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function go(t,e=!1){if(!($n&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),NN(t),e||t.docView&&t.docView.dirty){let n=hb(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function QP(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const $a=qt&&gr<15||Ri&&W3<604;Pt.copy=Ft.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=$a?null:n.clipboardData,s=r.content(),{dom:o,text:l}=gb(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",l)):QP(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function JP(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function eF(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?za(t,r.value,null,i,e):za(t,r.textContent,r.innerHTML,i,e)},50)}function za(t,e,n,r,i){let a=yN(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,a||se.empty)))return!0;if(!a)return!1;let s=JP(a),o=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function IN(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ft.paste=(t,e)=>{let n=e;if(t.composing&&!$n)return;let r=$a?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&za(t,IN(r),r.getData("text/html"),i,n)?n.preventDefault():eF(t,n)};class wN{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const tF=rn?"altKey":"ctrlKey";function RN(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[tF]}Pt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(Sl(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof ue?i.to-1:i.to))){if(r&&r.mightDrag)s=ue.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=ue.create(t.state.doc,d.posBefore))}}let o=(s||t.state.selection).content(),{dom:l,text:u,slice:c}=gb(t,o);(!n.dataTransfer.files.length||!ct||nN>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData($a?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",$a||n.dataTransfer.setData("text/plain",u),t.dragging=new wN(c,RN(t,n),s)};Pt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ft.dragover=Ft.dragenter=(t,e)=>e.preventDefault();Ft.drop=(t,e)=>{try{nF(t,e,t.dragging)}finally{t.dragging=null}};function nF(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Sl(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",f=>{a=f(a,t,!1)}):a=yN(t,IN(e.dataTransfer),$a?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&RN(t,e));if(t.someProp("handleDrop",f=>f(t,e,a||se.empty,s))){e.preventDefault();return}if(!a)return;e.preventDefault();let o=a?MC(t.state.doc,i.pos,a):i.pos;o==null&&(o=i.pos);let l=t.state.tr;if(s){let{node:f}=n;f?f.replace(l):l.deleteSelection()}let u=l.mapping.map(o),c=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=l.doc;if(c?l.replaceRangeWith(u,u,a.content.firstChild):l.replaceRange(u,u,a),l.doc.eq(d))return;let p=l.doc.resolve(u);if(c&&ue.isSelectable(a.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(a.content.firstChild))l.setSelection(new ue(p));else{let f=l.mapping.map(o);l.mapping.maps[l.mapping.maps.length-1].forEach((h,g,b,E)=>f=E),l.setSelection(mb(t,p,l.doc.resolve(f)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Pt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Gn(t)},20))};Pt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Pt.beforeinput=(t,e)=>{if(ct&&$n&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Rr(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Ft)Pt[t]=Ft[t];function ja(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class bo{constructor(e,n){this.toDOM=e,this.spec=n||Ur,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new St(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof bo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ja(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Er{constructor(e,n){this.attrs=e,this.spec=n||Ur}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=s?null:new St(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Er&&ja(this.attrs,e.attrs)&&ja(this.spec,e.spec)}static is(e){return e.type instanceof Er}destroy(){}}class Tb{constructor(e,n){this.attrs=e,this.spec=n||Ur}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=a.pos?null:new St(a.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof Tb&&ja(this.attrs,e.attrs)&&ja(this.spec,e.spec)}destroy(){}}class St{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new St(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new St(e,e,new bo(n,r))}static inline(e,n,r,i){return new St(e,n,new Er(r,i))}static node(e,n,r,i){return new St(e,n,new Tb(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Er}get widget(){return this.type instanceof bo}}const bi=[],Ur={};class qe{constructor(e,n){this.local=e.length?e:bi,this.children=n.length?n:bi}static create(e,n){return n.length?Eo(n,e,0,Ur):Tt}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,r,i+o,a)}}map(e,n,r){return this==Tt||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ur)}mapInner(e,n,r,i,a){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?rF(this.children,s||[],e,n,r,i,a):s?new qe(s.sort(Hr),bi):Tt}add(e,n){return n.length?this==Tt?qe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((o,l)=>{let u=l+r,c;if(c=LN(n,o,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<l;)a+=3;i[a]==l?i[a+2]=i[a+2].addInner(o,c,u+1):i.splice(a,0,l,l+o.nodeSize,Eo(c,o,u+1,Ur)),a+=3}});let s=ON(a?DN(n):n,-r);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new qe(s.length?this.local.concat(s).sort(Hr):this.local,i||this.children)}remove(e){return e.length==0||this==Tt?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let s,o=r[a]+n,l=r[a+1]+n;for(let c=0,d;c<e.length;c++)(d=e[c])&&d.from>o&&d.to<l&&(e[c]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(s,o+1);u!=Tt?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<i.length;o++)i[o].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new qe(i,r):Tt}forChild(e,n){if(this==Tt)return this;if(n.isLeaf)return qe.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<s&&l.to>a&&l.type instanceof Er){let u=Math.max(a,l.from)-a,c=Math.min(s,l.to)-a;u<c&&(i||(i=[])).push(l.copy(u,c))}}if(i){let o=new qe(i.sort(Hr),bi);return r?new sr([o,r]):o}return r||Tt}eq(e){if(this==e)return!0;if(!(e instanceof qe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Sb(this.localsInner(e))}localsInner(e){if(this==Tt)return bi;if(e.inlineContent||!this.local.some(Er.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Er||n.push(this.local[r]);return n}forEachSet(e){e(this)}}qe.empty=new qe([],[]);qe.removeOverlap=Sb;const Tt=qe.empty;class sr{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Ur));return sr.from(r)}forChild(e,n){if(n.isLeaf)return qe.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Tt&&(a instanceof sr?r=r.concat(a.members):r.push(a))}return sr.from(r)}eq(e){if(!(e instanceof sr)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let s=0;s<a.length;s++)n.push(a[s])}}return n?Sb(r?n:n.sort(Hr)):bi}static from(e){switch(e.length){case 0:return Tt;case 1:return e[0];default:return new sr(e.every(n=>n instanceof qe)?e:e.reduce((n,r)=>n.concat(r instanceof qe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function rF(t,e,n,r,i,a,s){let o=t.slice();for(let u=0,c=a;u<n.maps.length;u++){let d=0;n.maps[u].forEach((p,f,h,g)=>{let b=g-h-(f-p);for(let E=0;E<o.length;E+=3){let T=o[E+1];if(T<0||p>T+c-d)continue;let y=o[E]+c-d;f>=y?o[E+1]=p<=y?-2:-1:p>=c&&b&&(o[E]+=b,o[E+1]+=b)}d+=b}),c=n.maps[u].map(c,-1)}let l=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){l=!0,o[u+1]=-1;continue}let c=n.map(t[u]+a),d=c-i;if(d<0||d>=r.content.size){l=!0;continue}let p=n.map(t[u+1]+a,-1),f=p-i,{index:h,offset:g}=r.content.findIndex(d),b=r.maybeChild(h);if(b&&g==d&&g+b.nodeSize==f){let E=o[u+2].mapInner(n,b,c+1,t[u]+a+1,s);E!=Tt?(o[u]=d,o[u+1]=f,o[u+2]=E):(o[u+1]=-2,l=!0)}else l=!0}if(l){let u=iF(o,t,e,n,i,a,s),c=Eo(u,r,0,s);e=c.local;for(let d=0;d<o.length;d+=3)o[d+1]<0&&(o.splice(d,3),d-=3);for(let d=0,p=0;d<c.children.length;d+=3){let f=c.children[d];for(;p<o.length&&o[p]<f;)p+=3;o.splice(p,0,c.children[d],c.children[d+1],c.children[d+2])}}return new qe(e.sort(Hr),o)}function ON(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new St(i.from+e,i.to+e,i.type))}return n}function iF(t,e,n,r,i,a,s){function o(l,u){for(let c=0;c<l.local.length;c++){let d=l.local[c].map(r,i,u);d?n.push(d):s.onRemove&&s.onRemove(l.local[c].spec)}for(let c=0;c<l.children.length;c+=3)o(l.children[c+2],l.children[c]+u+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+a+1);return n}function LN(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[a]=null);return i}function DN(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Eo(t,e,n,r){let i=[],a=!1;e.forEach((o,l)=>{let u=LN(t,o,l+n);if(u){a=!0;let c=Eo(u,o,n+l+1,r);c!=Tt&&i.push(l,l+o.nodeSize,c)}});let s=ON(a?DN(t):t,-n).sort(Hr);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(r.onRemove&&r.onRemove(s[o].spec),s.splice(o--,1));return s.length||i.length?new qe(s,i):Tt}function Hr(t,e){return t.from-e.from||t.to-e.to}function Sb(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),ey(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),ey(e,i,r.copy(a.from,r.to)));break}}}return e}function ey(t,e,n){for(;e<t.length&&Hr(n,t[e])>0;)e++;t.splice(e,0,n)}function pu(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Tt&&e.push(r)}),t.cursorWrapper&&e.push(qe.create(t.state.doc,[t.cursorWrapper.deco])),sr.from(e)}const aF={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sF=qt&&gr<=11;class oF{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class lF{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new oF,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);qt&&gr<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():bt&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),sF&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,aF)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(V0(this.view)){if(this.suppressingSelectionUpdates)return Gn(this.view);if(qt&&gr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=wi(a))n.add(a);for(let a=e.anchorNode;a;a=wi(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&V0(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,o=!1,l=[];if(e.editable)for(let c=0;c<n.length;c++){let d=this.registerMutation(n[c],l);d&&(a=a<0?d.from:Math.min(d.from,a),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(o=!0))}if(un&&l.length){let c=l.filter(d=>d.nodeName=="BR");if(c.length==2){let[d,p]=c;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let p of c){let f=p.parentNode;f&&f.nodeName=="LI"&&(!d||dF(e,d)!=f)&&p.remove()}}}else if((ct||bt)&&l.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let c of l)if(c.nodeName=="BR"&&c.parentNode){let d=c.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&c.parentNode.removeChild(c)}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&yl(r)&&(u=hb(e))&&u.eq(ye.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Gn(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),uF(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,pF(e,l)),this.handleDOMChange(a,s,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Gn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let d=e.addedNodes[c];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(qt&&gr<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:d,nextSibling:p}=e.addedNodes[c];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(a=p)}let s=i&&i.parentNode==e.target?ht(i)+1:0,o=r.localPosFromDOM(e.target,s,-1),l=a&&a.parentNode==e.target?ht(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,l,1);return{from:o,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ty=new WeakMap,ny=!1;function uF(t){if(!ty.has(t)&&(ty.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=un,ny)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ny=!0}}function ry(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Wr(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function cF(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return ry(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?ry(t,n):null}function dF(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function pF(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let a of e)if(((n=a.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=a.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let o=s;for(;;){let l=o.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;o=l}o.insertBefore(a,o.firstChild),r==a&&t.domSelection().collapse(a,i)}else a.parentNode.removeChild(a)}}function fF(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),u,c=l.anchorNode;if(c&&t.dom.contains(c.nodeType==1?c:c.parentNode)&&(u=[{node:c,offset:l.anchorOffset}],yl(l)||u.push({node:l.focusNode,offset:l.focusOffset})),ct&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let E=r.childNodes[b-1],T=E.pmViewDesc;if(E.nodeName=="BR"&&!T){a=b;break}if(!T||T.size)break}let d=t.state.doc,p=t.someProp("domParser")||mr.fromSchema(t.state.schema),f=d.resolve(s),h=null,g=p.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:a,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:hF,context:f});if(u&&u[0].pos!=null){let b=u[0].pos,E=u[1]&&u[1].pos;E==null&&(E=b),h={anchor:b+s,head:E+s}}return{doc:g,sel:h,from:s,to:o}}function hF(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(bt&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||bt&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const mF=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function gF(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let v=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,w=hb(t,v);if(w&&!t.state.selection.eq(w)){if(ct&&$n&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",C=>C(t,Rr(13,"Enter"))))return;let _=t.state.tr.setSelection(w);v=="pointer"?_.setMeta("pointer",!0):v=="key"&&_.scrollIntoView(),a&&_.setMeta("composition",a),t.dispatch(_)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,u=fF(t,e,n),c=t.state.doc,d=c.slice(u.from,u.to),p,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,f="end"):(p=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let h=yF(d.content,u.doc.content,u.from,p,f);if(h&&t.input.domChangeCount++,(Ri&&t.input.lastIOSEnter>Date.now()-225||$n)&&i.some(v=>v.nodeType==1&&!mF.test(v.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",v=>v(t,Rr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&l instanceof fe&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let v=iy(t,t.state.doc,u.sel);if(v&&!v.eq(t.state.selection)){let w=t.state.tr.setSelection(v);a&&w.setMeta("composition",a),t.dispatch(w)}}return}t.state.selection.from<t.state.selection.to&&h.start==h.endB&&t.state.selection instanceof fe&&(h.start>t.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?h.start=t.state.selection.from:h.endA<t.state.selection.to&&h.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),qt&&gr<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let g=u.doc.resolveNoCache(h.start-u.from),b=u.doc.resolveNoCache(h.endB-u.from),E=c.resolve(h.start),T=g.sameParent(b)&&g.parent.inlineContent&&E.end()>=h.endA;if((Ri&&t.input.lastIOSEnter>Date.now()-225&&(!T||i.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!T&&g.pos<u.doc.content.size&&(!g.sameParent(b)||!g.parent.inlineContent)&&g.pos<b.pos&&!/\S/.test(u.doc.textBetween(g.pos,b.pos,"","")))&&t.someProp("handleKeyDown",v=>v(t,Rr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&EF(c,h.start,h.endA,g,b)&&t.someProp("handleKeyDown",v=>v(t,Rr(8,"Backspace")))){$n&&ct&&t.domObserver.suppressSelectionUpdates();return}ct&&h.endB==h.start&&(t.input.lastChromeDelete=Date.now()),$n&&!T&&g.start()!=b.start()&&b.parentOffset==0&&g.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,b=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(v){return v(t,Rr(13,"Enter"))})},20));let y=h.start,k=h.endA,x=v=>{let w=v||t.state.tr.replace(y,k,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let _=iy(t,w.doc,u.sel);_&&!(ct&&t.composing&&_.empty&&(h.start!=h.endB||t.input.lastChromeDelete<Date.now()-100)&&(_.head==y||_.head==w.mapping.map(k)-1)||qt&&_.empty&&_.head==y)&&w.setSelection(_)}return a&&w.setMeta("composition",a),w.scrollIntoView()},A;if(T)if(g.pos==b.pos){qt&&gr<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Gn(t),20));let v=x(t.state.tr.delete(y,k)),w=c.resolve(h.start).marksAcross(c.resolve(h.endA));w&&v.ensureMarks(w),t.dispatch(v)}else if(h.endA==h.endB&&(A=bF(g.parent.content.cut(g.parentOffset,b.parentOffset),E.parent.content.cut(E.parentOffset,h.endA-E.start())))){let v=x(t.state.tr);A.type=="add"?v.addMark(y,k,A.mark):v.removeMark(y,k,A.mark),t.dispatch(v)}else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let v=g.parent.textBetween(g.parentOffset,b.parentOffset),w=()=>x(t.state.tr.insertText(v,y,k));t.someProp("handleTextInput",_=>_(t,y,k,v,w))||t.dispatch(w())}else t.dispatch(x());else t.dispatch(x())}function iy(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:mb(t,e.resolve(n.anchor),e.resolve(n.head))}function bF(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,o,l;for(let c=0;c<r.length;c++)i=r[c].removeFromSet(i);for(let c=0;c<n.length;c++)a=n[c].removeFromSet(a);if(i.length==1&&a.length==0)o=i[0],s="add",l=c=>c.mark(o.addToSet(c.marks));else if(i.length==0&&a.length==1)o=a[0],s="remove",l=c=>c.mark(o.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<e.childCount;c++)u.push(l(e.child(c)));if(K.from(u).eq(t))return{mark:o,type:s}}function EF(t,e,n,r,i){if(n-e<=i.pos-r.pos||fu(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(fu(a,!0,!0));return!s.parent.isTextblock||s.pos>n||fu(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function fu(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function yF(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,a-Math.min(s,o));r-=s+l-a}if(s<a&&t.size<e.size){let l=r<=a&&r>=s?a-r:0;a-=l,a&&a<e.size&&ay(e.textBetween(a-1,a+1))&&(a+=l?1:-1),o=a+(o-s),s=a}else if(o<a){let l=r<=a&&r>=o?a-r:0;a-=l,a&&a<t.size&&ay(t.textBetween(a-1,a+1))&&(a+=l?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function ay(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class MN{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new MP,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(cy),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=ly(this),oy(this),this.nodeViews=uy(this),this.docView=H0(this.state.doc,sy(this),pu(this),this.dom,this),this.domObserver=new lF(this,(r,i,a,s)=>gF(this,r,i,a,s)),this.domObserver.start(),PP(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ig(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(cy),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,s=!1;e.storedMarks&&this.composing&&(NN(this),s=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=uy(this);SF(f,this.nodeViews)&&(this.nodeViews=f,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&ig(this),this.editable=ly(this),oy(this);let l=pu(this),u=sy(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=a||!this.docView.matchesNode(e.doc,u,l);(d||!e.selection.eq(i.selection))&&(s=!0);let p=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&X3(this);if(s){this.domObserver.stop();let f=d&&(qt||ct)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&TF(i.selection,e.selection);if(d){let h=ct?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=XP(this)),(a||!this.docView.update(e.doc,u,l,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=H0(e.doc,u,l,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&TP(this))?Gn(this,f):(gN(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():p&&Z3(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ue){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&D0(this,n.getBoundingClientRect(),e)}else D0(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new wN(e.slice,e.move,i<0?void 0:ue.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(i=n?n(o):o))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(qt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Q3(this.dom),Gn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return rP(this,e)}coordsAtPos(e,n=1){return lN(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return lP(this,n||this.state,e)}pasteHTML(e,n){return za(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return za(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return gb(this,e)}destroy(){this.docView&&(FP(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],pu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,H3())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return UP(this,e)}domSelectionRange(){let e=this.domSelection();return e?bt&&this.root.nodeType===11&&G3(this.dom.ownerDocument)==this.dom&&cF(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}MN.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function sy(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[St.node(0,t.state.doc.content.size,e)]}function oy(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:St.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ly(t){return!t.someProp("editable",e=>e(t.state)===!1)}function TF(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function uy(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function SF(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function cy(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var yr={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},yo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},AF=typeof navigator<"u"&&/Mac/.test(navigator.platform),kF=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var mt=0;mt<10;mt++)yr[48+mt]=yr[96+mt]=String(mt);for(var mt=1;mt<=24;mt++)yr[mt+111]="F"+mt;for(var mt=65;mt<=90;mt++)yr[mt]=String.fromCharCode(mt+32),yo[mt]=String.fromCharCode(mt);for(var hu in yr)yo.hasOwnProperty(hu)||(yo[hu]=yr[hu]);function xF(t){var e=AF&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||kF&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?yo:yr)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const vF=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_F=typeof navigator<"u"&&/Win/.test(navigator.platform);function CF(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))vF?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function NF(t){let e=Object.create(null);for(let n in t)e[CF(n)]=t[n];return e}function mu(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function IF(t){return new $e({props:{handleKeyDown:PN(t)}})}function PN(t){let e=NF(t);return function(n,r){let i=xF(r),a,s=e[mu(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[mu(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(_F&&r.ctrlKey&&r.altKey)&&(a=yr[r.keyCode])&&a!=i){let o=e[mu(a,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var wF=Object.defineProperty,Ab=(t,e)=>{for(var n in e)wF(t,n,{get:e[n],enumerable:!0})};function Al(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var kl=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([s,o])=>[s,(...u)=>{const c=o(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s=[],o=!!t,l=t||i.tr,u=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(l),s.every(d=>d===!0)),c={...Object.fromEntries(Object.entries(n).map(([d,p])=>[d,(...h)=>{const g=this.buildProps(l,e),b=p(...h)(g);return s.push(b),c}])),run:u};return c}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...u)=>l(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s={tr:t,editor:r,view:a,state:Al({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...u)=>l(...u)(s)]))}};return s}},FN={};Ab(FN,{blur:()=>RF,clearContent:()=>OF,clearNodes:()=>LF,command:()=>DF,createParagraphNear:()=>MF,cut:()=>PF,deleteCurrentNode:()=>FF,deleteNode:()=>BF,deleteRange:()=>UF,deleteSelection:()=>HF,enter:()=>$F,exitCode:()=>zF,extendMarkRange:()=>jF,first:()=>qF,focus:()=>VF,forEach:()=>WF,insertContent:()=>YF,insertContentAt:()=>ZF,joinBackward:()=>eB,joinDown:()=>JF,joinForward:()=>tB,joinItemBackward:()=>nB,joinItemForward:()=>rB,joinTextblockBackward:()=>iB,joinTextblockForward:()=>aB,joinUp:()=>QF,keyboardShortcut:()=>oB,lift:()=>lB,liftEmptyBlock:()=>uB,liftListItem:()=>cB,newlineInCode:()=>dB,resetAttributes:()=>pB,scrollIntoView:()=>fB,selectAll:()=>hB,selectNodeBackward:()=>mB,selectNodeForward:()=>gB,selectParentNode:()=>bB,selectTextblockEnd:()=>EB,selectTextblockStart:()=>yB,setContent:()=>TB,setMark:()=>HB,setMeta:()=>$B,setNode:()=>zB,setNodeSelection:()=>jB,setTextDirection:()=>qB,setTextSelection:()=>GB,sinkListItem:()=>VB,splitBlock:()=>WB,splitListItem:()=>YB,toggleList:()=>KB,toggleMark:()=>XB,toggleNode:()=>ZB,toggleWrap:()=>QB,undoInputRule:()=>JB,unsetAllMarks:()=>e4,unsetMark:()=>t4,unsetTextDirection:()=>n4,updateAttributes:()=>r4,wrapIn:()=>i4,wrapInList:()=>a4});var RF=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),OF=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),LF=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,l)=>{if(o.type.isText)return;const{doc:u,mapping:c}=e,d=u.resolve(c.map(l)),p=u.resolve(c.map(l+o.nodeSize)),f=d.blockRange(p);if(!f)return;const h=Ui(f);if(o.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,g)}(h||h===0)&&e.lift(f,h)})}),!0},DF=t=>e=>t(e),MF=()=>({state:t,dispatch:e})=>ZC(t,e),PF=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,a.content),r.setSelection(new fe(r.doc.resolve(Math.max(s-1,0)))),!0},FF=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const o=i.before(a),l=i.after(a);t.delete(o,l).scrollIntoView()}return!0}return!1};function tt(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var BF=t=>({tr:e,state:n,dispatch:r})=>{const i=tt(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===i){if(r){const l=a.before(s),u=a.after(s);e.delete(l,u).scrollIntoView()}return!0}return!1},UF=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},HF=()=>({state:t,dispatch:e})=>lb(t,e),$F=()=>({commands:t})=>t.keyboardShortcut("Enter"),zF=()=>({state:t,dispatch:e})=>v3(t,e);function kb(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function To(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:kb(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function BN(t,e,n={}){return t.find(r=>r.type===e&&To(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function dy(t,e,n={}){return!!BN(t,e,n)}function xb(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(c=>c.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(c=>c.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!BN([...i.node.marks],e,n)))return;let s=i.index,o=t.start()+i.offset,l=s+1,u=o+i.node.nodeSize;for(;s>0&&dy([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&dy([...t.parent.child(l).marks],e,n);)u+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:u}}function Vn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var jF=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Vn(t,r.schema),{doc:s,selection:o}=n,{$from:l,from:u,to:c}=o;if(i){const d=xb(l,a,e);if(d&&d.from<=u&&d.to>=c){const p=fe.create(s,d.from,d.to);n.setSelection(p)}}return!0},qF=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function UN(t){return t instanceof fe}function Dr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function HN(t,e=null){if(!e)return null;const n=ye.atStart(t),r=ye.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?fe.create(t,Dr(0,i,a),Dr(t.content.size,i,a)):fe.create(t,Dr(e,i,a),Dr(e,i,a))}function ag(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function qa(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function GF(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var VF=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(qa()||ag())&&r.dom.focus(),GF()&&!qa()&&!ag()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!UN(n.state.selection))return s(),!0;const o=HN(i.doc,t)||n.state.selection,l=n.state.selection.eq(o);return a&&(l||i.setSelection(o),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},WF=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),YF=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),$N=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&$N(r)}return t};function vs(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return $N(n)}function Ga(t,e,n){if(t instanceof hr||t instanceof K)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return K.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),Ga("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,o="";const l=new xC({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(s=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?mr.fromSchema(l).parseSlice(vs(t),n.parseOptions):mr.fromSchema(l).parse(vs(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=mr.fromSchema(e);return n.slice?a.parseSlice(vs(t),n.parseOptions).content:a.parse(vs(t),n.parseOptions)}return Ga("",e,n)}function KF(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof lt||i instanceof dt))return;const a=t.mapping.maps[r];let s=0;a.forEach((o,l,u,c)=>{s===0&&(s=c)}),t.setSelection(ye.near(t.doc.resolve(s),n))}var XF=t=>!("type"in t),ZF=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=b=>{a.emit("contentError",{editor:a,error:b,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Ga(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){l(b)}try{o=Ga(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(b){return l(b),!1}let{from:c,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,f=!0;if((XF(o)?o:[o]).forEach(b=>{b.check(),p=p?b.isText&&b.marks.length===0:!1,f=f?b.isBlock:!1}),c===d&&f){const{parent:b}=r.doc.resolve(c);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(c-=1,d+=1)}let g;if(p){if(Array.isArray(e))g=e.map(b=>b.text||"").join("");else if(e instanceof K){let b="";e.forEach(E=>{E.text&&(b+=E.text)}),g=b}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,c,d)}else{g=o;const b=r.doc.resolve(c),E=b.node(),T=b.parentOffset===0,y=E.isText||E.isTextblock,k=E.content.size>0;T&&y&&k&&(c=Math.max(0,c-1)),r.replaceWith(c,d,g)}n.updateSelection&&KF(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:g})}return!0},QF=()=>({state:t,dispatch:e})=>A3(t,e),JF=()=>({state:t,dispatch:e})=>k3(t,e),eB=()=>({state:t,dispatch:e})=>qC(t,e),tB=()=>({state:t,dispatch:e})=>YC(t,e),nB=()=>({state:t,dispatch:e,tr:n})=>{try{const r=gl(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},rB=()=>({state:t,dispatch:e,tr:n})=>{try{const r=gl(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},iB=()=>({state:t,dispatch:e})=>T3(t,e),aB=()=>({state:t,dispatch:e})=>S3(t,e);function zN(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function sB(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))qa()||zN()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var oB=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=sB(t).split(/-(?!$)/),s=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,o))});return l?.steps.forEach(u=>{const c=u.map(r.mapping);c&&i&&r.maybeStep(c)}),!0};function Tr(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?tt(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(d,p)=>{if(d.isText)return;const f=Math.max(r,p),h=Math.min(i,p+d.nodeSize);o.push({node:d,from:f,to:h})});const l=i-r,u=o.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>To(d.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((d,p)=>d+p.to-p.from,0)>=l}var lB=(t,e={})=>({state:n,dispatch:r})=>{const i=tt(t,n.schema);return Tr(n,i,e)?x3(n,r):!1},uB=()=>({state:t,dispatch:e})=>QC(t,e),cB=t=>({state:e,dispatch:n})=>{const r=tt(t,e.schema);return P3(r)(e,n)},dB=()=>({state:t,dispatch:e})=>XC(t,e);function xl(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function py(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var pB=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=xl(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=tt(t,r.schema)),o==="mark"&&(s=Vn(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(c,d)=>{a&&a===c.type&&(l=!0,i&&n.setNodeMarkup(d,void 0,py(c.attrs,e))),s&&c.marks.length&&c.marks.forEach(p=>{s===p.type&&(l=!0,i&&n.addMark(d,d+c.nodeSize,s.create(py(p.attrs,e))))})})}),l},fB=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),hB=()=>({tr:t,dispatch:e})=>{if(e){const n=new Xt(t.doc);t.setSelection(n)}return!0},mB=()=>({state:t,dispatch:e})=>VC(t,e),gB=()=>({state:t,dispatch:e})=>KC(t,e),bB=()=>({state:t,dispatch:e})=>N3(t,e),EB=()=>({state:t,dispatch:e})=>R3(t,e),yB=()=>({state:t,dispatch:e})=>w3(t,e);function sg(t,e,n={},r={}){return Ga(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var TB=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:o})=>{const{doc:l}=a;if(r.preserveWhitespace!=="full"){const u=sg(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,l.content.size,u).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function jN(t,e){const n=Vn(e,t.schema),{from:r,to:i,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const o=s.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function qN(t,e){const n=new HC(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function SB(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function AB(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function kB(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function vl(t){return e=>kB(e.$from,t)}function le(t,e,n){return t.config[e]===void 0&&t.parent?le(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?le(t.parent,e,n):null}):t.config[e]}function vb(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=le(e,"addExtensions",n);return r?[e,...vb(r())]:e}).flat(10)}function _b(t,e){const n=ni.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function GN(t){return typeof t=="function"}function Ne(t,e=void 0,...n){return GN(t)?e?t.bind(e)(...n):t(...n):t}function xB(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Oi(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function VN(t){const e=[],{nodeExtensions:n,markExtensions:r}=Oi(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:i},l=le(s,"addGlobalAttributes",o);if(!l)return;l().forEach(c=>{c.types.forEach(d=>{Object.entries(c.attributes).forEach(([p,f])=>{e.push({type:d,name:p,attribute:{...a,...f}})})})})}),i.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},l=le(s,"addAttributes",o);if(!l)return;const u=l();Object.entries(u).forEach(([c,d])=>{const p={...a,...d};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:s.name,name:c,attribute:p})})}),e}function nt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const o=a?String(a).split(" "):[],l=r[i]?r[i].split(" "):[],u=o.filter(c=>!l.includes(c));r[i]=[...l,...u].join(" ")}else if(i==="style"){const o=a?a.split(";").map(c=>c.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(c=>c.trim()).filter(Boolean):[],u=new Map;l.forEach(c=>{const[d,p]=c.split(":").map(f=>f.trim());u.set(d,p)}),o.forEach(c=>{const[d,p]=c.split(":").map(f=>f.trim());u.set(d,p)}),r[i]=Array.from(u.entries()).map(([c,d])=>`${c}: ${d}`).join("; ")}else r[i]=a}),r},{})}function Li(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>nt(n,r),{})}function vB(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function fy(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):vB(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...r,...i}}}}function hy(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&xB(n)?!1:n!=null))}function my(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function _B(t,e){var n;const r=VN(t),{nodeExtensions:i,markExtensions:a}=Oi(t),s=(n=i.find(u=>le(u,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(u=>{const c=r.filter(E=>E.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((E,T)=>{const y=le(T,"extendNodeSchema",d);return{...E,...y?y(u):{}}},{}),f=hy({...p,content:Ne(le(u,"content",d)),marks:Ne(le(u,"marks",d)),group:Ne(le(u,"group",d)),inline:Ne(le(u,"inline",d)),atom:Ne(le(u,"atom",d)),selectable:Ne(le(u,"selectable",d)),draggable:Ne(le(u,"draggable",d)),code:Ne(le(u,"code",d)),whitespace:Ne(le(u,"whitespace",d)),linebreakReplacement:Ne(le(u,"linebreakReplacement",d)),defining:Ne(le(u,"defining",d)),isolating:Ne(le(u,"isolating",d)),attrs:Object.fromEntries(c.map(my))}),h=Ne(le(u,"parseHTML",d));h&&(f.parseDOM=h.map(E=>fy(E,c)));const g=le(u,"renderHTML",d);g&&(f.toDOM=E=>g({node:E,HTMLAttributes:Li(E,c)}));const b=le(u,"renderText",d);return b&&(f.toText=b),[u.name,f]})),l=Object.fromEntries(a.map(u=>{const c=r.filter(b=>b.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((b,E)=>{const T=le(E,"extendMarkSchema",d);return{...b,...T?T(u):{}}},{}),f=hy({...p,inclusive:Ne(le(u,"inclusive",d)),excludes:Ne(le(u,"excludes",d)),group:Ne(le(u,"group",d)),spanning:Ne(le(u,"spanning",d)),code:Ne(le(u,"code",d)),attrs:Object.fromEntries(c.map(my))}),h=Ne(le(u,"parseHTML",d));h&&(f.parseDOM=h.map(b=>fy(b,c)));const g=le(u,"renderHTML",d);return g&&(f.toDOM=b=>g({mark:b,HTMLAttributes:Li(b,c)})),[u.name,f]}));return new xC({topNode:s,nodes:o,marks:l})}function CB(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function So(t){return t.sort((n,r)=>{const i=le(n,"priority")||100,a=le(r,"priority")||100;return i>a?-1:i<a?1:0})}function WN(t){const e=So(vb(t)),n=CB(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function YN(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
33
33
 
34
- `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(l,u,c,d)=>{var p;l.isBlock&&u>r&&(o+=a);const f=s?.[l.type.name];if(f)return c&&(o+=f({node:l,pos:u,parent:c,index:d,range:e})),!1;l.isText&&(o+=(p=l?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),o}function NB(t,e){const n={from:0,to:t.content.size};return YN(t,n,e)}function KN(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function IB(t,e){const n=tt(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function XN(t,e){const n=xl(typeof e=="string"?e:e.name,t.schema);return n==="node"?IB(t,e):n==="mark"?jN(t,e):{}}function wB(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function RB(t){const e=wB(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function ZN(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,l)=>{s.push({from:o,to:l})});else{const{from:o,to:l}=n[a];if(o===void 0||l===void 0)return;s.push({from:o,to:l})}s.forEach(({from:o,to:l})=>{const u=e.slice(a).map(o,-1),c=e.slice(a).map(l),d=e.invert().map(u,-1),p=e.invert().map(c);r.push({oldRange:{from:d,to:p},newRange:{from:u,to:c}})})}),RB(r)}function Cb(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=xb(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var OB=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function _s(t,e){return e.nodes[t]||e.marks[t]||null}function Ys(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var LB=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var l,u;const c=((u=(l=i.type.spec).toText)==null?void 0:u.call(l,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?c:c.slice(0,Math.max(0,r-a))}),n};function og(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Vn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>a?a.name===d.type.name:!0).find(d=>To(d.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:d,$to:p})=>{const f=d.pos,h=p.pos;t.doc.nodesBetween(f,h,(g,b)=>{if(!g.isText&&!g.marks.length)return;const E=Math.max(f,b),T=Math.min(h,b+g.nodeSize),y=T-E;s+=y,o.push(...g.marks.map(k=>({mark:k,from:E,to:T})))})}),s===0)return!1;const l=o.filter(d=>a?a.name===d.mark.type.name:!0).filter(d=>To(d.mark.attrs,n,{strict:!1})).reduce((d,p)=>d+p.to-p.from,0),u=o.filter(d=>a?d.mark.type!==a&&d.mark.type.excludes(a):!0).reduce((d,p)=>d+p.to-p.from,0);return(l>0?l+u:l)>=s}function DB(t,e,n={}){if(!e)return Tr(t,null,n)||og(t,null,n);const r=xl(e,t.schema);return r==="node"?Tr(t,e,n):r==="mark"?og(t,e,n):!1}var MB=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=vl(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},PB=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function gy(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function by(t,e){const{nodeExtensions:n}=Oi(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Ne(le(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function _l(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(_l(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function QN(t){return t instanceof ue}var JN=class eI{constructor(e){this.position=e}static fromJSON(e){return new eI(e.position)}toJSON(){return{position:this.position}}};function FB(t,e){const n=e.mapping.mapResult(t.position);return{position:new JN(n.pos),mapResult:n}}function BB(t){return new JN(t)}function UB(t,e,n){var r;const{selection:i}=e;let a=null;if(UN(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:l})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(c,d,p)=>{if(u)return!1;if(c.isInline){const f=!p||p.type.allowsMarkType(n),h=!!n.isInSet(c.marks)||!c.marks.some(g=>g.type.excludes(n));u=f&&h}return!u}),u})}var HB=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,l=Vn(t,r.schema);if(i)if(s){const u=jN(r,l);n.addStoredMark(l.create({...u,...e}))}else o.forEach(u=>{const c=u.$from.pos,d=u.$to.pos;r.doc.nodesBetween(c,d,(p,f)=>{const h=Math.max(f,c),g=Math.min(f+p.nodeSize,d);p.marks.find(E=>E.type===l)?p.marks.forEach(E=>{l===E.type&&n.addMark(h,g,l.create({...E.attrs,...e}))}):n.addMark(h,g,l.create(e))})});return UB(r,n,l)},$B=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zB=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=tt(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>R0(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>R0(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},jB=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Dr(t,0,r.content.size),a=ue.create(r,i);e.setSelection(a)}return!0},qB=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(l,u)=>{l.isText||n.setNodeMarkup(u,void 0,{...l.attrs,dir:t})}),!0},GB=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=fe.atStart(r).from,o=fe.atEnd(r).to,l=Dr(i,s,o),u=Dr(a,s,o),c=fe.create(r,l,u);e.setSelection(c)}return!0},VB=t=>({state:e,dispatch:n})=>{const r=tt(t,e.schema);return U3(r)(e,n)};function Ey(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var WB=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:l}=a,u=i.extensionManager.attributes,c=Ys(u,o.node().type.name,o.node().attrs);if(a instanceof ue&&a.node.isBlock)return!o.parentOffset||!qn(s,o.pos)?!1:(r&&(t&&Ey(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,p=o.depth===0?void 0:SB(o.node(-1).contentMatchAt(o.indexAfter(-1)));let f=d&&p?[{type:p,attrs:c}]:void 0,h=qn(e.doc,e.mapping.map(o.pos),1,f);if(!f&&!h&&qn(e.doc,e.mapping.map(o.pos),1,p?[{type:p}]:void 0)&&(h=!0,f=p?[{type:p,attrs:c}]:void 0),r){if(h&&(a instanceof fe&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,f),p&&!d&&!o.parentOffset&&o.parent.type!==p)){const g=e.mapping.map(o.before()),b=e.doc.resolve(g);o.node(-1).canReplaceWith(b.index(),b.index()+1,p)&&e.setNodeMarkup(e.mapping.map(o.before()),p)}t&&Ey(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return h},YB=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const o=tt(t,r.schema),{$from:l,$to:u}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(u))return!1;const d=l.node(-1);if(d.type!==o)return!1;const p=a.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let E=K.empty;const T=l.index(-1)?1:l.index(-2)?2:3;for(let w=l.depth-T;w>=l.depth-3;w-=1)E=K.from(l.node(w).copy(E));const y=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,k={...Ys(p,l.node().type.name,l.node().attrs),...e},x=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(k))||void 0;E=E.append(K.from(o.createAndFill(null,x)||void 0));const A=l.before(l.depth-(T-1));n.replace(A,l.after(-y),new se(E,4-T,0));let v=-1;n.doc.nodesBetween(A,n.doc.content.size,(w,_)=>{if(v>-1)return!1;w.isTextblock&&w.content.size===0&&(v=_+1)}),v>-1&&n.setSelection(fe.near(n.doc.resolve(v))),n.scrollIntoView()}return!0}const f=u.pos===l.end()?d.contentMatchAt(0).defaultType:null,h={...Ys(p,d.type.name,d.attrs),...e},g={...Ys(p,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,u.pos);const b=f?[{type:o,attrs:h},{type:f,attrs:g}]:[{type:o,attrs:h}];if(!qn(n.doc,l.pos,2))return!1;if(i){const{selection:E,storedMarks:T}=r,{splittableMarks:y}=a.extensionManager,k=T||E.$to.parentOffset&&E.$from.marks();if(n.split(l.pos,2,b).scrollIntoView(),!k||!i)return!0;const x=k.filter(A=>y.includes(A.type.name));n.ensureMarks(x)}return!0},gu=(t,e)=>{const n=vl(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Sr(t.doc,n.pos)&&t.join(n.pos),!0},bu=(t,e)=>{const n=vl(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Sr(t.doc,r)&&t.join(r),!0},KB=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:l,commands:u,can:c})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,f=tt(t,s.schema),h=tt(e,s.schema),{selection:g,storedMarks:b}=s,{$from:E,$to:T}=g,y=E.blockRange(T),k=b||g.$to.parentOffset&&g.$from.marks();if(!y)return!1;const x=vl(A=>by(A.type.name,d))(g);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===f)return u.liftListItem(h);if(by(x.node.type.name,d)&&f.validContent(x.node.content)&&o)return l().command(()=>(a.setNodeMarkup(x.pos,f),!0)).command(()=>gu(a,f)).command(()=>bu(a,f)).run()}return!n||!k||!o?l().command(()=>c().wrapInList(f,r)?!0:u.clearNodes()).wrapInList(f,r).command(()=>gu(a,f)).command(()=>bu(a,f)).run():l().command(()=>{const A=c().wrapInList(f,r),v=k.filter(w=>p.includes(w.type.name));return a.ensureMarks(v),A?!0:u.clearNodes()}).wrapInList(f,r).command(()=>gu(a,f)).command(()=>bu(a,f)).run()},XB=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Vn(t,r.schema);return og(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},ZB=(t,e,n={})=>({state:r,commands:i})=>{const a=tt(t,r.schema),s=tt(e,r.schema),o=Tr(r,a,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(s,l):i.setNode(a,{...l,...n})},QB=(t,e={})=>({state:n,commands:r})=>{const i=tt(t,n.schema);return Tr(n,i,e)?r.lift(i):r.wrapIn(i,e)},JB=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const s=t.tr,o=a.transform;for(let l=o.steps.length-1;l>=0;l-=1)s.step(o.steps[l].invert(o.docs[l]));if(a.text){const l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1},e4=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},t4=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=Vn(t,r.schema),{$from:u,empty:c,ranges:d}=o;if(!i)return!0;if(c&&s){let{from:p,to:f}=o;const h=(a=u.marks().find(b=>b.type===l))==null?void 0:a.attrs,g=xb(u,l,h);g&&(p=g.from,f=g.to),n.removeMark(p,f,l)}else d.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},n4=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,l)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(l,void 0,u)}),!0},r4=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=xl(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=tt(t,r.schema)),o==="mark"&&(s=Vn(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{const c=u.$from.pos,d=u.$to.pos;let p,f,h,g;n.selection.empty?r.doc.nodesBetween(c,d,(b,E)=>{a&&a===b.type&&(l=!0,h=Math.max(E,c),g=Math.min(E+b.nodeSize,d),p=E,f=b)}):r.doc.nodesBetween(c,d,(b,E)=>{E<c&&a&&a===b.type&&(l=!0,h=Math.max(E,c),g=Math.min(E+b.nodeSize,d),p=E,f=b),E>=c&&E<=d&&(a&&a===b.type&&(l=!0,i&&n.setNodeMarkup(E,void 0,{...b.attrs,...e})),s&&b.marks.length&&b.marks.forEach(T=>{if(s===T.type&&(l=!0,i)){const y=Math.max(E,c),k=Math.min(E+b.nodeSize,d);n.addMark(y,k,s.create({...T.attrs,...e}))}}))}),f&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(b=>{s===b.type&&i&&n.addMark(h,g,s.create({...b.attrs,...e}))}))}),l},i4=(t,e={})=>({state:n,dispatch:r})=>{const i=tt(t,n.schema);return O3(i,e)(n,r)},a4=(t,e={})=>({state:n,dispatch:r})=>{const i=tt(t,n.schema);return L3(i,e)(n,r)},s4=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Cl=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},o4=(t,e)=>{if(kb(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Cs(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const u=l.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let c=!1;const d=LB(u)+a;return s.forEach(p=>{if(c)return;const f=o4(d,p.find);if(!f)return;const h=l.state.tr,g=Al({state:l.state,transaction:h}),b={from:r-(f[0].length-a.length),to:i},{commands:E,chain:T,can:y}=new kl({editor:n,state:g});p.handler({state:g,range:b,match:f,commands:E,chain:T,can:y})===null||!h.steps.length||(p.undoable&&h.setMeta(o,{transform:h,from:r,to:i,text:a}),l.dispatch(h),c=!0)}),c}function l4(t){const{editor:e,rules:n}=t,r=new $e({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:c}=l;typeof c=="string"?c=c:c=_b(K.from(c),s.schema);const{from:d}=l,p=d+c.length;Cs({editor:e,from:d,to:p,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,o){return Cs({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&Cs({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Cs({editor:e,from:s.pos,to:s.pos,text:`
34
+ `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(l,u,c,d)=>{var p;l.isBlock&&u>r&&(o+=a);const f=s?.[l.type.name];if(f)return c&&(o+=f({node:l,pos:u,parent:c,index:d,range:e})),!1;l.isText&&(o+=(p=l?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),o}function NB(t,e){const n={from:0,to:t.content.size};return YN(t,n,e)}function KN(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function IB(t,e){const n=tt(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function XN(t,e){const n=xl(typeof e=="string"?e:e.name,t.schema);return n==="node"?IB(t,e):n==="mark"?jN(t,e):{}}function wB(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function RB(t){const e=wB(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function ZN(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,l)=>{s.push({from:o,to:l})});else{const{from:o,to:l}=n[a];if(o===void 0||l===void 0)return;s.push({from:o,to:l})}s.forEach(({from:o,to:l})=>{const u=e.slice(a).map(o,-1),c=e.slice(a).map(l),d=e.invert().map(u,-1),p=e.invert().map(c);r.push({oldRange:{from:d,to:p},newRange:{from:u,to:c}})})}),RB(r)}function Cb(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=xb(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var OB=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function _s(t,e){return e.nodes[t]||e.marks[t]||null}function Ys(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var LB=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var l,u;const c=((u=(l=i.type.spec).toText)==null?void 0:u.call(l,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?c:c.slice(0,Math.max(0,r-a))}),n};function og(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Vn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>a?a.name===d.type.name:!0).find(d=>To(d.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:d,$to:p})=>{const f=d.pos,h=p.pos;t.doc.nodesBetween(f,h,(g,b)=>{if(!g.isText&&!g.marks.length)return;const E=Math.max(f,b),T=Math.min(h,b+g.nodeSize),y=T-E;s+=y,o.push(...g.marks.map(k=>({mark:k,from:E,to:T})))})}),s===0)return!1;const l=o.filter(d=>a?a.name===d.mark.type.name:!0).filter(d=>To(d.mark.attrs,n,{strict:!1})).reduce((d,p)=>d+p.to-p.from,0),u=o.filter(d=>a?d.mark.type!==a&&d.mark.type.excludes(a):!0).reduce((d,p)=>d+p.to-p.from,0);return(l>0?l+u:l)>=s}function DB(t,e,n={}){if(!e)return Tr(t,null,n)||og(t,null,n);const r=xl(e,t.schema);return r==="node"?Tr(t,e,n):r==="mark"?og(t,e,n):!1}var MB=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=vl(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},PB=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function gy(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function by(t,e){const{nodeExtensions:n}=Oi(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Ne(le(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function _l(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(_l(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function QN(t){return t instanceof ue}var JN=class eI{constructor(e){this.position=e}static fromJSON(e){return new eI(e.position)}toJSON(){return{position:this.position}}};function FB(t,e){const n=e.mapping.mapResult(t.position);return{position:new JN(n.pos),mapResult:n}}function BB(t){return new JN(t)}function UB(t,e,n){var r;const{selection:i}=e;let a=null;if(UN(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:l})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(c,d,p)=>{if(u)return!1;if(c.isInline){const f=!p||p.type.allowsMarkType(n),h=!!n.isInSet(c.marks)||!c.marks.some(g=>g.type.excludes(n));u=f&&h}return!u}),u})}var HB=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,l=Vn(t,r.schema);if(i)if(s){const u=jN(r,l);n.addStoredMark(l.create({...u,...e}))}else o.forEach(u=>{const c=u.$from.pos,d=u.$to.pos;r.doc.nodesBetween(c,d,(p,f)=>{const h=Math.max(f,c),g=Math.min(f+p.nodeSize,d);p.marks.find(E=>E.type===l)?p.marks.forEach(E=>{l===E.type&&n.addMark(h,g,l.create({...E.attrs,...e}))}):n.addMark(h,g,l.create(e))})});return UB(r,n,l)},$B=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zB=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=tt(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>R0(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>R0(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},jB=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Dr(t,0,r.content.size),a=ue.create(r,i);e.setSelection(a)}return!0},qB=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(l,u)=>{l.isText||n.setNodeMarkup(u,void 0,{...l.attrs,dir:t})}),!0},GB=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=fe.atStart(r).from,o=fe.atEnd(r).to,l=Dr(i,s,o),u=Dr(a,s,o),c=fe.create(r,l,u);e.setSelection(c)}return!0},VB=t=>({state:e,dispatch:n})=>{const r=tt(t,e.schema);return U3(r)(e,n)};function Ey(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var WB=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:l}=a,u=i.extensionManager.attributes,c=Ys(u,o.node().type.name,o.node().attrs);if(a instanceof ue&&a.node.isBlock)return!o.parentOffset||!qn(s,o.pos)?!1:(r&&(t&&Ey(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,p=o.depth===0?void 0:SB(o.node(-1).contentMatchAt(o.indexAfter(-1)));let f=d&&p?[{type:p,attrs:c}]:void 0,h=qn(e.doc,e.mapping.map(o.pos),1,f);if(!f&&!h&&qn(e.doc,e.mapping.map(o.pos),1,p?[{type:p}]:void 0)&&(h=!0,f=p?[{type:p,attrs:c}]:void 0),r){if(h&&(a instanceof fe&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,f),p&&!d&&!o.parentOffset&&o.parent.type!==p)){const g=e.mapping.map(o.before()),b=e.doc.resolve(g);o.node(-1).canReplaceWith(b.index(),b.index()+1,p)&&e.setNodeMarkup(e.mapping.map(o.before()),p)}t&&Ey(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return h},YB=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const o=tt(t,r.schema),{$from:l,$to:u}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(u))return!1;const d=l.node(-1);if(d.type!==o)return!1;const p=a.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let E=K.empty;const T=l.index(-1)?1:l.index(-2)?2:3;for(let w=l.depth-T;w>=l.depth-3;w-=1)E=K.from(l.node(w).copy(E));const y=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,k={...Ys(p,l.node().type.name,l.node().attrs),...e},x=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(k))||void 0;E=E.append(K.from(o.createAndFill(null,x)||void 0));const A=l.before(l.depth-(T-1));n.replace(A,l.after(-y),new se(E,4-T,0));let v=-1;n.doc.nodesBetween(A,n.doc.content.size,(w,_)=>{if(v>-1)return!1;w.isTextblock&&w.content.size===0&&(v=_+1)}),v>-1&&n.setSelection(fe.near(n.doc.resolve(v))),n.scrollIntoView()}return!0}const f=u.pos===l.end()?d.contentMatchAt(0).defaultType:null,h={...Ys(p,d.type.name,d.attrs),...e},g={...Ys(p,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,u.pos);const b=f?[{type:o,attrs:h},{type:f,attrs:g}]:[{type:o,attrs:h}];if(!qn(n.doc,l.pos,2))return!1;if(i){const{selection:E,storedMarks:T}=r,{splittableMarks:y}=a.extensionManager,k=T||E.$to.parentOffset&&E.$from.marks();if(n.split(l.pos,2,b).scrollIntoView(),!k||!i)return!0;const x=k.filter(A=>y.includes(A.type.name));n.ensureMarks(x)}return!0},gu=(t,e)=>{const n=vl(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Sr(t.doc,n.pos)&&t.join(n.pos),!0},bu=(t,e)=>{const n=vl(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Sr(t.doc,r)&&t.join(r),!0},KB=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:l,commands:u,can:c})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,f=tt(t,s.schema),h=tt(e,s.schema),{selection:g,storedMarks:b}=s,{$from:E,$to:T}=g,y=E.blockRange(T),k=b||g.$to.parentOffset&&g.$from.marks();if(!y)return!1;const x=vl(A=>by(A.type.name,d))(g);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===f)return u.liftListItem(h);if(by(x.node.type.name,d)&&f.validContent(x.node.content)&&o)return l().command(()=>(a.setNodeMarkup(x.pos,f),!0)).command(()=>gu(a,f)).command(()=>bu(a,f)).run()}return!n||!k||!o?l().command(()=>c().wrapInList(f,r)?!0:u.clearNodes()).wrapInList(f,r).command(()=>gu(a,f)).command(()=>bu(a,f)).run():l().command(()=>{const A=c().wrapInList(f,r),v=k.filter(w=>p.includes(w.type.name));return a.ensureMarks(v),A?!0:u.clearNodes()}).wrapInList(f,r).command(()=>gu(a,f)).command(()=>bu(a,f)).run()},XB=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Vn(t,r.schema);return og(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},ZB=(t,e,n={})=>({state:r,commands:i})=>{const a=tt(t,r.schema),s=tt(e,r.schema),o=Tr(r,a,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(s,l):i.setNode(a,{...l,...n})},QB=(t,e={})=>({state:n,commands:r})=>{const i=tt(t,n.schema);return Tr(n,i,e)?r.lift(i):r.wrapIn(i,e)},JB=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const s=t.tr,o=a.transform;for(let l=o.steps.length-1;l>=0;l-=1)s.step(o.steps[l].invert(o.docs[l]));if(a.text){const l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1},e4=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},t4=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=Vn(t,r.schema),{$from:u,empty:c,ranges:d}=o;if(!i)return!0;if(c&&s){let{from:p,to:f}=o;const h=(a=u.marks().find(b=>b.type===l))==null?void 0:a.attrs,g=xb(u,l,h);g&&(p=g.from,f=g.to),n.removeMark(p,f,l)}else d.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},n4=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,l)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(l,void 0,u)}),!0},r4=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=xl(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=tt(t,r.schema)),o==="mark"&&(s=Vn(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{const c=u.$from.pos,d=u.$to.pos;let p,f,h,g;n.selection.empty?r.doc.nodesBetween(c,d,(b,E)=>{a&&a===b.type&&(l=!0,h=Math.max(E,c),g=Math.min(E+b.nodeSize,d),p=E,f=b)}):r.doc.nodesBetween(c,d,(b,E)=>{E<c&&a&&a===b.type&&(l=!0,h=Math.max(E,c),g=Math.min(E+b.nodeSize,d),p=E,f=b),E>=c&&E<=d&&(a&&a===b.type&&(l=!0,i&&n.setNodeMarkup(E,void 0,{...b.attrs,...e})),s&&b.marks.length&&b.marks.forEach(T=>{if(s===T.type&&(l=!0,i)){const y=Math.max(E,c),k=Math.min(E+b.nodeSize,d);n.addMark(y,k,s.create({...T.attrs,...e}))}}))}),f&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(b=>{s===b.type&&i&&n.addMark(h,g,s.create({...b.attrs,...e}))}))}),l},i4=(t,e={})=>({state:n,dispatch:r})=>{const i=tt(t,n.schema);return O3(i,e)(n,r)},a4=(t,e={})=>({state:n,dispatch:r})=>{const i=tt(t,n.schema);return L3(i,e)(n,r)},s4=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Cl=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},o4=(t,e)=>{if(kb(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Cs(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const u=l.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let c=!1;const d=LB(u)+a;return s.forEach(p=>{if(c)return;const f=o4(d,p.find);if(!f)return;const h=l.state.tr,g=Al({state:l.state,transaction:h}),b={from:r-(f[0].length-a.length),to:i},{commands:E,chain:T,can:y}=new kl({editor:n,state:g});p.handler({state:g,range:b,match:f,commands:E,chain:T,can:y})===null||!h.steps.length||(p.undoable&&h.setMeta(o,{transform:h,from:r,to:i,text:a}),l.dispatch(h),c=!0)}),c}function l4(t){const{editor:e,rules:n}=t,r=new $e({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:c}=l;typeof c=="string"?c=c:c=_b(K.from(c),s.schema);const{from:d}=l,p=d+c.length;Cs({editor:e,from:d,to:p,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,o){return Cs({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&Cs({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Cs({editor:e,from:s.pos,to:s.pos,text:`
35
35
  `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function u4(t){return Object.prototype.toString.call(t).slice(8,-1)}function Ns(t){return u4(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function tI(t,e){const n={...t};return Ns(t)&&Ns(e)&&Object.keys(e).forEach(r=>{Ns(e[r])&&Ns(t[r])?n[r]=tI(t[r],e[r]):n[r]=e[r]}),n}var Nb=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Ne(le(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ne(le(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>tI(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},ri=class nI extends Nb{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new nI(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(u=>u?.type.name===n.name))return!1;const l=s.find(u=>u?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function c4(t){return typeof t=="number"}var d4=class{constructor(t){this.find=t.find,this.handler=t.handler}},p4=(t,e,n)=>{if(kb(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function f4(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:l,chain:u,can:c}=new kl({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(f,h)=>{var g,b,E,T,y;if((b=(g=f.type)==null?void 0:g.spec)!=null&&b.code||!(f.isText||f.isTextblock||f.isInline))return;const k=(y=(T=(E=f.content)==null?void 0:E.size)!=null?T:f.nodeSize)!=null?y:0,x=Math.max(r,h),A=Math.min(i,h+k);if(x>=A)return;const v=f.isText?f.text||"":f.textBetween(x-h,A-h,void 0,"");p4(v,a.find,s).forEach(_=>{if(_.index===void 0)return;const C=x+_.index+1,D=C+_[0].length,M={from:n.tr.mapping.map(C),to:n.tr.mapping.map(D)},j=a.handler({state:n,range:M,match:_,commands:l,chain:u,can:c,pasteEvent:s,dropEvent:o});d.push(j)})}),d.every(f=>f!==null)}var Is=null,h4=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function m4(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:c,from:d,to:p,rule:f,pasteEvt:h})=>{const g=c.tr,b=Al({state:c,transaction:g});if(!(!f4({editor:e,state:b,from:Math.max(d-1,0),to:p.b-1,rule:f,pasteEvent:h,dropEvent:o})||!g.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(c=>new $e({view(d){const p=h=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(h.target)?d.dom.parentElement:null,r&&(Is=e)},f=()=>{Is&&(Is=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,p)=>{if(a=r===d.dom.parentElement,o=p,!a){const f=Is;f?.isEditable&&setTimeout(()=>{const h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(d,p)=>{var f;const h=(f=p.clipboardData)==null?void 0:f.getData("text/html");return s=p,i=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(d,p,f)=>{const h=d[0],g=h.getMeta("uiEvent")==="paste"&&!i,b=h.getMeta("uiEvent")==="drop"&&!a,E=h.getMeta("applyPasteRules"),T=!!E;if(!g&&!b&&!T)return;if(T){let{text:x}=E;typeof x=="string"?x=x:x=_b(K.from(x),f.schema);const{from:A}=E,v=A+x.length,w=h4(x);return l({rule:c,state:f,from:A,to:{b:v},pasteEvt:w})}const y=p.doc.content.findDiffStart(f.doc.content),k=p.doc.content.findDiffEnd(f.doc.content);if(!(!c4(y)||!k||y===k.b))return l({rule:c,state:f,from:y,to:k,pasteEvt:s})}}))}var Nl=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=WN(t),this.schema=_B(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:_s(e.name,this.schema)},r=le(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return So([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:_s(r.name,this.schema)},a=[],s=le(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&le(r,"exitable",i)&&(o.ArrowRight=()=>ri.handleExit({editor:t,mark:r})),s){const p=Object.fromEntries(Object.entries(s()).map(([f,h])=>[f,()=>h({editor:t})]));o={...o,...p}}const l=IF(o);a.push(l);const u=le(r,"addInputRules",i);if(gy(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const f=l4({editor:t,rules:p}),h=Array.isArray(f)?f:[f];a.push(...h)}}const c=le(r,"addPasteRules",i);if(gy(r,t.options.enablePasteRules)&&c){const p=c();if(p&&p.length){const f=m4({editor:t,rules:p});a.push(...f)}}const d=le(r,"addProseMirrorPlugins",i);if(d){const p=d();a.push(...p)}return a})}get attributes(){return VN(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Oi(this.extensions);return Object.fromEntries(e.filter(n=>!!le(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:tt(n.name,this.schema)},a=le(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const o=(l,u,c,d,p)=>{const f=Li(l,r);return s({node:l,view:u,getPos:c,decorations:d,innerDecorations:p,editor:t,extension:n,HTMLAttributes:f})};return[n.name,o]}))}dispatchTransaction(t){const{editor:e}=this;return So([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:_s(i.name,this.schema)},s=le(i,"dispatchTransaction",a);return s?o=>{s.call(a,{transaction:o,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Oi(this.extensions);return Object.fromEntries(e.filter(n=>!!le(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Vn(n.name,this.schema)},a=le(n,"addMarkView",i);if(!a)return[];const s=(o,l,u)=>{const c=Li(o,r);return a()({mark:o,view:l,inline:u,editor:t,extension:n,HTMLAttributes:c,updateAttributes:d=>{w4(o,t,d)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:_s(e.name,this.schema)};e.type==="mark"&&((n=Ne(le(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=le(e,"onBeforeCreate",r),a=le(e,"onCreate",r),s=le(e,"onUpdate",r),o=le(e,"onSelectionUpdate",r),l=le(e,"onTransaction",r),u=le(e,"onFocus",r),c=le(e,"onBlur",r),d=le(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),u&&this.editor.on("focus",u),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)})}};Nl.resolve=WN;Nl.sort=So;Nl.flatten=vb;var g4={};Ab(g4,{ClipboardTextSerializer:()=>iI,Commands:()=>aI,Delete:()=>sI,Drop:()=>oI,Editable:()=>lI,FocusEvents:()=>cI,Keymap:()=>dI,Paste:()=>pI,Tabindex:()=>fI,TextDirection:()=>hI,focusEventsPluginKey:()=>uI});var Ze=class rI extends Nb{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new rI(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},iI=Ze.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new $e({key:new Ge("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,s=Math.min(...a.map(c=>c.$from.pos)),o=Math.max(...a.map(c=>c.$to.pos)),l=KN(n);return YN(r,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),aI=Ze.create({name:"commands",addCommands(){return{...FN}}}),sI=Ze.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,o,l,u;if((u=(l=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const c=qN(t.before,[t,...e]);ZN(c).forEach(f=>{c.mapping.mapResult(f.oldRange.from).deletedAfter&&c.mapping.mapResult(f.oldRange.to).deletedBefore&&c.before.nodesBetween(f.oldRange.from,f.oldRange.to,(h,g)=>{const b=g+h.nodeSize-2,E=f.oldRange.from<=g&&b<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:h,from:g,to:b,newFrom:c.mapping.map(g),newTo:c.mapping.map(b),deletedRange:f.oldRange,newRange:f.newRange,partial:!E,editor:this.editor,transaction:t,combinedTransform:c})})});const p=c.mapping;c.steps.forEach((f,h)=>{var g,b;if(f instanceof hn){const E=p.slice(h).map(f.from,-1),T=p.slice(h).map(f.to),y=p.invert().map(E,-1),k=p.invert().map(T),x=(g=c.doc.nodeAt(E-1))==null?void 0:g.marks.some(v=>v.eq(f.mark)),A=(b=c.doc.nodeAt(T))==null?void 0:b.marks.some(v=>v.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:y,to:k},newRange:{from:E,to:T},partial:!!(A||x),editor:this.editor,transaction:t,combinedTransform:c})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),oI=Ze.create({name:"drop",addProseMirrorPlugins(){return[new $e({key:new Ge("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),lI=Ze.create({name:"editable",addProseMirrorPlugins(){return[new $e({key:new Ge("editable"),props:{editable:()=>this.editor.options.editable}})]}}),uI=new Ge("focusEvents"),cI=Ze.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new $e({key:uI,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),dI=Ze.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:l,doc:u}=o,{empty:c,$anchor:d}=l,{pos:p,parent:f}=d,h=d.parent.isTextblock&&p>0?o.doc.resolve(p-1):d,g=h.parent.type.spec.isolating,b=d.pos-d.parentOffset,E=g&&h.parent.childCount===1?b===d.pos:ye.atStart(u).from===p;return!c||!f.type.isTextblock||f.textContent.length||!E||E&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return qa()||zN()?a:i},addProseMirrorPlugins(){return[new $e({key:new Ge("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),i=t.some(g=>g.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:o}=e.selection,l=ye.atStart(e.doc).from,u=ye.atEnd(e.doc).to;if(a||!(s===l&&o===u)||!_l(n.doc))return;const p=n.tr,f=Al({state:n,transaction:p}),{commands:h}=new kl({editor:this.editor,state:f});if(h.clearNodes(),!!p.steps.length)return p}})]}}),pI=Ze.create({name:"paste",addProseMirrorPlugins(){return[new $e({key:new Ge("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),fI=Ze.create({name:"tabindex",addProseMirrorPlugins(){return[new $e({key:new Ge("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),hI=Ze.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Oi(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new $e({key:new Ge("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),b4=class da{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new da(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new da(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new da(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,s=n.isInline,o=this.pos+r+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&!s&&l.depth<=this.depth)return;const u=new da(l,this.editor,i,i||s?n:null);i&&(u.actualDepth=this.depth+1),e.push(u)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const l=s[o];if(a[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&a.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},E4=`.ProseMirror {
36
36
  position: relative;
37
37
  }