most-box 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -14
- package/electron/main.js +72 -8
- package/electron/preload.js +6 -0
- package/out/404/index.html +2 -2
- package/out/404.html +2 -2
- package/out/__next.__PAGE__.txt +6 -6
- package/out/__next._full.txt +16 -16
- package/out/__next._head.txt +3 -3
- package/out/__next._index.txt +8 -8
- package/out/__next._tree.txt +5 -5
- package/out/_next/static/chunks/0.e2avjgna_b2.js +1 -0
- package/out/_next/static/chunks/{0ho~log~~-jwp.css → 03h~nhgj0hv3p.css} +1 -1
- package/out/_next/static/chunks/07td.jq7xff84.css +1 -0
- package/out/_next/static/chunks/{0qou.u2e2dy48.css → 0adx~d-j05c9d.css} +2 -2
- package/out/_next/static/chunks/0aq.rc9woa2nz.js +1 -0
- package/out/_next/static/chunks/0etes81d_cihn.js +1 -0
- package/out/_next/static/chunks/0g_a~e050bgzg.css +1 -0
- package/out/_next/static/chunks/{0o6lrkxy4jwag.js → 0gcsdf57gcm6h.js} +1 -1
- package/out/_next/static/chunks/0gwian.hp3-92.js +1 -0
- package/out/_next/static/chunks/0hpev4am9jpmu.css +1 -0
- package/out/_next/static/chunks/0l5_.uqb-uqb8.js +1 -0
- package/out/_next/static/chunks/0mex8svsiv-2l.js +1 -0
- package/out/_next/static/chunks/0myq9gs8szydh.js +1 -0
- package/out/_next/static/chunks/{0usvo~vu7r8np.js → 0o9ce4cyf76by.js} +1 -1
- package/out/_next/static/chunks/0p0sv~fuddvgr.js +1 -0
- package/out/_next/static/chunks/{0o98f1yq..o.8.js → 0pt.5cg1t09qs.js} +1 -1
- package/out/_next/static/chunks/0q0ksgxg98xgd.js +1 -0
- package/out/_next/static/chunks/0qgx9t4jx16ua.css +1 -0
- package/out/_next/static/chunks/0ukyg~tkm~h2m.css +1 -0
- package/out/_next/static/chunks/0wtf0xsiicxx6.js +1 -0
- package/out/_next/static/chunks/0xdwau5k2augv.css +4 -0
- package/out/_next/static/chunks/12nr19.nnn6s3.js +5 -0
- package/out/_next/static/chunks/{0qub_r0x_r-e9.css → 12pep-2t-qg4n.css} +1 -1
- package/out/_next/static/chunks/14_inksek_rth.js +2 -0
- package/out/_next/static/chunks/153-sz7s.qml2.js +1 -0
- package/out/_next/static/chunks/16xls5tt_68lx.js +1 -0
- package/out/_next/static/chunks/{turbopack-0xs6mybc~5t_3.js → turbopack-0xta0kqwzkf28.js} +1 -1
- package/out/_not-found/__next._full.txt +13 -13
- package/out/_not-found/__next._head.txt +3 -3
- package/out/_not-found/__next._index.txt +8 -8
- package/out/_not-found/__next._not-found.__PAGE__.txt +4 -4
- package/out/_not-found/__next._not-found.txt +3 -3
- package/out/_not-found/__next._tree.txt +3 -3
- package/out/_not-found/index.html +2 -2
- package/out/_not-found/index.txt +13 -13
- package/out/admin/__next._full.txt +15 -15
- package/out/admin/__next._head.txt +3 -3
- package/out/admin/__next._index.txt +8 -8
- package/out/admin/__next._tree.txt +4 -4
- package/out/admin/__next.admin.__PAGE__.txt +4 -4
- package/out/admin/__next.admin.txt +4 -4
- package/out/admin/index.html +2 -2
- package/out/admin/index.txt +15 -15
- package/out/app/__next._full.txt +14 -14
- package/out/app/__next._head.txt +3 -3
- package/out/app/__next._index.txt +8 -8
- package/out/app/__next._tree.txt +3 -3
- package/out/app/__next.app.__PAGE__.txt +4 -4
- package/out/app/__next.app.txt +3 -3
- package/out/app/index.html +2 -2
- package/out/app/index.txt +14 -14
- package/out/chat/__next._full.txt +15 -15
- package/out/chat/__next._head.txt +3 -3
- package/out/chat/__next._index.txt +8 -8
- package/out/chat/__next._tree.txt +4 -4
- package/out/chat/__next.chat.__PAGE__.txt +4 -4
- package/out/chat/__next.chat.txt +4 -4
- package/out/chat/index.html +2 -2
- package/out/chat/index.txt +15 -15
- package/out/chat/join/__next._full.txt +25 -0
- package/out/chat/join/__next._head.txt +5 -0
- package/out/{changelog → chat/join}/__next._index.txt +8 -8
- package/out/chat/join/__next._tree.txt +5 -0
- package/out/chat/join/__next.chat.join.__PAGE__.txt +9 -0
- package/out/chat/join/__next.chat.join.txt +5 -0
- package/out/chat/join/__next.chat.txt +5 -0
- package/out/chat/join/index.html +15 -0
- package/out/chat/join/index.txt +25 -0
- package/out/download/__next._full.txt +21 -21
- package/out/download/__next._head.txt +3 -3
- package/out/download/__next._index.txt +8 -8
- package/out/download/__next._tree.txt +5 -5
- package/out/download/__next.download.__PAGE__.txt +9 -9
- package/out/download/__next.download.txt +3 -3
- package/out/download/index.html +2 -2
- package/out/download/index.txt +21 -21
- package/out/index.html +2 -2
- package/out/index.txt +16 -16
- package/out/note/__next._full.txt +14 -14
- package/out/note/__next._head.txt +3 -3
- package/out/note/__next._index.txt +8 -8
- package/out/note/__next._tree.txt +3 -3
- package/out/note/__next.note.__PAGE__.txt +4 -4
- package/out/note/__next.note.txt +3 -3
- package/out/note/index.html +2 -2
- package/out/note/index.txt +14 -14
- package/out/ping/__next._full.txt +16 -16
- package/out/ping/__next._head.txt +3 -3
- package/out/ping/__next._index.txt +8 -8
- package/out/ping/__next._tree.txt +5 -5
- package/out/ping/__next.ping.__PAGE__.txt +5 -5
- package/out/ping/__next.ping.txt +4 -4
- package/out/ping/index.html +2 -2
- package/out/ping/index.txt +16 -16
- package/out/web3/__next._full.txt +15 -15
- package/out/web3/__next._head.txt +3 -3
- package/out/web3/__next._index.txt +8 -8
- package/out/web3/__next._tree.txt +4 -4
- package/out/web3/__next.web3.__PAGE__.txt +4 -4
- package/out/web3/__next.web3.txt +4 -4
- package/out/web3/ed25519/__next._full.txt +13 -13
- package/out/web3/ed25519/__next._head.txt +3 -3
- package/out/web3/ed25519/__next._index.txt +8 -8
- package/out/web3/ed25519/__next._tree.txt +4 -4
- package/out/web3/ed25519/__next.web3.ed25519.__PAGE__.txt +2 -2
- package/out/web3/ed25519/__next.web3.ed25519.txt +3 -3
- package/out/web3/ed25519/__next.web3.txt +4 -4
- package/out/web3/ed25519/index.html +1 -1
- package/out/web3/ed25519/index.txt +13 -13
- package/out/web3/index.html +2 -2
- package/out/web3/index.txt +15 -15
- package/out/web3/tools/__next._full.txt +13 -13
- package/out/web3/tools/__next._head.txt +3 -3
- package/out/web3/tools/__next._index.txt +8 -8
- package/out/web3/tools/__next._tree.txt +4 -4
- package/out/web3/tools/__next.web3.tools.__PAGE__.txt +2 -2
- package/out/web3/tools/__next.web3.tools.txt +3 -3
- package/out/web3/tools/__next.web3.txt +4 -4
- package/out/web3/tools/index.html +1 -1
- package/out/web3/tools/index.txt +13 -13
- package/package.json +19 -9
- package/server/index.js +133 -1303
- package/server/src/config.js +1 -1
- package/server/src/core/channelAttachment.js +68 -0
- package/server/src/core/cid.js +2 -88
- package/server/src/core/cidTopic.js +29 -0
- package/server/src/core/mostLink.js +88 -0
- package/server/src/http/access.js +123 -0
- package/server/src/http/app.js +1095 -0
- package/server/src/http/errors.js +35 -0
- package/server/src/http/nodeLogs.js +53 -0
- package/server/src/http/nodeStatus.js +146 -0
- package/server/src/http/staticFiles.js +84 -0
- package/server/src/http/uploads.js +114 -0
- package/server/src/index.js +799 -211
- package/server/src/node/config.js +38 -6
- package/server/src/utils/api.js +287 -14
- package/server/src/utils/auth.js +63 -0
- package/server/src/utils/dateTime.js +30 -0
- package/server/src/utils/downloadMessages.js +89 -0
- package/server/src/utils/errors.js +7 -0
- package/server/src/utils/mostWallet.js +151 -0
- package/server/src/utils/mp.js +2 -26
- package/server/src/utils/noteBackup.js +2 -5
- package/server/src/utils/noteUtils.js +11 -3
- package/server/src/utils/userIdentity.js +0 -1
- package/out/_next/static/chunks/00-u5nq76f0.j.js +0 -1
- package/out/_next/static/chunks/00fm8lijienf1.js +0 -1
- package/out/_next/static/chunks/00o9ht.f2qm00.css +0 -4
- package/out/_next/static/chunks/00zi-erhjrny2.js +0 -2
- package/out/_next/static/chunks/084xf0edl9sfo.js +0 -1
- package/out/_next/static/chunks/09f1gfke9m5wg.css +0 -1
- package/out/_next/static/chunks/09xyi6fpro_d-.css +0 -1
- package/out/_next/static/chunks/0_npg_pcoywti.js +0 -5
- package/out/_next/static/chunks/0_r_mk1~6bosc.js +0 -1
- package/out/_next/static/chunks/0arm0a6adt7cc.css +0 -1
- package/out/_next/static/chunks/0c9j3eq_14vv2.css +0 -1
- package/out/_next/static/chunks/0d4bueddmcnca.js +0 -1
- package/out/_next/static/chunks/0gtwvy1z9ksa7.css +0 -1
- package/out/_next/static/chunks/0j27tcmtt4ly7.js +0 -1
- package/out/_next/static/chunks/0j3v4mq67wtnh.js +0 -1
- package/out/_next/static/chunks/0lkmf5ry.s_7w.js +0 -1
- package/out/_next/static/chunks/0p486m03-zfoi.js +0 -1
- package/out/_next/static/chunks/0r1~k82nji8sf.js +0 -1
- package/out/_next/static/chunks/0v7qp4hv-_._r.js +0 -1
- package/out/_next/static/chunks/0wuwlgcn6gxqt.js +0 -1
- package/out/_next/static/chunks/0xl5_avhu._i8.js +0 -1
- package/out/_next/static/chunks/10kvl8vj_plm-.js +0 -1
- package/out/_next/static/chunks/16m27azcs4k6w.js +0 -1
- package/out/changelog/__next._full.txt +0 -25
- package/out/changelog/__next._head.txt +0 -5
- package/out/changelog/__next._tree.txt +0 -5
- package/out/changelog/__next.changelog.__PAGE__.txt +0 -10
- package/out/changelog/__next.changelog.txt +0 -5
- package/out/changelog/index.html +0 -15
- package/out/changelog/index.txt +0 -25
- package/out/docs/__next._full.txt +0 -25
- package/out/docs/__next._head.txt +0 -5
- package/out/docs/__next._index.txt +0 -9
- package/out/docs/__next._tree.txt +0 -5
- package/out/docs/__next.docs.__PAGE__.txt +0 -10
- package/out/docs/__next.docs.txt +0 -5
- package/out/docs/getting-started/__next._full.txt +0 -25
- package/out/docs/getting-started/__next._head.txt +0 -5
- package/out/docs/getting-started/__next._index.txt +0 -9
- package/out/docs/getting-started/__next._tree.txt +0 -5
- package/out/docs/getting-started/__next.docs.getting-started.__PAGE__.txt +0 -10
- package/out/docs/getting-started/__next.docs.getting-started.txt +0 -5
- package/out/docs/getting-started/__next.docs.txt +0 -5
- package/out/docs/getting-started/index.html +0 -15
- package/out/docs/getting-started/index.txt +0 -25
- package/out/docs/index.html +0 -15
- package/out/docs/index.txt +0 -25
- package/out/note/edit/__next._full.txt +0 -24
- package/out/note/edit/__next._head.txt +0 -5
- package/out/note/edit/__next._index.txt +0 -9
- package/out/note/edit/__next._tree.txt +0 -4
- package/out/note/edit/__next.note.edit.__PAGE__.txt +0 -9
- package/out/note/edit/__next.note.edit.txt +0 -5
- package/out/note/edit/__next.note.txt +0 -5
- package/out/note/edit/index.html +0 -15
- package/out/note/edit/index.txt +0 -24
- /package/out/_next/static/{sIuUKxnnGU7K9Tu9UDKE8 → t7ZIeQpVvjz4a7-5Tt-VK}/_buildManifest.js +0 -0
- /package/out/_next/static/{sIuUKxnnGU7K9Tu9UDKE8 → t7ZIeQpVvjz4a7-5Tt-VK}/_clientMiddlewareManifest.js +0 -0
- /package/out/_next/static/{sIuUKxnnGU7K9Tu9UDKE8 → t7ZIeQpVvjz4a7-5Tt-VK}/_ssgManifest.js +0 -0
|
@@ -733,4 +733,4 @@
|
|
|
733
733
|
d="m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z"
|
|
734
734
|
/>
|
|
735
735
|
</svg>
|
|
736
|
-
`,zu={[Rk.CodeMirror]:{theme:n6,languages:nK,expandIcon:R_,searchIcon:R9,clearSearchIcon:RP,searchPlaceholder:"Search language",noResultText:"No result",previewToggleIcon:e=>e?R$:zc}},zh=ru([],"FeaturesCtx"),zd=ru({},"CrepeCtx");function zp(e){return e.use("FeaturesCtx")}function zf(e){return t=>{zp(t).update(t=>t.includes(e)?t:[...t,e])}}let zm=dw({provider:void 0,buildContext:void 0,diffReviewOnEnd:!0,onError:e=>{console.error(`[milkdown/ai] [${e.code}]`,e)},aiIcon:void 0},"aiProviderConfig"),zg=dw({abortController:null,label:"",lastInstruction:"",lastLabel:void 0,lastFrom:-1,lastTo:-1,diffOwnedByAI:!1},"aiSession");function zv(e,t){let n=e.get(zm.key);try{n.onError(t)}catch(e){console.error("[milkdown/ai] onError handler failed:",e)}}function zy(e){let t=e.get(zg.key);e.set(zg.key,{...t,abortController:null,label:""})}async function zb(e,t,n,r){try{let i=t(n,r.signal),o=e.get(hP);for await(let e of i){if(r.signal.aborted)break;o.call(pC.key,e)}if(r.signal.aborted)return;let l=e.get(zm.key);if(l.diffReviewOnEnd){let t=e.get(zg.key);e.set(zg.key,{...t,diffOwnedByAI:!0})}let s=o.call(pS.key,{diffReview:l.diffReviewOnEnd});if(l.diffReviewOnEnd&&!s){let t=e.get(zg.key);e.set(zg.key,{...t,diffOwnedByAI:!1})}}catch(n){let t;if(r.signal.aborted)return;zv(e,(t=n instanceof Error?n.message:rl(n),new n9(n8.aiProviderError,`AI provider error: ${t}`,{cause:n}))),e.get(hP).call(pM.key,{keep:!1})}finally{e.get(zg.key).abortController===r&&zy(e)}}let zw=df("RunAI",e=>t=>(n,r)=>{var i,o,l,s;let a;if(!(null==t?void 0:t.instruction))return!1;let c=e.get(zm.key);if(!c.provider||e.get(zg.key).abortController||(null==(i=pw.getState(n))?void 0:i.active)||(null==(o=d$.getState(n))?void 0:o.active))return!1;if(!r)return!0;let u=new AbortController,{from:h,to:d}=n.selection;e.set(zg.key,{abortController:u,label:null!=(l=t.label)?l:"",lastInstruction:t.instruction,lastLabel:t.label,lastFrom:h,lastTo:d,diffOwnedByAI:!1});let p=e.get(hP),f=n.selection.empty?"cursor":"selection";if(!p.call(pk.key,{insertAt:f}))return zy(e),!1;try{a=(null!=(s=c.buildContext)?s:function(e,t){var n;let r=e.get(hg),i=e.get(h0),{state:o}=r,l=i(o.doc),s="";if(!o.selection.empty){let{from:e,to:t}=o.selection,r=o.doc.slice(e,t),{schema:l}=o.doc.type,a=l.topNodeType.createAndFill(null,r.content);if(!a){let e=null==(n=l.nodes.paragraph)?void 0:n.createAndFill(null,r.content);e&&(a=l.topNodeType.createAndFill(null,e))}s=a?i(a):o.doc.textBetween(e,t)}return{document:l,selection:s,instruction:t}})(e,t.instruction)}catch(n){let t;return zv(e,(t=n instanceof Error?n.message:rl(n),new n9(n8.aiBuildContextError,`AI buildContext failed: ${t}`,{cause:n}))),p.call(pM.key,{keep:!1}),zy(e),!1}return zb(e,c.provider,a,u),!0}),zx=df("AbortAI",e=>t=>(n,r)=>{var i;let o=e.get(zg.key);return r?!!o.abortController&&(o.abortController.abort(),zy(e),(null==(i=pw.getState(n))?void 0:i.active)&&e.get(hP).call(pM.key,t),!0):!!o.abortController});var zk=e=>{throw TypeError(e)},zC=(e,t,n)=>t.has(e)||zk("Cannot "+n),zS=(e,t,n)=>(zC(e,t,"read from private field"),n?n.call(e):t.get(e)),zM=(e,t,n)=>t.has(e)?zk("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zA=(e,t,n,r)=>(zC(e,t,"write to private field"),t.set(e,n),n),zT=(e,t,n)=>(zC(e,t,"access private method"),n);let zO="milkdown-ai-diff-actions";function zE(e,t){e.innerHTML=fk.sanitize(t.trim())}class zN{constructor(e,t,n){this.ctx=e,zM(this,ey),zM(this,eu),zM(this,eh),zM(this,ed),zM(this,ep),zM(this,ef,!1),zM(this,em,!1),zM(this,eg,null),zM(this,ev,!1),zM(this,ek,()=>{let e=this.ctx.get(zg.key);if(!e.lastInstruction||!zS(this,ev)||!zT(this,ey,eC).call(this))return;let t=this.ctx.get(hP);t.call(d0.key);let n=this.ctx.get(hg),{doc:r}=n.state,i=Math.min(Math.max(e.lastFrom,0),r.content.size),o=Math.min(Math.max(e.lastTo,0),r.content.size);n.dispatch(n.state.tr.setSelection(sv.create(n.state.doc,i,o))),t.call(zw.key,{instruction:e.lastInstruction,label:e.lastLabel})}),zM(this,eS,()=>{this.ctx.get(hP).call(d0.key)}),zM(this,eM,()=>{this.ctx.get(hP).call(dQ.key)}),zA(this,ep,n),zA(this,eh,zT(this,ey,eb).call(this,t));const r=document.createElement("div");r.className=zO,r.dataset.show="false",zA(this,ed,zT(this,ey,ew).call(this,"retry",n.retryIcon,n.retryLabel,zS(this,ek))),r.appendChild(zS(this,ed)),r.appendChild(zT(this,ey,ew).call(this,"reject",n.rejectIcon,n.rejectAllLabel,zS(this,eS)));const i=zT(this,ey,ew).call(this,"accept",n.acceptIcon,n.acceptAllLabel,zS(this,eM));i.appendChild(zT(this,ey,ex).call(this)),r.appendChild(i),zA(this,eu,r),zS(this,eh).appendChild(r),this.update(t)}update(e){var t;let n=!!(null==(t=d$.getState(e.state))?void 0:t.active);if(n!==zS(this,em))if(zA(this,em,n),n){let t=this.ctx.get(zg.key);zA(this,ev,t.diffOwnedByAI),zA(this,eg,e.state.doc)}else{zA(this,ev,!1),zA(this,eg,null);let e=this.ctx.get(zg.key);e.diffOwnedByAI&&this.ctx.set(zg.key,{...e,diffOwnedByAI:!1})}let r=n&&zS(this,ev);if(r!==zS(this,ef)&&(zA(this,ef,r),zS(this,eu).dataset.show=r?"true":"false"),r){let t=this.ctx.get(zg.key),n=!!zS(this,eg)&&e.state.doc.eq(zS(this,eg));zS(this,ed).disabled=!t.lastInstruction||!n}}destroy(){zS(this,eu).remove()}}eu=new WeakMap,eh=new WeakMap,ed=new WeakMap,ep=new WeakMap,ef=new WeakMap,em=new WeakMap,eg=new WeakMap,ev=new WeakMap,ey=new WeakSet,eb=function(e){var t;return null!=(t=e.dom.closest(".milkdown"))?t:document.body},ew=function(e,t,n,r){let i,o=document.createElement("button");o.type="button",o.className=`${zO}-btn ${zO}-btn-${e}`,o.appendChild(((i=document.createElement("span")).className=`${zO}-icon`,zE(i,t),i));let l=document.createElement("span");return l.textContent=n,o.appendChild(l),o.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),r()}),o},ex=function(){let e=document.createElement("span");e.className=`${zO}-shortcut`;let t=document.createElement("span");t.textContent=zS(this,ep).modSymbol;let n=document.createElement("span");return n.className=`${zO}-shortcut-icon`,zE(n,zS(this,ep).enterKeyIcon),e.append(t,n),e},ek=new WeakMap,eC=function(){return!!zS(this,eg)&&this.ctx.get(hg).state.doc.eq(zS(this,eg))},eS=new WeakMap,eM=new WeakMap;let zD=new s_("CREPE_AI_DIFF_ACTIONS_PANEL"),zI=function(){var e,t,n,r;if("u"<typeof navigator)return"⌘";let i=navigator,o=null!=(r=null!=(n=null!=(t=null==(e=i.userAgentData)?void 0:e.platform)?t:i.platform)?n:i.userAgent)?r:"";return/mac|iphone|ipad|ipod/i.test(o)?"⌘":"Ctrl"}();var zL=e=>{throw TypeError(e)},z_=(e,t,n)=>t.has(e)||zL("Cannot "+n),zR=(e,t,n)=>(z_(e,t,"read from private field"),n?n.call(e):t.get(e)),zz=(e,t,n)=>t.has(e)?zL("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zP=(e,t,n,r)=>(z_(e,t,"write to private field"),t.set(e,n),n);function zB(e){let t={addItem:(n,r)=>(e.items.set(n,r),t),removeItem:n=>(e.items.delete(n),t),getItem:t=>e.items.get(t),clear:()=>(e.items.clear(),t)};return t}class zF{constructor(){zz(this,eA,[]),this.addItem=(e,t)=>(zR(this,eT).call(this,e),zR(this,eA).push({kind:"item",id:e,item:t}),this),this.addSubmenu=(e,t,n)=>{zR(this,eT).call(this,e);let r={def:t,items:new Map};return n&&n(zB(r)),zR(this,eA).push({kind:"submenu",id:e,node:r}),this},this.removeItem=e=>(zR(this,eT).call(this,e),this),this.getItem=e=>{let t=zR(this,eA).find(t=>"item"===t.kind&&t.id===e);return(null==t?void 0:t.kind)==="item"?t.item:void 0},this.getSubmenu=e=>{let t=zR(this,eA).find(t=>"submenu"===t.kind&&t.id===e);return(null==t?void 0:t.kind)==="submenu"?zB(t.node):void 0},this.clear=()=>(zP(this,eA,[]),this),this.build=()=>{let e=[],t={};for(let n of zR(this,eA))"item"===n.kind?e.push({kind:"item",id:n.id,item:n.item}):(e.push({kind:"submenu",id:n.id,def:n.node.def}),t[n.id]={def:n.node.def,items:Array.from(n.node.items.entries()).map(([e,t])=>({id:e,item:t}))});return{main:e,submenus:t}},zz(this,eT,e=>{zP(this,eA,zR(this,eA).filter(t=>t.id!==e))})}}function zH(){}eA=new WeakMap,eT=new WeakMap,zH(bR);let zq=ye({props:{placeholder:{type:Object,required:!0},resetSignal:{type:Object,required:!0},suggestions:{type:Object,required:!0},chrome:{type:Object,required:!0},onConfirm:{type:Function,required:!0},onCancel:{type:Function,required:!0}},setup({placeholder:e,resetSignal:t,suggestions:n,chrome:r,onConfirm:i,onCancel:o}){let l=vd(""),s=vd({kind:"main"}),a=vd(0),c=vd(null),u=vd(null),h=`ai-instruction-list-${Math.random().toString(36).slice(2,9)}`,d=e=>`${h}-opt-${e}`;v0(t,()=>{l.value="",s.value={kind:"main"},a.value=0},void 0);let p=b_(()=>{if("submenu"===s.value.kind){let e=n.submenus[s.value.id];return e?e.items.map(({id:e,item:t})=>({id:e,icon:t.icon,label:t.label,hasSubmenu:!1,prompt:{text:t.prompt,streamingLabel:t.streamingLabel}})):[]}return n.main.map(e=>"item"===e.kind?{id:e.id,icon:e.item.icon,label:e.item.label,hasSubmenu:!1,prompt:{text:e.item.prompt,streamingLabel:e.item.streamingLabel}}:{id:e.id,icon:e.def.icon,label:e.def.label,hasSubmenu:!0})}),f=b_(()=>{var e,t;return"submenu"!==s.value.kind?null:null!=(t=null==(e=n.submenus[s.value.id])?void 0:e.def)?t:null}),m=b_(()=>{let e=l.value.trim().toLowerCase();return e?p.value.filter(t=>t.label.toLowerCase().includes(e)):p.value}),g=b_(()=>l.value.trim().length>0),y=b_(()=>m.value.length+ +!!g.value);v0([m,s,g],()=>{a.value=g.value?m.value.length:0},void 0);let b=()=>{v_(()=>{var e;return null==(e=c.value)?void 0:e.focus()})},w=()=>{s.value={kind:"main"},l.value="",a.value=0,b()},x=e=>{e.hasSubmenu?(s.value={kind:"submenu",id:e.id},l.value="",a.value=0,b()):e.prompt&&(i(e.prompt.text,e.prompt.streamingLabel),l.value="")},k=()=>{let e=l.value.trim();e&&(i(e),l.value="")},C=()=>{v_(()=>{let e=u.value;if(!e)return;let t=e.querySelector(`[data-index="${a.value}"]`);null==t||t.scrollIntoView({block:"nearest"})})},S=e=>{if(e.stopPropagation(),"ArrowDown"===e.key){if(e.preventDefault(),0===y.value)return;a.value=(a.value+1)%y.value,C();return}if("ArrowUp"===e.key){if(e.preventDefault(),0===y.value)return;a.value=(a.value-1+y.value)%y.value,C();return}if("Enter"===e.key){let t,n;e.preventDefault(),t=a.value,t<(n=m.value).length?x(n[t]):g.value&&k();return}if("Escape"===e.key){e.preventDefault(),"submenu"===s.value.kind?w():o();return}"Backspace"===e.key&&""===l.value&&"submenu"===s.value.kind&&(e.preventDefault(),w())},M=e=>{e.preventDefault()};return()=>{let t=m.value,n=g.value,i=f.value;return bR("div",{class:"ai-instruction"},bR("div",{class:"ai-instruction-input"},bR("span",{class:"ai-instruction-input-prefix"},bR(b6,{icon:r.aiIcon})),bR("input",{ref:c,class:"ai-instruction-input-field",role:"combobox","aria-expanded":"true","aria-autocomplete":"list","aria-controls":h,"aria-activedescendant":y.value>0?d(a.value):void 0,placeholder:i?i.searchPlaceholder:e.value,value:l.value,onInput:e=>{l.value=e.target.value},onKeydown:S}),bR("button",{type:"button",class:"ai-instruction-submit","aria-label":r.submitButtonLabel,disabled:!n,onMousedown:M,onClick:k},bR(b6,{icon:r.sendIcon}))),bR("div",{class:"ai-instruction-list",ref:u,id:h,role:"listbox","aria-label":r.listboxLabel},i&&bR("button",{type:"button",class:"ai-instruction-back",onMousedown:M,onClick:w},bR("span",{class:"ai-instruction-back-icon","aria-hidden":"true"},bR(b6,{icon:r.chevronLeftIcon})),bR("span",null,i.title)),t.length>0&&bR("div",{class:"ai-instruction-section"},bR("div",{class:"ai-instruction-section-header"},r.suggestionsHeaderLabel),t.map((e,t)=>bR("div",{key:e.id,id:d(t),"data-index":t,role:"option","aria-selected":t===a.value,class:["ai-instruction-item",t===a.value?"active":""],onMousedown:M,onClick:()=>x(e),onPointerenter:()=>{a.value=t}},bR("span",{class:"ai-instruction-item-icon"},bR(b6,{icon:e.icon})),bR("span",{class:"ai-instruction-item-label"},function(e,t){let n=t.trim();if(!n)return[e];let r=e.toLowerCase(),i=n.toLowerCase(),o=r.indexOf(i);return -1===o?[e]:[e.slice(0,o),bR("mark",null,e.slice(o,o+n.length)),e.slice(o+n.length)]}(e.label,l.value)),e.hasSubmenu&&bR("span",{class:"ai-instruction-item-arrow"},bR(b6,{icon:r.chevronRightIcon}))))),n&&bR("div",{class:"ai-instruction-section"},bR("div",{class:"ai-instruction-section-header"},r.sendAsPromptHeaderLabel),bR("div",{id:d(t.length),"data-index":t.length,role:"option","aria-selected":a.value===t.length,class:["ai-instruction-item","ai-instruction-item-prompt",a.value===t.length?"active":""],onMousedown:M,onClick:k,onPointerenter:()=>{a.value=t.length}},bR("span",{class:"ai-instruction-item-icon"},bR(b6,{icon:r.sendPromptIcon})),bR("span",{class:"ai-instruction-item-label"},r.sendAsPromptLabel," ",bR("span",{class:"ai-instruction-item-quote"},'"',l.value,'"')),bR("span",{class:"ai-instruction-item-shortcut"},bR(b6,{icon:r.enterKeyIcon}))))))}}});var zj=e=>{throw TypeError(e)},zV=(e,t,n)=>t.has(e)||zj("Cannot "+n),z$=(e,t,n)=>(zV(e,t,"read from private field"),n?n.call(e):t.get(e)),zW=(e,t,n)=>t.has(e)?zj("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zU=(e,t,n,r)=>(zV(e,t,"write to private field"),t.set(e,n),n);class zG{constructor(e,t,n){this.ctx=e,zW(this,eO),zW(this,eE),zW(this,eN),zW(this,eD),zW(this,eI),zW(this,eL,-1),zW(this,e_,-1),zW(this,eR,!1),zW(this,ez,(e,t)=>{!e.trim()||this.ctx.get(hP).call(zw.key,{instruction:e,label:t})&&(zU(this,eR,!1),z$(this,eE).hide())}),zW(this,eP,()=>{zU(this,eR,!1),z$(this,eE).hide()}),this.show=(e,t)=>{zU(this,eL,e),zU(this,e_,t),z$(this,eI).value++,zU(this,eR,!0);let n=this.ctx.get(hg);z$(this,eE).show({getBoundingClientRect:()=>aE(n,e,t)},n),requestAnimationFrame(()=>{var e;null==(e=z$(this,eO).querySelector("input"))||e.focus()})},this.update=(e,t)=>{let{selection:n}=e.state,r=n instanceof sv,i=n.from!==z$(this,eL)||n.to!==z$(this,e_);if(!r||i){zU(this,eR,!1),z$(this,eE).hide();return}z$(this,eE).update(e,t)},this.destroy=()=>{z$(this,eN).unmount(),z$(this,eE).destroy(),z$(this,eO).remove()},zU(this,eD,vd(n.placeholder)),zU(this,eI,vd(0));const r=document.createElement("div");r.className="milkdown-ai-instruction";const i=b3(zq,{placeholder:z$(this,eD),resetSignal:z$(this,eI),suggestions:n.suggestions,chrome:n.chrome,onConfirm:z$(this,ez),onCancel:z$(this,eP)});i.mount(r),zU(this,eN,i),zU(this,eO,r),zU(this,eE,new mP({content:r,debounce:0,offset:10,shouldShow:()=>z$(this,eR),floatingUIOptions:{placement:"bottom"}})),z$(this,eE).onHide=()=>{zU(this,eR,!1),requestAnimationFrame(()=>{try{let e=z$(this,eO).getRootNode().activeElement;if(!e||!z$(this,eO).contains(e))return;this.ctx.get(hg).dom.focus({preventScroll:!0})}catch(e){}})},z$(this,eE).update(t)}}eO=new WeakMap,eE=new WeakMap,eN=new WeakMap,eD=new WeakMap,eI=new WeakMap,eL=new WeakMap,e_=new WeakMap,eR=new WeakMap,ez=new WeakMap,eP=new WeakMap;let zK=dw({show:()=>{}},"aiInstructionTooltipAPI"),zJ=mB("CREPE_AI_INSTRUCTION");var zZ=e=>{throw TypeError(e)},zY=(e,t,n)=>t.has(e)||zZ("Cannot "+n),zX=(e,t,n)=>(zY(e,t,"read from private field"),n?n.call(e):t.get(e)),zQ=(e,t,n)=>t.has(e)?zZ("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z0=(e,t,n,r)=>(zY(e,t,"write to private field"),t.set(e,n),n);let z1="milkdown-ai-streaming",z4=new s_("CREPE_AI_STREAMING_INDICATOR");class z5{constructor(e,t,n){zQ(this,eB),zQ(this,eF),zQ(this,eH),zQ(this,eq,performance.now()),zQ(this,ej,""),zQ(this,eV,0),zQ(this,e$,()=>{let e=performance.now()-zX(this,eq);zX(this,eB).style.transform=`rotate(${e/800*360}deg)`,z0(this,eV,requestAnimationFrame(zX(this,e$)))}),z0(this,eH,t);const r=document.createElement("span");r.className=`${z1}-indicator`,r.contentEditable="false",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const i=document.createElement("span");i.className=`${z1}-spinner`,i.setAttribute("aria-hidden","true"),r.appendChild(i);const o=document.createElement("span");o.className=`${z1}-label`,r.appendChild(o);const l=document.createElement("span");l.className=`${z1}-esc`,l.textContent=n,r.appendChild(l),this.dom=r,z0(this,eB,i),z0(this,eF,o),this.setLabel(e),zX(this,e$).call(this)}setLabel(e){let t=e.get(zg.key),n=`${t.label||zX(this,eH)}\u2026`;n!==zX(this,ej)&&(z0(this,ej,n),zX(this,eF).textContent=n)}destroy(){zX(this,eV)&&cancelAnimationFrame(zX(this,eV)),z0(this,eV,0)}}eB=new WeakMap,eF=new WeakMap,eH=new WeakMap,eq=new WeakMap,ej=new WeakMap,eV=new WeakMap,e$=new WeakMap;let z2=["table","image-block","code_block"],z3={heading:["id"]};function z7(e){return"code_block"===e.$from.parent.type.name}function z6(e){var t;let n=null==(t=e.$from.node(e.$from.depth-1))?void 0:t.type;return(null==n?void 0:n.name)==="list_item"}var z8=e=>{throw TypeError(e)},z9=(e,t,n)=>t.has(e)||z8("Cannot "+n),Pe=(e,t,n)=>(z9(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?z8("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);class Pn{constructor(){Pt(this,eW,[]),this.clear=()=>{let e,t;return t=[],z9(this,e=eW,"write to private field"),e.set(this,t),this},Pt(this,eU,e=>{let t={group:e,addItem:(n,r)=>{let i={...r,key:n};return e.items.push(i),t},clear:()=>(e.items=[],t)};return t}),this.addGroup=(e,t)=>{let n={key:e,label:t,items:[]};return Pe(this,eW).push(n),Pe(this,eU).call(this,n)},this.getGroup=e=>{let t=Pe(this,eW).find(t=>t.key===e);if(!t)throw Error(`Group with key ${e} not found`);return Pe(this,eU).call(this,t)},this.build=()=>Pe(this,eW)}}eW=new WeakMap,eU=new WeakMap,zH(bR);let Pr=ye({props:{ctx:{type:Object,required:!0},show:{type:Object,required:!0},filter:{type:Object,required:!0},hide:{type:Function,required:!0},config:{type:Object,required:!1}},setup({ctx:e,show:t,filter:n,hide:r,config:i}){let o=vd(),l=b_(()=>(function(e,t,n){var r,i,o,l,s,a,c,u,h,d,p,f,m,g,y,b,w,x,k,C,S,M,A,T,O,E,N,D,I,L,_,R,z,P,B,F,H,q,j,V,$,W,U,G,K,J,Z,Y,X,Q,ee,et,en,er,ei,eo,el,es,ea,ec,eu,eh,ed,ep,ef,em,eg,ev,ey,eb,ew,ex,ek,eC,eS,eM,eA,eT,eO,eE,eN,eD,eI,eL,e_,eR,ez,eP,eB,eF,eH,eq,ej,eV,e$,eW,eU,eG,eK,eJ,eZ,eY,eX,eQ,e0,e1,e4,e5,e2,e3,e7,e6,e8,e9,te,tt,tn,tr,ti;let to=n&&zp(n).get(),tl=null==to?void 0:to.includes(Rk.Latex),ts=null==to?void 0:to.includes(Rk.ImageBlock),ta=null==to?void 0:to.includes(Rk.Table),tc=new Pn;if((null==t?void 0:t.textGroup)!==null){let e=tc.addGroup("text",null!=(i=null==(r=null==t?void 0:t.textGroup)?void 0:r.label)?i:"Text");(null==(o=null==t?void 0:t.textGroup)?void 0:o.text)!==null&&e.addItem("text",{label:null!=(a=null==(s=null==(l=null==t?void 0:t.textGroup)?void 0:l.text)?void 0:s.label)?a:"Text",icon:null!=(h=null==(u=null==(c=null==t?void 0:t.textGroup)?void 0:c.text)?void 0:u.icon)?h:zo,onRun:e=>{let t=e.get(hP),n=wz.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n})}}),(null==(d=null==t?void 0:t.textGroup)?void 0:d.h1)!==null&&e.addItem("h1",{label:null!=(m=null==(f=null==(p=null==t?void 0:t.textGroup)?void 0:p.h1)?void 0:f.label)?m:"Heading 1",icon:null!=(b=null==(y=null==(g=null==t?void 0:t.textGroup)?void 0:g.h1)?void 0:y.icon)?b:RG,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:1}})}}),(null==(w=null==t?void 0:t.textGroup)?void 0:w.h2)!==null&&e.addItem("h2",{label:null!=(C=null==(k=null==(x=null==t?void 0:t.textGroup)?void 0:x.h2)?void 0:k.label)?C:"Heading 2",icon:null!=(A=null==(M=null==(S=null==t?void 0:t.textGroup)?void 0:S.h2)?void 0:M.icon)?A:RK,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:2}})}}),(null==(T=null==t?void 0:t.textGroup)?void 0:T.h3)!==null&&e.addItem("h3",{label:null!=(N=null==(E=null==(O=null==t?void 0:t.textGroup)?void 0:O.h3)?void 0:E.label)?N:"Heading 3",icon:null!=(L=null==(I=null==(D=null==t?void 0:t.textGroup)?void 0:D.h3)?void 0:I.icon)?L:RJ,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:3}})}}),(null==(_=null==t?void 0:t.textGroup)?void 0:_.h4)!==null&&e.addItem("h4",{label:null!=(P=null==(z=null==(R=null==t?void 0:t.textGroup)?void 0:R.h4)?void 0:z.label)?P:"Heading 4",icon:null!=(H=null==(F=null==(B=null==t?void 0:t.textGroup)?void 0:B.h4)?void 0:F.icon)?H:RZ,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:4}})}}),(null==(q=null==t?void 0:t.textGroup)?void 0:q.h5)!==null&&e.addItem("h5",{label:null!=($=null==(V=null==(j=null==t?void 0:t.textGroup)?void 0:j.h5)?void 0:V.label)?$:"Heading 5",icon:null!=(G=null==(U=null==(W=null==t?void 0:t.textGroup)?void 0:W.h5)?void 0:U.icon)?G:RY,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:5}})}}),(null==(K=null==t?void 0:t.textGroup)?void 0:K.h6)!==null&&e.addItem("h6",{label:null!=(Y=null==(Z=null==(J=null==t?void 0:t.textGroup)?void 0:J.h6)?void 0:Z.label)?Y:"Heading 6",icon:null!=(ee=null==(Q=null==(X=null==t?void 0:t.textGroup)?void 0:X.h6)?void 0:Q.icon)?ee:RX,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:6}})}}),(null==(et=null==t?void 0:t.textGroup)?void 0:et.quote)!==null&&e.addItem("quote",{label:null!=(ei=null==(er=null==(en=null==t?void 0:t.textGroup)?void 0:en.quote)?void 0:er.label)?ei:"Quote",icon:null!=(es=null==(el=null==(eo=null==t?void 0:t.textGroup)?void 0:eo.quote)?void 0:el.icon)?es:R7,onRun:e=>{let t=e.get(hP),n=wK.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n})}}),(null==(ea=null==t?void 0:t.textGroup)?void 0:ea.divider)!==null&&e.addItem("divider",{label:null!=(eh=null==(eu=null==(ec=null==t?void 0:t.textGroup)?void 0:ec.divider)?void 0:eu.label)?eh:"Divider",icon:null!=(ef=null==(ep=null==(ed=null==t?void 0:t.textGroup)?void 0:ed.divider)?void 0:ep.icon)?ef:Rj,onRun:e=>{let t=e.get(hP),n=xn.type(e);t.call(xN.key),t.call(xL.key,{nodeType:n})}})}if((null==t?void 0:t.listGroup)!==null){let e=tc.addGroup("list",null!=(eg=null==(em=null==t?void 0:t.listGroup)?void 0:em.label)?eg:"List");(null==(ev=null==t?void 0:t.listGroup)?void 0:ev.bulletList)!==null&&e.addItem("bullet-list",{label:null!=(ew=null==(eb=null==(ey=null==t?void 0:t.listGroup)?void 0:ey.bulletList)?void 0:eb.label)?ew:"Bullet List",icon:null!=(eC=null==(ek=null==(ex=null==t?void 0:t.listGroup)?void 0:ex.bulletList)?void 0:ek.icon)?eC:RN,onRun:e=>{let t=e.get(hP),n=xl.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n})}}),(null==(eS=null==t?void 0:t.listGroup)?void 0:eS.orderedList)!==null&&e.addItem("ordered-list",{label:null!=(eT=null==(eA=null==(eM=null==t?void 0:t.listGroup)?void 0:eM.orderedList)?void 0:eA.label)?eT:"Ordered List",icon:null!=(eN=null==(eE=null==(eO=null==t?void 0:t.listGroup)?void 0:eO.orderedList)?void 0:eE.icon)?eN:R2,onRun:e=>{let t=e.get(hP),n=xh.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n})}}),(null==(eD=null==t?void 0:t.listGroup)?void 0:eD.taskList)!==null&&e.addItem("task-list",{label:null!=(e_=null==(eL=null==(eI=null==t?void 0:t.listGroup)?void 0:eI.taskList)?void 0:eL.label)?e_:"Task List",icon:null!=(eP=null==(ez=null==(eR=null==t?void 0:t.listGroup)?void 0:eR.taskList)?void 0:ez.icon)?eP:zl,onRun:e=>{let t=e.get(hP),n=xg.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n,attrs:{checked:!1}})}})}if((null==t?void 0:t.advancedGroup)!==null){let e=tc.addGroup("advanced",null!=(eF=null==(eB=null==t?void 0:t.advancedGroup)?void 0:eB.label)?eF:"Advanced");(null==(eH=null==t?void 0:t.advancedGroup)?void 0:eH.image)!==null&&ts&&e.addItem("image",{label:null!=(eV=null==(ej=null==(eq=null==t?void 0:t.advancedGroup)?void 0:eq.image)?void 0:ej.label)?eV:"Image",icon:null!=(eU=null==(eW=null==(e$=null==t?void 0:t.advancedGroup)?void 0:e$.image)?void 0:eW.icon)?eU:RQ,onRun:e=>{let t=e.get(hP),n=ki.type(e);t.call(xN.key),t.call(xL.key,{nodeType:n})}}),(null==(eG=null==t?void 0:t.advancedGroup)?void 0:eG.codeBlock)!==null&&e.addItem("code",{label:null!=(eZ=null==(eJ=null==(eK=null==t?void 0:t.advancedGroup)?void 0:eK.codeBlock)?void 0:eJ.label)?eZ:"Code",icon:null!=(eQ=null==(eX=null==(eY=null==t?void 0:t.advancedGroup)?void 0:eY.codeBlock)?void 0:eX.icon)?eQ:RB,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n})}}),(null==(e0=null==t?void 0:t.advancedGroup)?void 0:e0.table)!==null&&ta&&e.addItem("table",{label:null!=(e5=null==(e4=null==(e1=null==t?void 0:t.advancedGroup)?void 0:e1.table)?void 0:e4.label)?e5:"Table",icon:null!=(e7=null==(e3=null==(e2=null==t?void 0:t.advancedGroup)?void 0:e2.table)?void 0:e3.icon)?e7:zi,onRun:e=>{let t=e.get(hP),n=e.get(hg);t.call(xN.key);let{from:r}=n.state.selection;t.call(xL.key,{nodeType:SH(e,3,3)}),t.call(x_.key,{pos:r})}}),(null==(e6=null==t?void 0:t.advancedGroup)?void 0:e6.math)!==null&&tl&&e.addItem("math",{label:null!=(te=null==(e9=null==(e8=null==t?void 0:t.advancedGroup)?void 0:e8.math)?void 0:e9.label)?te:"Math",icon:null!=(tr=null==(tn=null==(tt=null==t?void 0:t.advancedGroup)?void 0:tt.math)?void 0:tn.icon)?tr:za,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xN.key),t.call(xL.key,{nodeType:n,attrs:{language:"LaTeX"}})}})}null==(ti=null==t?void 0:t.buildMenu)||ti.call(t,tc);let tu=tc.build();e&&(tu=tu.map(t=>{let n=t.items.filter(t=>t.label.toLowerCase().includes(e.toLowerCase()));return{...t,items:n}}).filter(e=>e.items.length>0));let th=tu.flatMap(e=>e.items);return th.forEach((e,t)=>{Object.assign(e,{index:t})}),tu.reduce((e,t)=>{let n=e+t.items.length;return Object.assign(t,{range:[e,n]}),n},0),{groups:tu,size:th.length}})(n.value,i,e)),s=vd(0),a=vd({x:-999,y:-999}),c=e=>{let{x:t,y:n}=e;a.value={x:t,y:n}};v0([l,t],()=>{let{size:e}=l.value;0===e&&t.value?r():s.value>=e&&(s.value=0)},void 0);let u=(e,t)=>{let n=s.value,r="function"==typeof e?e(n):e;null==t||t(r),s.value=r},h=e=>{var t,n;let r=null==(t=o.value)?void 0:t.querySelector(`[data-index="${e}"]`),i=null==(n=o.value)?void 0:n.querySelector(".menu-groups");r&&i&&(i.scrollTop=r.offsetTop-i.offsetTop)},d=t=>{let n=l.value.groups.flatMap(e=>e.items).at(t);(null==n?void 0:n.onRun)&&e&&n.onRun(e),r()},p=e=>{let{size:t,groups:n}=l.value;if("Escape"===e.key){e.preventDefault(),null==r||r();return}return"ArrowDown"===e.key?(e.preventDefault(),u(e=>e<t-1?e+1:e,h)):"ArrowUp"===e.key?(e.preventDefault(),u(e=>e<=0?e:e-1,h)):"ArrowLeft"===e.key?(e.preventDefault(),u(e=>{let t=n.find(t=>t.range[0]<=e&&t.range[1]>e);if(!t)return e;let r=n[n.indexOf(t)-1];return r?r.range[1]-1:e},h)):"ArrowRight"===e.key?(e.preventDefault(),u(e=>{let t=n.find(t=>t.range[0]<=e&&t.range[1]>e);if(!t)return e;let r=n[n.indexOf(t)+1];return r?r.range[0]:e},h)):void("Enter"===e.key&&(e.preventDefault(),d(s.value)))};return vQ(()=>{t.value?window.addEventListener("keydown",p,{capture:!0}):window.removeEventListener("keydown",p,{capture:!0})}),yy(()=>{window.removeEventListener("keydown",p,{capture:!0})}),()=>bR("div",{ref:o,onPointerdown:e=>e.preventDefault()},bR("nav",{class:"tab-group"},bR("ul",null,l.value.groups.map(e=>bR("li",{key:e.key,onPointerdown:()=>u(e.range[0],h),class:s.value>=e.range[0]&&s.value<e.range[1]?"selected":""},e.label)))),bR("div",{class:"menu-groups",onPointermove:c},l.value.groups.map(e=>bR("div",{key:e.key,class:"menu-group"},bR("h6",null,e.label),bR("ul",null,e.items.map(e=>{let t;return bR("li",{key:e.key,"data-index":e.index,class:s.value===e.index?"hover":"",onPointerenter:(t=e.index,e=>{let n=a.value;if(!n)return;let{x:r,y:i}=e;(r!==n.x||i!==n.y)&&u(t)}),onPointerdown:()=>{var t,n;null==(n=null==(t=o.value)?void 0:t.querySelector(`[data-index="${e.index}"]`))||n.classList.add("active")},onPointerup:()=>{var t,n;null==(n=null==(t=o.value)?void 0:t.querySelector(`[data-index="${e.index}"]`))||n.classList.remove("active"),d(e.index)}},bR(b6,{icon:e.icon}),bR("span",null,e.label))}))))))}});var Pi=e=>{throw TypeError(e)},Po=(e,t,n)=>t.has(e)||Pi("Cannot "+n),Pl=(e,t,n)=>(Po(e,t,"read from private field"),n?n.call(e):t.get(e)),Ps=(e,t,n)=>t.has(e)?Pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pa=(e,t,n,r)=>(Po(e,t,"write to private field"),t.set(e,n),n);let Pc=(P="CREPE_MENU",w=dw({},`${P}_SLASH_SPEC`),x=dv(e=>{let t=e.get(w.key);return new sD({key:new s_(`${P}_SLASH`),...t})}),(k=[w,x]).key=w.key,k.pluginKey=x.key,w.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${P}`},x.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${P}`},k),Pu=dw({show:()=>{},hide:()=>{}},"menuAPICtx");class Ph{constructor(e,t,n){Ps(this,eG),Ps(this,eK),Ps(this,eJ),Ps(this,eZ),Ps(this,eY,null),this.update=e=>{Pl(this,eZ).update(e)},this.show=e=>{Pa(this,eY,e),Pl(this,eJ).value="",Pl(this,eZ).show()},this.hide=()=>{Pa(this,eY,null),Pl(this,eZ).hide()},this.destroy=()=>{Pl(this,eZ).destroy(),Pl(this,eK).unmount(),Pl(this,eG).remove()};const r=document.createElement("div");r.classList.add("milkdown-slash-menu");const i=vd(!1),o=vd("");Pa(this,eJ,o);const l=b3(Pr,{ctx:e,config:n,show:i,filter:o,hide:this.hide});Pa(this,eK,l),l.mount(r),Pa(this,eG,r);const s=this;Pa(this,eZ,new xZ({content:Pl(this,eG),debounce:20,shouldShow(e){if(z7(e.state.selection)||z6(e.state.selection))return!1;let t=this.getContent(e,e=>["paragraph","heading"].includes(e.type.name));if(null==t||!function(e){if(!(e instanceof sv))return!1;let{$head:t}=e,n=t.parent;return t.parentOffset===n.content.size}(e.state.selection))return!1;let n=Pl(s,eY);if(o.value=t.startsWith("/")?t.slice(1):t,"number"==typeof n){let t=Math.min(n,e.state.doc.nodeSize-2);return e.state.doc.resolve(t).node()===e.state.doc.resolve(e.state.selection.from).node()||(Pa(s,eY,null),!1)}return!!t.startsWith("/")},offset:10})),Pl(this,eZ).onShow=()=>{i.value=!0},Pl(this,eZ).onHide=()=>{i.value=!1},this.update(t),e.set(Pu.key,{show:e=>this.show(e),hide:()=>this.hide()})}}eG=new WeakMap,eK=new WeakMap,eJ=new WeakMap,eZ=new WeakMap,eY=new WeakMap,zH(bR,bn);let Pd=ye({props:{onAdd:{type:Function,required:!0},addIcon:{type:String,required:!0},handleIcon:{type:String,required:!0}},setup(e){let t=vd();return()=>bR(bn,null,bR("div",{ref:t,class:"operation-item",onPointerdown:e=>{var n;e.preventDefault(),e.stopPropagation(),null==(n=t.value)||n.classList.add("active")},onPointerup:n=>{var r;n.preventDefault(),n.stopPropagation(),null==(r=t.value)||r.classList.remove("active"),e.onAdd()}},bR(b6,{icon:e.addIcon})),bR("div",{class:"operation-item"},bR(b6,{icon:e.handleIcon})))}});var Pp=e=>{throw TypeError(e)},Pf=(e,t,n)=>t.has(e)||Pp("Cannot "+n),Pm=(e,t,n)=>(Pf(e,t,"read from private field"),n?n.call(e):t.get(e)),Pg=(e,t,n)=>t.has(e)?Pp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pv=(e,t,n,r)=>(Pf(e,t,"write to private field"),t.set(e,n),n);class Py{constructor(e,t){var n,r,i;Pg(this,eX),Pg(this,eQ),Pg(this,e0),Pg(this,e1),this.update=()=>{Pm(this,eQ).update()},this.destroy=()=>{Pm(this,eQ).destroy(),Pm(this,eX).remove(),Pm(this,e0).unmount()},this.onAdd=()=>{let e=Pm(this,e1),t=e.get(hg);t.hasFocus()||t.focus();let{state:n,dispatch:r}=t,i=Pm(this,eQ).active;if(!i)return;let o=i.$pos.pos+i.node.nodeSize,l=n.tr.insert(o,wz.type(e).create());r((l=l.setSelection(sv.near(l.doc.resolve(o)))).scrollIntoView()),Pm(this,eQ).hide(),e.get(Pu.key).show(l.selection.from)},Pv(this,e1,e);const o=document.createElement("div");o.classList.add("milkdown-block-handle");const l=b3(Pd,{onAdd:this.onAdd,addIcon:null!=(n=null==t?void 0:t.handleAddIcon)?n:R3,handleIcon:null!=(r=null==t?void 0:t.handleDragIcon)?r:R5});l.mount(o),Pv(this,e0,l),Pv(this,eX,o);const s=null!=(i=null==t?void 0:t.blockHandle)?i:{};Pv(this,eQ,new wl({ctx:e,content:o,getOffset:()=>16,getPlacement:({active:e,blockDom:t})=>{if("heading"===e.node.type.name)return"left";let n=0;e.node.descendants(e=>{n+=e.childCount});let r=e.el,i=r.getBoundingClientRect(),o=t.getBoundingClientRect(),l=window.getComputedStyle(r),s=Number.parseInt(l.paddingTop,10)||0,a=Number.parseInt(l.paddingBottom,10)||0,c=i.height-s-a,u=o.height;return n>2||u<c?"left-start":"left"},...s})),this.update()}}eX=new WeakMap,eQ=new WeakMap,e0=new WeakMap,e1=new WeakMap;let Pb=wQ.extendSchema(e=>t=>{let n=e(t);return{...n,toMarkdown:{match:n.toMarkdown.match,runner:(e,t)=>{var r,i;if("latex"!==(null!=(r=t.attrs.language)?r:"").toLowerCase())return n.toMarkdown.runner(e,t);e.addNode("math",void 0,(null==(i=t.content.firstChild)?void 0:i.text)||"")}}}}),Pw="math_inline",Px=dx(Pw,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${Pw}"]`,getAttrs:e=>{var t;return{value:null!=(t=e.dataset.value)?t:""}}}],toDOM:e=>{let t=e.attrs.value,n=document.createElement("span");return n.dataset.type=Pw,n.dataset.value=t,LT(t,n,{throwOnError:!1}),n},parseMarkdown:{match:e=>"inlineMath"===e.type,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===Pw,runner:(e,t)=>{e.addNode("inlineMath",void 0,t.attrs.value)}}})),Pk=df("ToggleLatex",e=>()=>(t,n)=>{let{hasNode:r,pos:i,target:o}=aL(t,Px.type(e)),{selection:l,doc:s,tr:a}=t;if(!r){let t=s.textBetween(l.from,l.to),r=a.replaceSelectionWith(Px.type(e).create({value:t}));return n&&n(r.setSelection(sb.create(r.doc,l.from))),!0}let{from:c,to:u}=l;if(!o||i<0)return!1;let h=a.delete(i,i+1),d=o.attrs.value;return h=h.insertText(d,i),n&&n(h.setSelection(sv.create(h.doc,c,u+d.length-1))),!0}),PC=mB("INLINE_LATEX");zH(bR);let PS=ye({props:{config:{type:Object,required:!0},innerView:{type:Object,required:!0},updateValue:{type:Object,required:!0}},setup(e){let t=t=>{if(t&&t instanceof HTMLElement){for(;t.firstChild;)t.removeChild(t.firstChild);e.innerView.value&&t.appendChild(e.innerView.value.dom)}},n=t=>{t.preventDefault(),e.updateValue.value()};return()=>bR("div",{class:"container"},e.innerView&&bR("div",{ref:t}),bR("button",{type:"button",onPointerdown:n},bR(b6,{icon:e.config.inlineEditConfirm})))}});var PM=e=>{throw TypeError(e)},PA=(e,t,n)=>t.has(e)||PM("Cannot "+n),PT=(e,t,n)=>(PA(e,t,"read from private field"),n?n.call(e):t.get(e)),PO=(e,t,n)=>t.has(e)?PM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),PE=(e,t,n,r)=>(PA(e,t,"write to private field"),t.set(e,n),n);class PN{constructor(e,t,n){this.ctx=e,PO(this,e4),PO(this,e5),PO(this,e2),PO(this,e3,vp(null,!0)),PO(this,e7,function(e){return vp(e,!0)}(()=>{})),PO(this,e6),PO(this,e8,()=>{PT(this,e3).value&&(PT(this,e3).value.destroy(),PT(this,e3).value=null)}),PO(this,e9,e=>{let t=(()=>{if(!e.editable)return!1;let{selection:t,schema:n}=e.state;if(t.empty||!(t instanceof sb))return!1;let r=t.node;if(r.type.name!==Pw)return!1;let i=t.from,o=n.nodes.paragraph.create(null,n.text(r.attrs.value)),l=new ha(PT(this,e2),{state:sN.create({doc:o,schema:new lA({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},text:{group:"inline"}}}),plugins:[aB({"Mod-z":AG,"Mod-Z":AK,"Mod-y":AK,Enter:()=>(PT(this,e7).value(),!0)})]})});return PT(this,e3).value=l,PT(this,e7).value=()=>{let{tr:t}=e.state;t.setNodeAttribute(i,"value",l.state.doc.textContent),e.dispatch(t),requestAnimationFrame(()=>{e.focus()})},!0})();return t||PT(this,e8).call(this),t}),this.update=(e,t)=>{PT(this,e5).update(e,t)},this.destroy=()=>{PT(this,e6).unmount(),PT(this,e5).destroy(),PT(this,e4).remove()};const r=document.createElement("div");r.className="milkdown-latex-inline-edit",PE(this,e4,r),PE(this,e6,b3(PS,{config:n,innerView:PT(this,e3),updateValue:PT(this,e7)})),PT(this,e6).mount(r),PE(this,e5,new mP({debounce:0,content:PT(this,e4),shouldShow:PT(this,e9),offset:10,floatingUIOptions:{placement:"bottom"}})),PT(this,e5).update(t),PE(this,e2,document.createElement("div"))}}e4=new WeakMap,e5=new WeakMap,e2=new WeakMap,e3=new WeakMap,e7=new WeakMap,e6=new WeakMap,e8=new WeakMap,e9=new WeakMap;let PD=dm(e=>(function(e,t,n={}){return new s2(e,(e,r,i,o)=>{var l,s,a;let{tr:c}=e,u=r[1],h=r[0],d={group:u,fullMatch:h,start:i,end:o},p=null==(l=n.updateCaptured)?void 0:l.call(n,d);if(Object.assign(d,p),{group:u,fullMatch:h,start:i,end:o}=d,null===h||!u||""===u.trim())return null;let f=null==(s=n.getAttr)?void 0:s.call(n,r),m=t.createAndFill(f);return m&&(c.replaceRangeWith(t.isBlock?c.doc.resolve(i).before():i,o,m),null==(a=n.beforeDispatch)||a.call(n,{match:[h,u],start:i,end:o,tr:c})),c})})(/(?:\$)([^$]+)(?:\$)$/,Px.type(e),{getAttr:e=>{var t;return{value:null!=(t=e[1])?t:""}}})),PI=dm(e=>s6(/^\$\$[\s\n]$/,wQ.type(e),()=>({language:"LaTeX"}))),PL=dA("remarkMath",()=>LL);function P_(e){return i6(e,"math",(e,t,n)=>{let{value:r}=e;n.children.splice(t,1,{type:"code",lang:"LaTeX",value:r})})}let PR=dA("remarkMathBlock",()=>()=>P_),Pz=dw({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),PP=dv(e=>new sD({key:new s_("CREPE_PLACEHOLDER"),props:{decorations:t=>{var n,r,i;if(e.get("CrepeCtx").readonly)return null;let o=e.get(Pz.key);if("doc"===o.mode&&!((r=t.doc).childCount<=1&&!(null==(i=r.firstChild)?void 0:i.content.size))||z7(t.selection)||z6(t.selection))return null;let l=function(e,t){let{selection:n}=e;if(!n.empty)return null;let r=n.$anchor,i=r.parent;if(i.content.size>0||aD(e=>"table"===e.type.name)(r))return null;let o=r.before();return uU.node(o,o+i.nodeSize,{class:"crepe-placeholder","data-placeholder":t})}(t,null!=(n=o.text)?n:"Please enter...");return l?uJ.create(t.doc,[l]):null}}}));zH(bR,bn);let PB=ye({props:{ctx:{type:Object,required:!0},hide:{type:Function,required:!0},show:{type:Object,required:!0},selection:{type:Object,required:!0},config:{type:Object,required:!1}},setup(e){let{ctx:t,config:n}=e,r=b_(()=>(function(e,t){var n,r,i,o,l,s,a,c,u;let h=new Pn;h.addGroup("formatting","Formatting").addItem("bold",{icon:null!=(n=null==e?void 0:e.boldIcon)?n:RO,active:e=>e.get(hP).call(xO.key,wb.type(e)),onRun:e=>{e.get(hP).call(ww.key)}}).addItem("italic",{icon:null!=(r=null==e?void 0:e.italicIcon)?r:R0,active:e=>e.get(hP).call(xO.key,wp.type(e)),onRun:e=>{e.get(hP).call(wf.key)}}).addItem("strikethrough",{icon:null!=(i=null==e?void 0:e.strikethroughIcon)?i:zr,active:e=>e.get(hP).call(xO.key,SN.type(e)),onRun:e=>{e.get(hP).call(SD.key)}});let d=h.addGroup("function","Function");d.addItem("code",{icon:null!=(o=null==e?void 0:e.codeIcon)?o:RB,active:e=>e.get(hP).call(xO.key,wS.type(e)),onRun:e=>{e.get(hP).call(wM.key)}});let p=t&&zp(t).get();if((null==p?void 0:p.includes(Rk.Latex))&&d.addItem("latex",{icon:null!=(l=null==e?void 0:e.latexIcon)?l:za,active:e=>e.get(hP).call(xE.key,Px.type(e)),onRun:e=>{e.get(hP).call(Pk.key)}}),d.addItem("link",{icon:null!=(s=null==e?void 0:e.linkIcon)?s:R1,active:e=>e.get(hP).call(xO.key,wE.type(e)),onRun:e=>{e.get(hP).call(LJ.key)}}),t&&(null==p?void 0:p.includes(Rk.AI))){let n=t.get(zm.key);n.provider&&d.addItem("ai",{icon:null!=(c=null!=(a=null==e?void 0:e.aiIcon)?a:n.aiIcon)?c:RS,active:()=>!1,onRun:e=>{let t=e.get(zK.key),{from:n,to:r}=e.get(hg).state.selection;t.show(n,r)}})}return null==(u=null==e?void 0:e.buildToolbar)||u.call(e,h),h.build()})(n,t));return()=>bR(bn,null,r.value.map(n=>n.items.map(n=>{var r;let i;return bR("button",{type:"button",class:b7("toolbar-item",t&&(r=n.active,zH(e.selection.value),t.get(hb).status===dh.Created&&r(t))&&"active"),onPointerdown:(i=n.onRun,e=>{e.preventDefault(),t&&(null==i||i(t))})},bR(b6,{icon:n.icon}))})).reduce((e,t,n)=>(0===n?e.push(...t):e.push(bR("div",{class:"divider"}),...t),e),[]))}});var PF=e=>{throw TypeError(e)},PH=(e,t,n)=>t.has(e)||PF("Cannot "+n),Pq=(e,t,n)=>(PH(e,t,"read from private field"),n?n.call(e):t.get(e)),Pj=(e,t,n)=>t.has(e)?PF("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),PV=(e,t,n,r)=>(PH(e,t,"write to private field"),t.set(e,n),n);let P$=mB("CREPE_TOOLBAR");class PW{constructor(e,t,n){Pj(this,te),Pj(this,tt),Pj(this,tn),Pj(this,tr),Pj(this,ti,vd(!1)),this.update=(e,t)=>{Pq(this,te).update(e,t),Pq(this,tr).value=e.state.selection},this.destroy=()=>{Pq(this,te).destroy(),Pq(this,tn).unmount(),Pq(this,tt).remove()},this.hide=()=>{Pq(this,te).hide()};const r=document.createElement("div");r.className="milkdown-toolbar",PV(this,tr,function(e){return vp(e,!0)}(t.state.selection));const i=b3(PB,{ctx:e,hide:this.hide,config:n,selection:Pq(this,tr),show:Pq(this,ti)});i.mount(r),PV(this,tt,r),PV(this,tn,i),PV(this,te,new mP({content:Pq(this,tt),debounce:20,offset:10,shouldShow(e){let{doc:t,selection:n}=e.state,{empty:i,from:o,to:l}=n,s=!t.textBetween(o,l).length&&n instanceof sv,a=!(n instanceof sv),c=e.dom.getRootNode().activeElement,u=r.contains(c),h=!e.hasFocus()&&!u,d=!e.editable;return!h&&!a&&!i&&!s&&!d}})),Pq(this,te).onShow=()=>{Pq(this,ti).value=!0},Pq(this,te).onHide=()=>{Pq(this,ti).value=!1},this.update(t)}}te=new WeakMap,tt=new WeakMap,tn=new WeakMap,tr=new WeakMap,ti=new WeakMap;let PU=[{label:"Paragraph",level:null},{label:"Heading 1",level:1},{label:"Heading 2",level:2},{label:"Heading 3",level:3},{label:"Heading 4",level:4},{label:"Heading 5",level:5},{label:"Heading 6",level:6}];function PG(e,t){if(e.get(hP).call(xO.key,t))return!0;let{state:n}=e.get(hg);if(n.storedMarks)return n.storedMarks.some(e=>e.type===t);if(n.selection instanceof sv){let{$cursor:e}=n.selection;if(e)return e.marks().some(e=>e.type===t)}return!1}zH(bR,bn);let PK=ye({props:{ctx:{type:Object,required:!0},version:{type:Object,required:!0},config:{type:Object,required:!1}},setup(e){let{ctx:t,config:n}=e,r=vd(null);function i(){return t.get(hb).status===dh.Created}function o(){zH(e.version.value)}let l=e=>{e.target.closest(".top-bar-heading-selector")||(r.value=null)};yf(()=>{window.addEventListener("pointerdown",l)}),yy(()=>{window.removeEventListener("pointerdown",l)});let s=b_(()=>{var e,r,i,o,l,s,a,c,u,h,d,p,f,m,g,y,b;let w,x,k,C,S,M,A,T;return x=null==(w=t&&zp(t).get())?void 0:w.includes(Rk.Latex),k=null==w?void 0:w.includes(Rk.ImageBlock),C=null==w?void 0:w.includes(Rk.Table),(S=new Pn).addGroup("heading","Heading").addItem("heading-selector",{...(y=null==n?void 0:n.headingOptions,b=null==n?void 0:n.chevronDownIcon,{icon:"",active:()=>!1,selector:{chevronIcon:null!=b?b:R_,activeLabel:e=>(function(e,t){var n,r;let i=null!=t?t:PU,{$from:o}=e.get(hg).state.selection,l=o.parent,s=null!=(n=i.find(e=>null===e.level))?n:i[0];if(l.type===wj.type(e)){let e=l.attrs.level;return null!=(r=i.find(t=>t.level===e))?r:s}return s})(e,M).label,options:(M=null!=y?y:PU).map(e=>({label:e.label,onSelect:t=>(function(e,t){let n=e.get(hP);if(null==t){let t=wz.type(e);n.call(xD.key,{nodeType:t})}else{let r=wj.type(e);n.call(xD.key,{nodeType:r,attrs:{level:t}})}})(t,e.level)}))}})}),S.addGroup("formatting","Formatting").addItem("bold",{icon:null!=(e=null==n?void 0:n.boldIcon)?e:RO,active:e=>PG(e,wb.type(e)),onRun:e=>{e.get(hP).call(ww.key)}}).addItem("italic",{icon:null!=(r=null==n?void 0:n.italicIcon)?r:R0,active:e=>PG(e,wp.type(e)),onRun:e=>{e.get(hP).call(wf.key)}}).addItem("strikethrough",{icon:null!=(i=null==n?void 0:n.strikethroughIcon)?i:zr,active:e=>PG(e,SN.type(e)),onRun:e=>{e.get(hP).call(SD.key)}}).addItem("code",{icon:null!=(o=null==n?void 0:n.codeIcon)?o:RB,active:e=>PG(e,wS.type(e)),onRun:e=>{let t=e.get(hg),{state:n}=t;if(n.selection.empty){let r=wS.type(e);PG(e,r)?t.dispatch(n.tr.removeStoredMark(r)):t.dispatch(n.tr.addStoredMark(r.create()))}else e.get(hP).call(wM.key)}}),S.addGroup("list","List").addItem("bullet-list",{icon:null!=(l=null==n?void 0:n.bulletListIcon)?l:RN,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xl.type(e);t.call(xI.key,{nodeType:n})}}).addItem("ordered-list",{icon:null!=(s=null==n?void 0:n.orderedListIcon)?s:R2,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xh.type(e);t.call(xI.key,{nodeType:n})}}).addItem("task-list",{icon:null!=(a=null==n?void 0:n.taskListIcon)?a:zl,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xg.type(e);t.call(xI.key,{nodeType:n,attrs:{checked:!1}})}}),(A=S.addGroup("insert","Insert")).addItem("link",{icon:null!=(c=null==n?void 0:n.linkIcon)?c:R1,active:e=>PG(e,wE.type(e)),onRun:e=>{let t=e.get(hg),{state:n}=t,r=wE.type(e);n.selection.empty&&PG(e,r)?t.dispatch(n.tr.removeStoredMark(r)):e.get(hP).call(LJ.key)}}),k&&A.addItem("image",{icon:null!=(u=null==n?void 0:n.imageIcon)?u:RQ,active:()=>!1,onRun:e=>{let t=e.get(hP),n=ki.type(e);t.call(xL.key,{nodeType:n})}}),C&&A.addItem("table",{icon:null!=(h=null==n?void 0:n.tableIcon)?h:zi,active:()=>!1,onRun:e=>{let t=e.get(hP),{from:n}=e.get(hg).state.selection;t.call(xL.key,{nodeType:SH(e,3,3)}),t.call(x_.key,{pos:n})}}),(T=S.addGroup("block","Block")).addItem("code-block",{icon:null!=(d=null==n?void 0:n.codeBlockIcon)?d:RF,active:()=>!1,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xD.key,{nodeType:n})}}),x&&T.addItem("math",{icon:null!=(p=null==n?void 0:n.mathIcon)?p:za,active:()=>!1,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xL.key,{nodeType:n,attrs:{language:"LaTeX"}})}}),S.addGroup("more","More").addItem("quote",{icon:null!=(f=null==n?void 0:n.quoteIcon)?f:R7,active:()=>!1,onRun:e=>{let t=e.get(hP),n=wK.type(e);t.call(xI.key,{nodeType:n})}}).addItem("hr",{icon:null!=(m=null==n?void 0:n.hrIcon)?m:Rj,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xn.type(e);t.call(xL.key,{nodeType:n})}}),null==(g=null==n?void 0:n.buildTopBar)||g.call(n,S),S.build()});return()=>{let e=i()?t.get(hg):null;return e&&!e.editable?null:bR("div",{class:"top-bar-inner"},s.value.map(e=>e.items.map(e=>{var n,l,s,a,c;let u;if(e.selector){let c,u;return n=e.key,l=e.selector,c=r.value===n,bR("div",{key:n,class:"top-bar-heading-selector"},bR("button",{type:"button",class:"top-bar-heading-button",onPointerdown:e=>{e.preventDefault(),e.stopPropagation(),r.value=r.value===n?null:n}},bR("span",{class:"top-bar-heading-label"},(o(),u=i()?l.activeLabel(t):null!=(a=null==(s=l.options[0])?void 0:s.label)?a:"")),l.chevronIcon&&bR("span",{class:"top-bar-chevron"},bR(b6,{icon:l.chevronIcon}))),c&&bR("div",{class:"top-bar-heading-dropdown"},l.options.map((e,i)=>bR("button",{key:`${n}-${i}`,type:"button",class:b7("top-bar-heading-option",u===e.label&&"active"),onPointerdown:n=>{n.preventDefault(),n.stopPropagation(),r.value=null,e.onSelect(t)}},e.label))))}return e.onRun?bR("button",{key:e.key,type:"button",class:b7("top-bar-item",(c=e.active,o(),!!i()&&c(t)&&"active")),onPointerdown:(u=e.onRun,e=>{e.preventDefault(),t&&u(t)})},bR(b6,{icon:e.icon})):null})).reduce((e,t,n)=>{var r,i;if(0===n)e.push(...t);else{let o=null!=(i=null==(r=s.value[n])?void 0:r.key)?i:n;e.push(bR("div",{key:`divider-${o}`,class:"top-bar-divider"}),...t)}return e},[]))}}});var PJ=e=>{throw TypeError(e)},PZ=(e,t,n)=>t.has(e)||PJ("Cannot "+n),PY=(e,t,n)=>(PZ(e,t,"read from private field"),n?n.call(e):t.get(e)),PX=(e,t,n)=>t.has(e)?PJ("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),PQ=(e,t,n,r)=>(PZ(e,t,"write to private field"),t.set(e,n),n);let P0=new s_("CREPE_TOP_BAR");class P1{constructor(e,t,n){PX(this,to),PX(this,tl),PX(this,ts),this.update=(e,t)=>{PY(this,to).style.display=e.editable?"":"none",PY(this,ts).value++},this.destroy=()=>{PY(this,tl).unmount(),PY(this,to).remove()},PQ(this,ts,vd(0));const r=document.createElement("div");r.className="milkdown-top-bar";const i=b3(PK,{ctx:e,config:n,version:PY(this,ts)});i.mount(r),PQ(this,to,r),PQ(this,tl,i);const o=t.dom.parentElement;o&&o.insertBefore(r,o.firstChild),this.update(t)}}to=new WeakMap,tl=new WeakMap,ts=new WeakMap;let P4=dw({view:()=>({update:()=>{},destroy:()=>{}})},"topBarConfig"),P5=dv(e=>new sD({key:P0,view:e.get(P4.key).view}));var P2=e=>{throw TypeError(e)},P3=(e,t,n)=>t.has(e)||P2("Cannot "+n),P7=(e,t,n)=>(P3(e,t,"read from private field"),n?n.call(e):t.get(e)),P6=(e,t,n)=>t.has(e)?P2("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),P8=(e,t,n,r)=>(P3(e,t,"write to private field"),t.set(e,n),n);class P9{constructor({root:e,defaultValue:t=""}={}){var n;P6(this,ta),P6(this,tc),P6(this,tu,!0),this.addFeature=(e,t)=>(e(P7(this,ta),t),this),this.create=()=>P7(this,ta).create(),this.destroy=()=>P7(this,ta).destroy(),this.setReadonly=e=>(P8(this,tu,!e),P7(this,ta).action(t=>{P7(this,ta).status===dh.Created&&t.get(hg).setProps({editable:()=>!e})}),this),this.getMarkdown=()=>P7(this,ta).action(e=>{let t=e.get(hg),n=(e.get(hD),e.get(h0));return n(t.state.doc)}),this.on=e=>(P7(this,ta).status!==dh.Created?P7(this,ta).config(t=>{e(t.get(Rp))}):P7(this,ta).action(t=>{e(t.get(Rp))}),this),P8(this,tc,null!=(n="string"==typeof e?document.querySelector(e):e)?n:document.body),P8(this,ta,dd.make().config(e=>{e.inject(zd,this),e.inject(zh,[])}).config(e=>{e.set(dl,P7(this,tc)),e.set(h4,t),e.set(di,{editable:()=>P7(this,tu)}),e.update(Rc.key,e=>({...e,size:4})),e.update(Rb.key,e=>({...e,uploader:async(e,t,n)=>{let r=zp(n).get().includes(Rk.ImageBlock),i=r?t.nodes["image-block"]:t.nodes.image;if(!i)return[];let o=r?n.get(x3.key).onUpload:void 0,l=[];for(let t=0;t<e.length;t++){let n=e.item(t);n&&n.type.includes("image")&&l.push(n)}return await Promise.all(l.map(async e=>{let t=o?await o(e):URL.createObjectURL(e);return i.createAndFill({src:t})}))}}))}).use(xJ).use(Rm).use(Ra).use(Rh).use(Ry).use(Rt).use(Rx).use(Mg))}get editor(){return P7(this,ta)}get readonly(){return!P7(this,tu)}}ta=new WeakMap,tc=new WeakMap,tu=new WeakMap;class Be extends P9{constructor({features:e={},featureConfigs:t={},...n}={}){super(n);const r=n$(t,zu);Object.entries({...RC,...e}).filter(([,e])=>e).map(([e])=>e).forEach(e=>{let t=r[e];!function(e,t,n){switch(e){case Rk.CodeMirror:return((e,t={})=>{e.config(zf(Rk.CodeMirror)).config(e=>{let{languages:n=[],theme:r}=t,i=[nJ.keymap.of(AN.concat(AD)),Ok];r&&i.push(r),t.extensions&&i.push(...t.extensions),e.update(A1.key,e=>{var r;return{extensions:i,languages:n,expandIcon:t.expandIcon||R_,searchIcon:t.searchIcon||R9,clearSearchIcon:t.clearSearchIcon||RP,searchPlaceholder:t.searchPlaceholder||"Search language",copyText:t.copyText||"Copy",copyIcon:t.copyIcon||Rq,onCopy:t.onCopy||(()=>{}),noResultText:t.noResultText||"No result",renderLanguage:t.renderLanguage||e.renderLanguage,renderPreview:t.renderPreview||e.renderPreview,previewToggleButton:e=>{var n,r;return[(null==(n=t.previewToggleIcon)?void 0:n.call(t,e))||(e?R$:zc),(null==(r=t.previewToggleText)?void 0:r.call(t,e))||(e?"Edit":"Hide")].map(e=>e.trim()).join(" ")},previewLabel:t.previewLabel||e.previewLabel,previewLoading:t.previewLoading||e.previewLoading,previewOnlyByDefault:null!=(r=t.previewOnlyByDefault)?r:e.previewOnlyByDefault}})}).use(Ti)})(t,n);case Rk.ListItem:return t.config(zf(Rk.ListItem)).config(e=>{e.set(_O.key,{renderLabel:({label:e,listType:t,checked:r})=>{var i,o,l;return null==r?"bullet"===t?null!=(i=null==n?void 0:n.bulletIcon)?i:RE:e:r?null!=(o=null==n?void 0:n.checkBoxCheckedIcon)?o:RI:null!=(l=null==n?void 0:n.checkBoxUncheckedIcon)?l:RL}})}).use(_L);case Rk.LinkTooltip:return t.config(zf(Rk.LinkTooltip)).config(_w).config(e=>{e.update(LK.key,e=>{var t,r,i,o,l,s;return{...e,linkIcon:null!=(t=null==n?void 0:n.linkIcon)?t:Rq,editButton:null!=(r=null==n?void 0:n.editButton)?r:R$,removeButton:null!=(i=null==n?void 0:n.removeButton)?i:R6,confirmButton:null!=(o=null==n?void 0:n.confirmButton)?o:RH,inputPlaceholder:null!=(l=null==n?void 0:n.inputPlaceholder)?l:"Paste link...",onCopyLink:null!=(s=null==n?void 0:n.onCopyLink)?s:()=>{}}})}).use(_x);case Rk.ImageBlock:return t.config(zf(Rk.ImageBlock)).config(e=>{e.update(OZ.key,e=>{var t,r,i,o,l,s;return{uploadButton:null!=(t=null==n?void 0:n.inlineUploadButton)?t:"Upload",imageIcon:null!=(r=null==n?void 0:n.inlineImageIcon)?r:RQ,confirmButton:null!=(i=null==n?void 0:n.inlineConfirmButton)?i:RH,uploadPlaceholderText:null!=(o=null==n?void 0:n.inlineUploadPlaceholderText)?o:"or paste link",onUpload:null!=(s=null!=(l=null==n?void 0:n.inlineOnUpload)?l:null==n?void 0:n.onUpload)?s:e.onUpload,proxyDomURL:null==n?void 0:n.proxyDomURL}}),e.update(x3.key,e=>{var t,r,i,o,l,s,a,c,u;return{uploadButton:null!=(t=null==n?void 0:n.blockUploadButton)?t:"Upload file",imageIcon:null!=(r=null==n?void 0:n.blockImageIcon)?r:RQ,captionIcon:null!=(i=null==n?void 0:n.blockCaptionIcon)?i:RD,confirmButton:null!=(o=null==n?void 0:n.blockConfirmButton)?o:"Confirm",captionPlaceholderText:null!=(l=null==n?void 0:n.blockCaptionPlaceholderText)?l:"Write Image Caption",uploadPlaceholderText:null!=(s=null==n?void 0:n.blockUploadPlaceholderText)?s:"or paste link",onUpload:null!=(c=null!=(a=null==n?void 0:n.blockOnUpload)?a:null==n?void 0:n.onUpload)?c:e.onUpload,proxyDomURL:null==n?void 0:n.proxyDomURL,onImageLoadError:null!=(u=null==n?void 0:n.onImageLoadError)?u:e.onImageLoadError,maxWidth:null==n?void 0:n.maxWidth,maxHeight:null==n?void 0:n.maxHeight}})}).use(kv).use(O5);case Rk.Cursor:var r,i;let o,l;if(t.config(zf(Rk.Cursor)).config(e=>{e.update(OR.key,()=>{var e,t;return{class:"crepe-drop-cursor",width:null!=(e=null==n?void 0:n.width)?e:4,color:null!=(t=null==n?void 0:n.color)&&t}})}).use(OH),(null==n?void 0:n.virtual)===!1)return;let s=(o=!1,l="u"<typeof document?null:document.createElement("div"),new sD({key:Oq,view:e=>{let t;!0!==o&&function(e,t){for(let[n,r]of Object.entries(e.marks))!1!==r.spec.inclusive||t.includes(n)||console.warn(`[prosemirror-virtual-cursor] Virtual cursor does not work well with marks that have inclusive set to false. Please consider removing the inclusive option from the "${n}" mark or adding it to the "skipWarning" option.`)}(e.state.schema,o||[]);let n=e.dom.ownerDocument,r=l=l||document.createElement("div"),i=()=>{!function(e,t){var n,r;if(!e||!e.dom||e.isDestroyed||!t)return;let{state:i,dom:o}=e,{selection:l}=i;if(!OV(l))return;let s=function(e,t){var n;let r=window.getSelection();if(!r||!r.rangeCount)return null;let i=null==(n=null==r?void 0:r.getRangeAt(0))?void 0:n.cloneRange();if(!i)return null;i.collapse(t);let o=i.getClientRects(),l=(null==o?void 0:o.length)?o[o.length-1]:null;return(null==l?void 0:l.height)?l:e.coordsAtPos(e.state.selection.head)}(e,l.$head===l.$from);if(!s)return;let a=o.getBoundingClientRect(),c="prosemirror-virtual-cursor",u=i.selection.$head,[h,d]=Oj(u),p=i.storedMarks||u.marks();l.$cursor&&h&&d&&p&&!o7.sameSet(h,d)&&(o7.sameSet(h,p)?c+=" prosemirror-virtual-cursor-left":o7.sameSet(d,p)&&(c+=" prosemirror-virtual-cursor-right")),t.className=c,r="prosemirror-virtual-cursor-animation",(n=t).classList.remove(r),n.offsetWidth,n.classList.add(r),t.style.height=`${s.bottom-s.top}px`,t.style.left=`${s.left-a.left}px`,t.style.top=`${s.top-a.top}px`}(e,r)};return window.ResizeObserver&&(t=new window.ResizeObserver(()=>i())).observe(e.dom),n.addEventListener("selectionchange",i),{update:()=>{i()},destroy:()=>{n.removeEventListener("selectionchange",i),t&&t.unobserve(e.dom)}}},props:{handleKeyDown:(e,t)=>{var n;let{selection:r}=e.state;if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||t.isComposing||!["ArrowLeft","ArrowRight"].includes(t.key)||!OV(r)||!r.empty)return!1;let i=r.$head,[o,l]=Oj(i),s=e.state.storedMarks||i.marks();if(o&&l&&!o7.sameSet(o,l)){if("ArrowLeft"===t.key&&!o7.sameSet(o,s))return e.dispatch(e.state.tr.setStoredMarks(o)),!0;if("ArrowRight"===t.key&&!o7.sameSet(l,s))return e.dispatch(e.state.tr.setStoredMarks(l)),!0}return"ArrowLeft"===t.key&&1===i.textOffset?(e.dispatch(e.state.tr.setSelection(sv.create(e.state.doc,i.pos-1)).setStoredMarks(i.marks())),!0):"ArrowRight"===t.key&&i.textOffset+1===(null==(n=i.parent.maybeChild(i.index()))?void 0:n.nodeSize)&&(e.dispatch(e.state.tr.setSelection(sv.create(e.state.doc,i.pos+1)).setStoredMarks(i.marks())),!0)},decorations:e=>{if(l&&OV(e.selection)&&e.selection.empty)return uJ.create(e.doc,[uU.widget(0,l,{key:"prosemirror-virtual-cursor"})])},attributes:{class:"virtual-cursor-enabled"}}}));t.use(dv(()=>s));return;case Rk.BlockEdit:return t.config(zf(Rk.BlockEdit)).config(e=>{e.set(b9.key,{filterNodes:e=>!aD(e=>["table","blockquote","math_inline"].includes(e.type.name))(e)}),e.set(ws.key,{view:()=>new Py(e,n)})}).config(e=>{e.set(Pc.key,{view:t=>new Ph(e,t,n)})}).use(Pu).use(ws).use(Pc);case Rk.Placeholder:return t.config(zf(Rk.Placeholder)).config(e=>{n&&e.update(Pz.key,e=>({...e,...n}))}).use(PP).use(Pz);case Rk.Toolbar:return t.config(zf(Rk.Toolbar)).config(e=>{e.set(P$.key,{view:t=>new PW(e,t,n)})}).use(P$);case Rk.Table:return t.config(zf(Rk.Table)).config(e=>{e.update(_W.key,e=>({...e,renderButton:e=>{var t,r,i,o,l,s,a,c,u;switch(e){case"add_row":return null!=(t=null==n?void 0:n.addRowIcon)?t:R3;case"add_col":return null!=(r=null==n?void 0:n.addColIcon)?r:R3;case"delete_row":return null!=(i=null==n?void 0:n.deleteRowIcon)?i:R6;case"delete_col":return null!=(o=null==n?void 0:n.deleteColIcon)?o:R6;case"align_col_left":return null!=(l=null==n?void 0:n.alignLeftIcon)?l:RA;case"align_col_center":return null!=(s=null==n?void 0:n.alignCenterIcon)?s:RM;case"align_col_right":return null!=(a=null==n?void 0:n.alignRightIcon)?a:RT;case"col_drag_handle":return null!=(c=null==n?void 0:n.colDragHandleIcon)?c:RV;case"row_drag_handle":return null!=(u=null==n?void 0:n.rowDragHandleIcon)?u:RV}}}))}).use(_9);case Rk.Latex:return t.config(zf(Rk.Latex)).config(e=>{if(!zp(e).get().includes(Rk.CodeMirror))throw Error("You need to enable CodeMirror to use LaTeX feature");e.update(A1.key,e=>({...e,renderPreview:(t,r,i)=>"latex"===t.toLowerCase()&&r.length>0?LA(r,{...null==n?void 0:n.katexOptions,throwOnError:!1,displayMode:!0}).toMarkup():(0,e.renderPreview)(t,r,i)})),e.set(PC.key,{view:t=>{var r;return new PN(e,t,{inlineEditConfirm:null!=(r=null==n?void 0:n.inlineEditConfirm)?r:RH,...n})}})}).use(PL).use(PR).use(Px).use(PC).use(PD).use(PI).use(Pb).use(Pk);case Rk.TopBar:return t.config(zf(Rk.TopBar)).config(e=>{e.set(P4.key,{view:t=>new P1(e,t,n)})}).use(P4).use(P5);case Rk.AI:let a,c;return a=null!=(r=null==n?void 0:n.diff)?r:{},c=null!=(i=null==n?void 0:n.streaming)?i:{},t.config(zf(Rk.AI)).config(e=>{e.update(dV.key,e=>{var t;return{...e,ignoreAttrs:null!=(t=a.ignoreAttrs)?t:z3}});let{ignoreAttrs:t,...n}=a;e.update(d9.key,e=>{var t;return{...e,customBlockTypes:null!=(t=n.customBlockTypes)?t:z2,...n}})}).use(d1).use(pp).config(e=>{e.update(pm.key,e=>{var t;return{...e,...c,ignoreAttrs:null!=(t=c.ignoreAttrs)?t:z3,...(null==n?void 0:n.diffReviewOnEnd)!==void 0?{diffReviewOnEnd:n.diffReviewOnEnd}:{}}})}).use(pA).config(e=>{e.update(zm.key,e=>{var t;return{...e,...(null==n?void 0:n.provider)!==void 0?{provider:n.provider}:{},...(null==n?void 0:n.buildContext)!==void 0?{buildContext:n.buildContext}:{},diffReviewOnEnd:null!=(t=null==n?void 0:n.diffReviewOnEnd)?t:e.diffReviewOnEnd,...(null==n?void 0:n.onError)!==void 0?{onError:n.onError}:{},...(null==n?void 0:n.aiIcon)!==void 0?{aiIcon:n.aiIcon}:{}}})}).use(zm).use(zg).use(zw).use(zx).config(e=>{var t,r,i,o,l,s,a,c,u,h,d,p,f;let m,g=((m=new zF).addItem("improve",{icon:RS,label:"Improve writing",streamingLabel:"Improving writing",prompt:"Improve the writing while preserving the original meaning."}).addItem("grammar",{icon:RU,label:"Fix grammar & spelling",streamingLabel:"Fixing grammar & spelling",prompt:"Fix any grammar and spelling errors without changing the meaning."}).addItem("shorter",{icon:zn,label:"Make shorter",streamingLabel:"Making shorter",prompt:"Make this shorter while preserving the key information."}).addItem("longer",{icon:R4,label:"Make longer",streamingLabel:"Expanding",prompt:"Expand this with more detail and examples."}),m.addSubmenu("tone",{icon:R$,label:"Change tone…",title:"Change tone",searchPlaceholder:"Search tones…"},e=>{for(let[t,n]of[["professional","Professional"],["casual","Casual"],["confident","Confident"],["friendly","Friendly"],["direct","Direct"],["formal","Formal"]])e.addItem(t,{icon:R$,label:n,streamingLabel:"Adjusting tone",prompt:`Rewrite this in a ${n.toLowerCase()} tone.`})}),m.addSubmenu("translate",{icon:zs,label:"Translate…",title:"Translate",searchPlaceholder:"Search languages…"},e=>{for(let[t,n,r]of[["english","English","English"],["chinese","Chinese","Chinese (Simplified)"],["japanese","Japanese","Japanese"],["korean","Korean","Korean"],["spanish","Spanish","Spanish"],["french","French","French"],["german","German","German"]])e.addItem(t,{icon:zs,label:n,streamingLabel:`Translating to ${n}`,prompt:`Translate this to ${r}.`})}),null==(t=null==n?void 0:n.buildAISuggestions)||t.call(n,m),{placeholder:null!=(r=null==n?void 0:n.instructionPlaceholder)?r:"Tell AI what to do with the selection…",chrome:{aiIcon:null!=(i=null==n?void 0:n.aiIcon)?i:RS,sendIcon:null!=(o=null==n?void 0:n.sendIcon)?o:ze,sendPromptIcon:null!=(l=null==n?void 0:n.sendPromptIcon)?l:zt,enterKeyIcon:null!=(s=null==n?void 0:n.enterKeyIcon)?s:RW,chevronLeftIcon:null!=(a=null==n?void 0:n.chevronLeftIcon)?a:RR,chevronRightIcon:null!=(c=null==n?void 0:n.chevronRightIcon)?c:Rz,suggestionsHeaderLabel:null!=(u=null==n?void 0:n.suggestionsHeaderLabel)?u:"SUGGESTIONS",sendAsPromptHeaderLabel:null!=(h=null==n?void 0:n.sendAsPromptHeaderLabel)?h:"SEND AS PROMPT",sendAsPromptLabel:null!=(d=null==n?void 0:n.sendAsPromptLabel)?d:"Ask AI:",submitButtonLabel:null!=(p=null==n?void 0:n.submitButtonLabel)?p:"Send prompt",listboxLabel:null!=(f=null==n?void 0:n.listboxLabel)?f:"AI suggestions"},suggestions:m.build()}),y=null;e.update(zK.key,e=>({...e,show:(e,t)=>{null==y||y.show(e,t)}})),e.set(zJ.key,{view:t=>y=new zG(e,t,g)})}).use(zK).use(zJ).use(function(e={}){var t,n;let{config:r}=e,i=null!=(t=null==r?void 0:r.fallbackLabel)?t:"Generating",o=null!=(n=null==r?void 0:r.cancelHint)?n:"Esc to cancel";return dv(e=>{let t=null;function n(){t&&(t.destroy(),t=null)}return new sD({key:z4,state:{init:()=>uJ.empty,apply(r,l,s,a){let c=pw.getState(a);if(!(null==c?void 0:c.active)||null==c.insertEndPos)return n(),uJ.empty;if(r.getMeta(pw)||r.docChanged){var u;let n,r;return u=a.doc,n=Math.min(c.insertEndPos,u.content.size),r=uU.widget(n,(t?t.setLabel(e):t=new z5(e,i,o),t).dom,{side:1,key:"ai-streaming-indicator"}),uJ.create(u,[r])}return l.map(r.mapping,r.doc)}},view:()=>({destroy(){n()}}),props:{decorations(e){var t;return null!=(t=z4.getState(e))?t:uJ.empty},handleKeyDown(t,n){var r;if("Escape"!==n.key)return!1;let i=e.get(hP);return e.get(zg.key).abortController?(n.preventDefault(),i.call(zx.key,{keep:!0}),!0):null!=(r=pw.getState(t.state))&&!!r.active&&(n.preventDefault(),i.call(pM.key,{keep:!0}),!0)}}})})}({config:null==n?void 0:n.streamingIndicator})).use(function(e={}){let t=function(e){var t,n,r,i,o,l,s;let{config:a,enterKeyIcon:c}=e;return{retryLabel:null!=(t=null==a?void 0:a.retryLabel)?t:"Retry",rejectAllLabel:null!=(n=null==a?void 0:a.rejectAllLabel)?n:"Reject all",acceptAllLabel:null!=(r=null==a?void 0:a.acceptAllLabel)?r:"Accept all",retryIcon:null!=(i=null==a?void 0:a.retryIcon)?i:R8,rejectIcon:null!=(o=null==a?void 0:a.rejectIcon)?o:RP,acceptIcon:null!=(l=null==a?void 0:a.acceptIcon)?l:RH,enterKeyIcon:null!=c?c:RW,modSymbol:null!=(s=null==a?void 0:a.modSymbol)?s:zI}}(e);return dv(e=>new sD({key:zD,view:n=>new zN(e,n,t),props:{handleKeyDown(t,n){var r;return"Enter"===n.key&&!!(n.metaKey||n.ctrlKey)&&!!(null==(r=d$.getState(t.state))?void 0:r.active)&&!!e.get(zg.key).diffOwnedByAI&&(n.preventDefault(),e.get(hP).call(dQ.key),!0)}}}))}({config:null==n?void 0:n.diffActions,enterKeyIcon:null==n?void 0:n.enterKeyIcon}))}}(e,this.editor,t)})}}Be.Feature=Rk;let Bt=(0,td.forwardRef)(({content:e,readOnly:t,onChange:n,className:r},i)=>{let o=(0,td.useRef)(null),l=(0,td.useRef)(null),s=(0,td.useRef)(n),[a,c]=(0,td.useState)(!1);return(0,td.useEffect)(()=>{s.current=n},[n]),(0,td.useImperativeHandle)(i,()=>({setMarkdown:e=>{l.current&&a&&l.current.editor.action(dT(e))},getMarkdown:()=>l.current?.getMarkdown()||""})),(0,td.useEffect)(()=>{if(!o.current)return;let n=new Be({root:o.current,defaultValue:e,featureConfigs:{[Be.Feature.Placeholder]:{text:"输入 / 以使用命令..."},[Be.Feature.ImageBlock]:{inlineUploadButton:"上传图片",inlineUploadPlaceholderText:"或粘贴图片链接...",blockUploadButton:"上传图片",blockUploadPlaceholderText:"或粘贴图片链接...",blockCaptionPlaceholderText:"添加标题..."},[Be.Feature.BlockEdit]:{textGroup:{label:"基础",text:{label:"文本"},h1:{label:"一级标题"},h2:{label:"二级标题"},h3:{label:"三级标题"},h4:{label:"四级标题"},h5:{label:"五级标题"},h6:{label:"六级标题"},quote:{label:"引用"},divider:{label:"分割线"}},listGroup:{label:"列表",bulletList:{label:"无序列表"},orderedList:{label:"有序列表"},taskList:{label:"任务列表"}},advancedGroup:{label:"高级",image:{label:"图片"},codeBlock:{label:"代码块"},table:{label:"表格"},math:{label:"数学公式"}}}}});n.on(e=>{e.markdownUpdated((e,t,n)=>{s.current&&t!==n&&s.current(t)})});let r=!1;return n.create().then(()=>{r?n.destroy():(l.current=n,n.setReadonly(!!t),c(!0))}),()=>{r=!0,l.current&&(l.current.destroy(),l.current=null)}},[]),(0,td.useEffect)(()=>{l.current&&a&&l.current.setReadonly(!!t)},[t,a]),(0,td.useEffect)(()=>{l.current&&a&&e!==l.current.getMarkdown()&&l.current.editor.action(dT(e))},[e,a]),(0,th.jsx)("div",{ref:o,className:r||"milkdown-editor"})});Bt.displayName="MilkdownEditor",e.s(["MilkdownEditor",0,Bt],34859)},36975,e=>{e.n(e.i(34859))}]);
|
|
736
|
+
`,zu={[Rk.CodeMirror]:{theme:n6,languages:nK,expandIcon:R_,searchIcon:R9,clearSearchIcon:RP,searchPlaceholder:"Search language",noResultText:"No result",previewToggleIcon:e=>e?R$:zc}},zh=ru([],"FeaturesCtx"),zd=ru({},"CrepeCtx");function zp(e){return e.use("FeaturesCtx")}function zf(e){return t=>{zp(t).update(t=>t.includes(e)?t:[...t,e])}}let zm=dw({provider:void 0,buildContext:void 0,diffReviewOnEnd:!0,onError:e=>{console.error(`[milkdown/ai] [${e.code}]`,e)},aiIcon:void 0},"aiProviderConfig"),zg=dw({abortController:null,label:"",lastInstruction:"",lastLabel:void 0,lastFrom:-1,lastTo:-1,diffOwnedByAI:!1},"aiSession");function zv(e,t){let n=e.get(zm.key);try{n.onError(t)}catch(e){console.error("[milkdown/ai] onError handler failed:",e)}}function zy(e){let t=e.get(zg.key);e.set(zg.key,{...t,abortController:null,label:""})}async function zb(e,t,n,r){try{let i=t(n,r.signal),o=e.get(hP);for await(let e of i){if(r.signal.aborted)break;o.call(pC.key,e)}if(r.signal.aborted)return;let l=e.get(zm.key);if(l.diffReviewOnEnd){let t=e.get(zg.key);e.set(zg.key,{...t,diffOwnedByAI:!0})}let s=o.call(pS.key,{diffReview:l.diffReviewOnEnd});if(l.diffReviewOnEnd&&!s){let t=e.get(zg.key);e.set(zg.key,{...t,diffOwnedByAI:!1})}}catch(n){let t;if(r.signal.aborted)return;zv(e,(t=n instanceof Error?n.message:rl(n),new n9(n8.aiProviderError,`AI provider error: ${t}`,{cause:n}))),e.get(hP).call(pM.key,{keep:!1})}finally{e.get(zg.key).abortController===r&&zy(e)}}let zw=df("RunAI",e=>t=>(n,r)=>{var i,o,l,s;let a;if(!(null==t?void 0:t.instruction))return!1;let c=e.get(zm.key);if(!c.provider||e.get(zg.key).abortController||(null==(i=pw.getState(n))?void 0:i.active)||(null==(o=d$.getState(n))?void 0:o.active))return!1;if(!r)return!0;let u=new AbortController,{from:h,to:d}=n.selection;e.set(zg.key,{abortController:u,label:null!=(l=t.label)?l:"",lastInstruction:t.instruction,lastLabel:t.label,lastFrom:h,lastTo:d,diffOwnedByAI:!1});let p=e.get(hP),f=n.selection.empty?"cursor":"selection";if(!p.call(pk.key,{insertAt:f}))return zy(e),!1;try{a=(null!=(s=c.buildContext)?s:function(e,t){var n;let r=e.get(hg),i=e.get(h0),{state:o}=r,l=i(o.doc),s="";if(!o.selection.empty){let{from:e,to:t}=o.selection,r=o.doc.slice(e,t),{schema:l}=o.doc.type,a=l.topNodeType.createAndFill(null,r.content);if(!a){let e=null==(n=l.nodes.paragraph)?void 0:n.createAndFill(null,r.content);e&&(a=l.topNodeType.createAndFill(null,e))}s=a?i(a):o.doc.textBetween(e,t)}return{document:l,selection:s,instruction:t}})(e,t.instruction)}catch(n){let t;return zv(e,(t=n instanceof Error?n.message:rl(n),new n9(n8.aiBuildContextError,`AI buildContext failed: ${t}`,{cause:n}))),p.call(pM.key,{keep:!1}),zy(e),!1}return zb(e,c.provider,a,u),!0}),zx=df("AbortAI",e=>t=>(n,r)=>{var i;let o=e.get(zg.key);return r?!!o.abortController&&(o.abortController.abort(),zy(e),(null==(i=pw.getState(n))?void 0:i.active)&&e.get(hP).call(pM.key,t),!0):!!o.abortController});var zk=e=>{throw TypeError(e)},zC=(e,t,n)=>t.has(e)||zk("Cannot "+n),zS=(e,t,n)=>(zC(e,t,"read from private field"),n?n.call(e):t.get(e)),zM=(e,t,n)=>t.has(e)?zk("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zA=(e,t,n,r)=>(zC(e,t,"write to private field"),t.set(e,n),n),zT=(e,t,n)=>(zC(e,t,"access private method"),n);let zO="milkdown-ai-diff-actions";function zE(e,t){e.innerHTML=fk.sanitize(t.trim())}class zN{constructor(e,t,n){this.ctx=e,zM(this,ey),zM(this,eu),zM(this,eh),zM(this,ed),zM(this,ep),zM(this,ef,!1),zM(this,em,!1),zM(this,eg,null),zM(this,ev,!1),zM(this,ek,()=>{let e=this.ctx.get(zg.key);if(!e.lastInstruction||!zS(this,ev)||!zT(this,ey,eC).call(this))return;let t=this.ctx.get(hP);t.call(d0.key);let n=this.ctx.get(hg),{doc:r}=n.state,i=Math.min(Math.max(e.lastFrom,0),r.content.size),o=Math.min(Math.max(e.lastTo,0),r.content.size);n.dispatch(n.state.tr.setSelection(sv.create(n.state.doc,i,o))),t.call(zw.key,{instruction:e.lastInstruction,label:e.lastLabel})}),zM(this,eS,()=>{this.ctx.get(hP).call(d0.key)}),zM(this,eM,()=>{this.ctx.get(hP).call(dQ.key)}),zA(this,ep,n),zA(this,eh,zT(this,ey,eb).call(this,t));const r=document.createElement("div");r.className=zO,r.dataset.show="false",zA(this,ed,zT(this,ey,ew).call(this,"retry",n.retryIcon,n.retryLabel,zS(this,ek))),r.appendChild(zS(this,ed)),r.appendChild(zT(this,ey,ew).call(this,"reject",n.rejectIcon,n.rejectAllLabel,zS(this,eS)));const i=zT(this,ey,ew).call(this,"accept",n.acceptIcon,n.acceptAllLabel,zS(this,eM));i.appendChild(zT(this,ey,ex).call(this)),r.appendChild(i),zA(this,eu,r),zS(this,eh).appendChild(r),this.update(t)}update(e){var t;let n=!!(null==(t=d$.getState(e.state))?void 0:t.active);if(n!==zS(this,em))if(zA(this,em,n),n){let t=this.ctx.get(zg.key);zA(this,ev,t.diffOwnedByAI),zA(this,eg,e.state.doc)}else{zA(this,ev,!1),zA(this,eg,null);let e=this.ctx.get(zg.key);e.diffOwnedByAI&&this.ctx.set(zg.key,{...e,diffOwnedByAI:!1})}let r=n&&zS(this,ev);if(r!==zS(this,ef)&&(zA(this,ef,r),zS(this,eu).dataset.show=r?"true":"false"),r){let t=this.ctx.get(zg.key),n=!!zS(this,eg)&&e.state.doc.eq(zS(this,eg));zS(this,ed).disabled=!t.lastInstruction||!n}}destroy(){zS(this,eu).remove()}}eu=new WeakMap,eh=new WeakMap,ed=new WeakMap,ep=new WeakMap,ef=new WeakMap,em=new WeakMap,eg=new WeakMap,ev=new WeakMap,ey=new WeakSet,eb=function(e){var t;return null!=(t=e.dom.closest(".milkdown"))?t:document.body},ew=function(e,t,n,r){let i,o=document.createElement("button");o.type="button",o.className=`${zO}-btn ${zO}-btn-${e}`,o.appendChild(((i=document.createElement("span")).className=`${zO}-icon`,zE(i,t),i));let l=document.createElement("span");return l.textContent=n,o.appendChild(l),o.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),r()}),o},ex=function(){let e=document.createElement("span");e.className=`${zO}-shortcut`;let t=document.createElement("span");t.textContent=zS(this,ep).modSymbol;let n=document.createElement("span");return n.className=`${zO}-shortcut-icon`,zE(n,zS(this,ep).enterKeyIcon),e.append(t,n),e},ek=new WeakMap,eC=function(){return!!zS(this,eg)&&this.ctx.get(hg).state.doc.eq(zS(this,eg))},eS=new WeakMap,eM=new WeakMap;let zD=new s_("CREPE_AI_DIFF_ACTIONS_PANEL"),zI=function(){var e,t,n,r;if("u"<typeof navigator)return"⌘";let i=navigator,o=null!=(r=null!=(n=null!=(t=null==(e=i.userAgentData)?void 0:e.platform)?t:i.platform)?n:i.userAgent)?r:"";return/mac|iphone|ipad|ipod/i.test(o)?"⌘":"Ctrl"}();var zL=e=>{throw TypeError(e)},z_=(e,t,n)=>t.has(e)||zL("Cannot "+n),zR=(e,t,n)=>(z_(e,t,"read from private field"),n?n.call(e):t.get(e)),zz=(e,t,n)=>t.has(e)?zL("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zP=(e,t,n,r)=>(z_(e,t,"write to private field"),t.set(e,n),n);function zB(e){let t={addItem:(n,r)=>(e.items.set(n,r),t),removeItem:n=>(e.items.delete(n),t),getItem:t=>e.items.get(t),clear:()=>(e.items.clear(),t)};return t}class zF{constructor(){zz(this,eA,[]),this.addItem=(e,t)=>(zR(this,eT).call(this,e),zR(this,eA).push({kind:"item",id:e,item:t}),this),this.addSubmenu=(e,t,n)=>{zR(this,eT).call(this,e);let r={def:t,items:new Map};return n&&n(zB(r)),zR(this,eA).push({kind:"submenu",id:e,node:r}),this},this.removeItem=e=>(zR(this,eT).call(this,e),this),this.getItem=e=>{let t=zR(this,eA).find(t=>"item"===t.kind&&t.id===e);return(null==t?void 0:t.kind)==="item"?t.item:void 0},this.getSubmenu=e=>{let t=zR(this,eA).find(t=>"submenu"===t.kind&&t.id===e);return(null==t?void 0:t.kind)==="submenu"?zB(t.node):void 0},this.clear=()=>(zP(this,eA,[]),this),this.build=()=>{let e=[],t={};for(let n of zR(this,eA))"item"===n.kind?e.push({kind:"item",id:n.id,item:n.item}):(e.push({kind:"submenu",id:n.id,def:n.node.def}),t[n.id]={def:n.node.def,items:Array.from(n.node.items.entries()).map(([e,t])=>({id:e,item:t}))});return{main:e,submenus:t}},zz(this,eT,e=>{zP(this,eA,zR(this,eA).filter(t=>t.id!==e))})}}function zH(){}eA=new WeakMap,eT=new WeakMap,zH(bR);let zq=ye({props:{placeholder:{type:Object,required:!0},resetSignal:{type:Object,required:!0},suggestions:{type:Object,required:!0},chrome:{type:Object,required:!0},onConfirm:{type:Function,required:!0},onCancel:{type:Function,required:!0}},setup({placeholder:e,resetSignal:t,suggestions:n,chrome:r,onConfirm:i,onCancel:o}){let l=vd(""),s=vd({kind:"main"}),a=vd(0),c=vd(null),u=vd(null),h=`ai-instruction-list-${Math.random().toString(36).slice(2,9)}`,d=e=>`${h}-opt-${e}`;v0(t,()=>{l.value="",s.value={kind:"main"},a.value=0},void 0);let p=b_(()=>{if("submenu"===s.value.kind){let e=n.submenus[s.value.id];return e?e.items.map(({id:e,item:t})=>({id:e,icon:t.icon,label:t.label,hasSubmenu:!1,prompt:{text:t.prompt,streamingLabel:t.streamingLabel}})):[]}return n.main.map(e=>"item"===e.kind?{id:e.id,icon:e.item.icon,label:e.item.label,hasSubmenu:!1,prompt:{text:e.item.prompt,streamingLabel:e.item.streamingLabel}}:{id:e.id,icon:e.def.icon,label:e.def.label,hasSubmenu:!0})}),f=b_(()=>{var e,t;return"submenu"!==s.value.kind?null:null!=(t=null==(e=n.submenus[s.value.id])?void 0:e.def)?t:null}),m=b_(()=>{let e=l.value.trim().toLowerCase();return e?p.value.filter(t=>t.label.toLowerCase().includes(e)):p.value}),g=b_(()=>l.value.trim().length>0),y=b_(()=>m.value.length+ +!!g.value);v0([m,s,g],()=>{a.value=g.value?m.value.length:0},void 0);let b=()=>{v_(()=>{var e;return null==(e=c.value)?void 0:e.focus()})},w=()=>{s.value={kind:"main"},l.value="",a.value=0,b()},x=e=>{e.hasSubmenu?(s.value={kind:"submenu",id:e.id},l.value="",a.value=0,b()):e.prompt&&(i(e.prompt.text,e.prompt.streamingLabel),l.value="")},k=()=>{let e=l.value.trim();e&&(i(e),l.value="")},C=()=>{v_(()=>{let e=u.value;if(!e)return;let t=e.querySelector(`[data-index="${a.value}"]`);null==t||t.scrollIntoView({block:"nearest"})})},S=e=>{if(e.stopPropagation(),"ArrowDown"===e.key){if(e.preventDefault(),0===y.value)return;a.value=(a.value+1)%y.value,C();return}if("ArrowUp"===e.key){if(e.preventDefault(),0===y.value)return;a.value=(a.value-1+y.value)%y.value,C();return}if("Enter"===e.key){let t,n;e.preventDefault(),t=a.value,t<(n=m.value).length?x(n[t]):g.value&&k();return}if("Escape"===e.key){e.preventDefault(),"submenu"===s.value.kind?w():o();return}"Backspace"===e.key&&""===l.value&&"submenu"===s.value.kind&&(e.preventDefault(),w())},M=e=>{e.preventDefault()};return()=>{let t=m.value,n=g.value,i=f.value;return bR("div",{class:"ai-instruction"},bR("div",{class:"ai-instruction-input"},bR("span",{class:"ai-instruction-input-prefix"},bR(b6,{icon:r.aiIcon})),bR("input",{ref:c,class:"ai-instruction-input-field",role:"combobox","aria-expanded":"true","aria-autocomplete":"list","aria-controls":h,"aria-activedescendant":y.value>0?d(a.value):void 0,placeholder:i?i.searchPlaceholder:e.value,value:l.value,onInput:e=>{l.value=e.target.value},onKeydown:S}),bR("button",{type:"button",class:"ai-instruction-submit","aria-label":r.submitButtonLabel,disabled:!n,onMousedown:M,onClick:k},bR(b6,{icon:r.sendIcon}))),bR("div",{class:"ai-instruction-list",ref:u,id:h,role:"listbox","aria-label":r.listboxLabel},i&&bR("button",{type:"button",class:"ai-instruction-back",onMousedown:M,onClick:w},bR("span",{class:"ai-instruction-back-icon","aria-hidden":"true"},bR(b6,{icon:r.chevronLeftIcon})),bR("span",null,i.title)),t.length>0&&bR("div",{class:"ai-instruction-section"},bR("div",{class:"ai-instruction-section-header"},r.suggestionsHeaderLabel),t.map((e,t)=>bR("div",{key:e.id,id:d(t),"data-index":t,role:"option","aria-selected":t===a.value,class:["ai-instruction-item",t===a.value?"active":""],onMousedown:M,onClick:()=>x(e),onPointerenter:()=>{a.value=t}},bR("span",{class:"ai-instruction-item-icon"},bR(b6,{icon:e.icon})),bR("span",{class:"ai-instruction-item-label"},function(e,t){let n=t.trim();if(!n)return[e];let r=e.toLowerCase(),i=n.toLowerCase(),o=r.indexOf(i);return -1===o?[e]:[e.slice(0,o),bR("mark",null,e.slice(o,o+n.length)),e.slice(o+n.length)]}(e.label,l.value)),e.hasSubmenu&&bR("span",{class:"ai-instruction-item-arrow"},bR(b6,{icon:r.chevronRightIcon}))))),n&&bR("div",{class:"ai-instruction-section"},bR("div",{class:"ai-instruction-section-header"},r.sendAsPromptHeaderLabel),bR("div",{id:d(t.length),"data-index":t.length,role:"option","aria-selected":a.value===t.length,class:["ai-instruction-item","ai-instruction-item-prompt",a.value===t.length?"active":""],onMousedown:M,onClick:k,onPointerenter:()=>{a.value=t.length}},bR("span",{class:"ai-instruction-item-icon"},bR(b6,{icon:r.sendPromptIcon})),bR("span",{class:"ai-instruction-item-label"},r.sendAsPromptLabel," ",bR("span",{class:"ai-instruction-item-quote"},'"',l.value,'"')),bR("span",{class:"ai-instruction-item-shortcut"},bR(b6,{icon:r.enterKeyIcon}))))))}}});var zj=e=>{throw TypeError(e)},zV=(e,t,n)=>t.has(e)||zj("Cannot "+n),z$=(e,t,n)=>(zV(e,t,"read from private field"),n?n.call(e):t.get(e)),zW=(e,t,n)=>t.has(e)?zj("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zU=(e,t,n,r)=>(zV(e,t,"write to private field"),t.set(e,n),n);class zG{constructor(e,t,n){this.ctx=e,zW(this,eO),zW(this,eE),zW(this,eN),zW(this,eD),zW(this,eI),zW(this,eL,-1),zW(this,e_,-1),zW(this,eR,!1),zW(this,ez,(e,t)=>{!e.trim()||this.ctx.get(hP).call(zw.key,{instruction:e,label:t})&&(zU(this,eR,!1),z$(this,eE).hide())}),zW(this,eP,()=>{zU(this,eR,!1),z$(this,eE).hide()}),this.show=(e,t)=>{zU(this,eL,e),zU(this,e_,t),z$(this,eI).value++,zU(this,eR,!0);let n=this.ctx.get(hg);z$(this,eE).show({getBoundingClientRect:()=>aE(n,e,t)},n),requestAnimationFrame(()=>{var e;null==(e=z$(this,eO).querySelector("input"))||e.focus()})},this.update=(e,t)=>{let{selection:n}=e.state,r=n instanceof sv,i=n.from!==z$(this,eL)||n.to!==z$(this,e_);if(!r||i){zU(this,eR,!1),z$(this,eE).hide();return}z$(this,eE).update(e,t)},this.destroy=()=>{z$(this,eN).unmount(),z$(this,eE).destroy(),z$(this,eO).remove()},zU(this,eD,vd(n.placeholder)),zU(this,eI,vd(0));const r=document.createElement("div");r.className="milkdown-ai-instruction";const i=b3(zq,{placeholder:z$(this,eD),resetSignal:z$(this,eI),suggestions:n.suggestions,chrome:n.chrome,onConfirm:z$(this,ez),onCancel:z$(this,eP)});i.mount(r),zU(this,eN,i),zU(this,eO,r),zU(this,eE,new mP({content:r,debounce:0,offset:10,shouldShow:()=>z$(this,eR),floatingUIOptions:{placement:"bottom"}})),z$(this,eE).onHide=()=>{zU(this,eR,!1),requestAnimationFrame(()=>{try{let e=z$(this,eO).getRootNode().activeElement;if(!e||!z$(this,eO).contains(e))return;this.ctx.get(hg).dom.focus({preventScroll:!0})}catch(e){}})},z$(this,eE).update(t)}}eO=new WeakMap,eE=new WeakMap,eN=new WeakMap,eD=new WeakMap,eI=new WeakMap,eL=new WeakMap,e_=new WeakMap,eR=new WeakMap,ez=new WeakMap,eP=new WeakMap;let zK=dw({show:()=>{}},"aiInstructionTooltipAPI"),zJ=mB("CREPE_AI_INSTRUCTION");var zZ=e=>{throw TypeError(e)},zY=(e,t,n)=>t.has(e)||zZ("Cannot "+n),zX=(e,t,n)=>(zY(e,t,"read from private field"),n?n.call(e):t.get(e)),zQ=(e,t,n)=>t.has(e)?zZ("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z0=(e,t,n,r)=>(zY(e,t,"write to private field"),t.set(e,n),n);let z1="milkdown-ai-streaming",z4=new s_("CREPE_AI_STREAMING_INDICATOR");class z5{constructor(e,t,n){zQ(this,eB),zQ(this,eF),zQ(this,eH),zQ(this,eq,performance.now()),zQ(this,ej,""),zQ(this,eV,0),zQ(this,e$,()=>{let e=performance.now()-zX(this,eq);zX(this,eB).style.transform=`rotate(${e/800*360}deg)`,z0(this,eV,requestAnimationFrame(zX(this,e$)))}),z0(this,eH,t);const r=document.createElement("span");r.className=`${z1}-indicator`,r.contentEditable="false",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const i=document.createElement("span");i.className=`${z1}-spinner`,i.setAttribute("aria-hidden","true"),r.appendChild(i);const o=document.createElement("span");o.className=`${z1}-label`,r.appendChild(o);const l=document.createElement("span");l.className=`${z1}-esc`,l.textContent=n,r.appendChild(l),this.dom=r,z0(this,eB,i),z0(this,eF,o),this.setLabel(e),zX(this,e$).call(this)}setLabel(e){let t=e.get(zg.key),n=`${t.label||zX(this,eH)}\u2026`;n!==zX(this,ej)&&(z0(this,ej,n),zX(this,eF).textContent=n)}destroy(){zX(this,eV)&&cancelAnimationFrame(zX(this,eV)),z0(this,eV,0)}}eB=new WeakMap,eF=new WeakMap,eH=new WeakMap,eq=new WeakMap,ej=new WeakMap,eV=new WeakMap,e$=new WeakMap;let z2=["table","image-block","code_block"],z3={heading:["id"]};function z7(e){return"code_block"===e.$from.parent.type.name}function z6(e){var t;let n=null==(t=e.$from.node(e.$from.depth-1))?void 0:t.type;return(null==n?void 0:n.name)==="list_item"}var z8=e=>{throw TypeError(e)},z9=(e,t,n)=>t.has(e)||z8("Cannot "+n),Pe=(e,t,n)=>(z9(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?z8("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);class Pn{constructor(){Pt(this,eW,[]),this.clear=()=>{let e,t;return t=[],z9(this,e=eW,"write to private field"),e.set(this,t),this},Pt(this,eU,e=>{let t={group:e,addItem:(n,r)=>{let i={...r,key:n};return e.items.push(i),t},clear:()=>(e.items=[],t)};return t}),this.addGroup=(e,t)=>{let n={key:e,label:t,items:[]};return Pe(this,eW).push(n),Pe(this,eU).call(this,n)},this.getGroup=e=>{let t=Pe(this,eW).find(t=>t.key===e);if(!t)throw Error(`Group with key ${e} not found`);return Pe(this,eU).call(this,t)},this.build=()=>Pe(this,eW)}}eW=new WeakMap,eU=new WeakMap,zH(bR);let Pr=ye({props:{ctx:{type:Object,required:!0},show:{type:Object,required:!0},filter:{type:Object,required:!0},hide:{type:Function,required:!0},config:{type:Object,required:!1}},setup({ctx:e,show:t,filter:n,hide:r,config:i}){let o=vd(),l=b_(()=>(function(e,t,n){var r,i,o,l,s,a,c,u,h,d,p,f,m,g,y,b,w,x,k,C,S,M,A,T,O,E,N,D,I,L,_,R,z,P,B,F,H,q,j,V,$,W,U,G,K,J,Z,Y,X,Q,ee,et,en,er,ei,eo,el,es,ea,ec,eu,eh,ed,ep,ef,em,eg,ev,ey,eb,ew,ex,ek,eC,eS,eM,eA,eT,eO,eE,eN,eD,eI,eL,e_,eR,ez,eP,eB,eF,eH,eq,ej,eV,e$,eW,eU,eG,eK,eJ,eZ,eY,eX,eQ,e0,e1,e4,e5,e2,e3,e7,e6,e8,e9,te,tt,tn,tr,ti;let to=n&&zp(n).get(),tl=null==to?void 0:to.includes(Rk.Latex),ts=null==to?void 0:to.includes(Rk.ImageBlock),ta=null==to?void 0:to.includes(Rk.Table),tc=new Pn;if((null==t?void 0:t.textGroup)!==null){let e=tc.addGroup("text",null!=(i=null==(r=null==t?void 0:t.textGroup)?void 0:r.label)?i:"Text");(null==(o=null==t?void 0:t.textGroup)?void 0:o.text)!==null&&e.addItem("text",{label:null!=(a=null==(s=null==(l=null==t?void 0:t.textGroup)?void 0:l.text)?void 0:s.label)?a:"Text",icon:null!=(h=null==(u=null==(c=null==t?void 0:t.textGroup)?void 0:c.text)?void 0:u.icon)?h:zo,onRun:e=>{let t=e.get(hP),n=wz.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n})}}),(null==(d=null==t?void 0:t.textGroup)?void 0:d.h1)!==null&&e.addItem("h1",{label:null!=(m=null==(f=null==(p=null==t?void 0:t.textGroup)?void 0:p.h1)?void 0:f.label)?m:"Heading 1",icon:null!=(b=null==(y=null==(g=null==t?void 0:t.textGroup)?void 0:g.h1)?void 0:y.icon)?b:RG,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:1}})}}),(null==(w=null==t?void 0:t.textGroup)?void 0:w.h2)!==null&&e.addItem("h2",{label:null!=(C=null==(k=null==(x=null==t?void 0:t.textGroup)?void 0:x.h2)?void 0:k.label)?C:"Heading 2",icon:null!=(A=null==(M=null==(S=null==t?void 0:t.textGroup)?void 0:S.h2)?void 0:M.icon)?A:RK,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:2}})}}),(null==(T=null==t?void 0:t.textGroup)?void 0:T.h3)!==null&&e.addItem("h3",{label:null!=(N=null==(E=null==(O=null==t?void 0:t.textGroup)?void 0:O.h3)?void 0:E.label)?N:"Heading 3",icon:null!=(L=null==(I=null==(D=null==t?void 0:t.textGroup)?void 0:D.h3)?void 0:I.icon)?L:RJ,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:3}})}}),(null==(_=null==t?void 0:t.textGroup)?void 0:_.h4)!==null&&e.addItem("h4",{label:null!=(P=null==(z=null==(R=null==t?void 0:t.textGroup)?void 0:R.h4)?void 0:z.label)?P:"Heading 4",icon:null!=(H=null==(F=null==(B=null==t?void 0:t.textGroup)?void 0:B.h4)?void 0:F.icon)?H:RZ,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:4}})}}),(null==(q=null==t?void 0:t.textGroup)?void 0:q.h5)!==null&&e.addItem("h5",{label:null!=($=null==(V=null==(j=null==t?void 0:t.textGroup)?void 0:j.h5)?void 0:V.label)?$:"Heading 5",icon:null!=(G=null==(U=null==(W=null==t?void 0:t.textGroup)?void 0:W.h5)?void 0:U.icon)?G:RY,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:5}})}}),(null==(K=null==t?void 0:t.textGroup)?void 0:K.h6)!==null&&e.addItem("h6",{label:null!=(Y=null==(Z=null==(J=null==t?void 0:t.textGroup)?void 0:J.h6)?void 0:Z.label)?Y:"Heading 6",icon:null!=(ee=null==(Q=null==(X=null==t?void 0:t.textGroup)?void 0:X.h6)?void 0:Q.icon)?ee:RX,onRun:e=>{let t=e.get(hP),n=wj.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n,attrs:{level:6}})}}),(null==(et=null==t?void 0:t.textGroup)?void 0:et.quote)!==null&&e.addItem("quote",{label:null!=(ei=null==(er=null==(en=null==t?void 0:t.textGroup)?void 0:en.quote)?void 0:er.label)?ei:"Quote",icon:null!=(es=null==(el=null==(eo=null==t?void 0:t.textGroup)?void 0:eo.quote)?void 0:el.icon)?es:R7,onRun:e=>{let t=e.get(hP),n=wK.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n})}}),(null==(ea=null==t?void 0:t.textGroup)?void 0:ea.divider)!==null&&e.addItem("divider",{label:null!=(eh=null==(eu=null==(ec=null==t?void 0:t.textGroup)?void 0:ec.divider)?void 0:eu.label)?eh:"Divider",icon:null!=(ef=null==(ep=null==(ed=null==t?void 0:t.textGroup)?void 0:ed.divider)?void 0:ep.icon)?ef:Rj,onRun:e=>{let t=e.get(hP),n=xn.type(e);t.call(xN.key),t.call(xL.key,{nodeType:n})}})}if((null==t?void 0:t.listGroup)!==null){let e=tc.addGroup("list",null!=(eg=null==(em=null==t?void 0:t.listGroup)?void 0:em.label)?eg:"List");(null==(ev=null==t?void 0:t.listGroup)?void 0:ev.bulletList)!==null&&e.addItem("bullet-list",{label:null!=(ew=null==(eb=null==(ey=null==t?void 0:t.listGroup)?void 0:ey.bulletList)?void 0:eb.label)?ew:"Bullet List",icon:null!=(eC=null==(ek=null==(ex=null==t?void 0:t.listGroup)?void 0:ex.bulletList)?void 0:ek.icon)?eC:RN,onRun:e=>{let t=e.get(hP),n=xl.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n})}}),(null==(eS=null==t?void 0:t.listGroup)?void 0:eS.orderedList)!==null&&e.addItem("ordered-list",{label:null!=(eT=null==(eA=null==(eM=null==t?void 0:t.listGroup)?void 0:eM.orderedList)?void 0:eA.label)?eT:"Ordered List",icon:null!=(eN=null==(eE=null==(eO=null==t?void 0:t.listGroup)?void 0:eO.orderedList)?void 0:eE.icon)?eN:R2,onRun:e=>{let t=e.get(hP),n=xh.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n})}}),(null==(eD=null==t?void 0:t.listGroup)?void 0:eD.taskList)!==null&&e.addItem("task-list",{label:null!=(e_=null==(eL=null==(eI=null==t?void 0:t.listGroup)?void 0:eI.taskList)?void 0:eL.label)?e_:"Task List",icon:null!=(eP=null==(ez=null==(eR=null==t?void 0:t.listGroup)?void 0:eR.taskList)?void 0:ez.icon)?eP:zl,onRun:e=>{let t=e.get(hP),n=xg.type(e);t.call(xN.key),t.call(xI.key,{nodeType:n,attrs:{checked:!1}})}})}if((null==t?void 0:t.advancedGroup)!==null){let e=tc.addGroup("advanced",null!=(eF=null==(eB=null==t?void 0:t.advancedGroup)?void 0:eB.label)?eF:"Advanced");(null==(eH=null==t?void 0:t.advancedGroup)?void 0:eH.image)!==null&&ts&&e.addItem("image",{label:null!=(eV=null==(ej=null==(eq=null==t?void 0:t.advancedGroup)?void 0:eq.image)?void 0:ej.label)?eV:"Image",icon:null!=(eU=null==(eW=null==(e$=null==t?void 0:t.advancedGroup)?void 0:e$.image)?void 0:eW.icon)?eU:RQ,onRun:e=>{let t=e.get(hP),n=ki.type(e);t.call(xN.key),t.call(xL.key,{nodeType:n})}}),(null==(eG=null==t?void 0:t.advancedGroup)?void 0:eG.codeBlock)!==null&&e.addItem("code",{label:null!=(eZ=null==(eJ=null==(eK=null==t?void 0:t.advancedGroup)?void 0:eK.codeBlock)?void 0:eJ.label)?eZ:"Code",icon:null!=(eQ=null==(eX=null==(eY=null==t?void 0:t.advancedGroup)?void 0:eY.codeBlock)?void 0:eX.icon)?eQ:RB,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xN.key),t.call(xD.key,{nodeType:n})}}),(null==(e0=null==t?void 0:t.advancedGroup)?void 0:e0.table)!==null&&ta&&e.addItem("table",{label:null!=(e5=null==(e4=null==(e1=null==t?void 0:t.advancedGroup)?void 0:e1.table)?void 0:e4.label)?e5:"Table",icon:null!=(e7=null==(e3=null==(e2=null==t?void 0:t.advancedGroup)?void 0:e2.table)?void 0:e3.icon)?e7:zi,onRun:e=>{let t=e.get(hP),n=e.get(hg);t.call(xN.key);let{from:r}=n.state.selection;t.call(xL.key,{nodeType:SH(e,3,3)}),t.call(x_.key,{pos:r})}}),(null==(e6=null==t?void 0:t.advancedGroup)?void 0:e6.math)!==null&&tl&&e.addItem("math",{label:null!=(te=null==(e9=null==(e8=null==t?void 0:t.advancedGroup)?void 0:e8.math)?void 0:e9.label)?te:"Math",icon:null!=(tr=null==(tn=null==(tt=null==t?void 0:t.advancedGroup)?void 0:tt.math)?void 0:tn.icon)?tr:za,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xN.key),t.call(xL.key,{nodeType:n,attrs:{language:"LaTeX"}})}})}null==(ti=null==t?void 0:t.buildMenu)||ti.call(t,tc);let tu=tc.build();e&&(tu=tu.map(t=>{let n=t.items.filter(t=>t.label.toLowerCase().includes(e.toLowerCase()));return{...t,items:n}}).filter(e=>e.items.length>0));let th=tu.flatMap(e=>e.items);return th.forEach((e,t)=>{Object.assign(e,{index:t})}),tu.reduce((e,t)=>{let n=e+t.items.length;return Object.assign(t,{range:[e,n]}),n},0),{groups:tu,size:th.length}})(n.value,i,e)),s=vd(0),a=vd({x:-999,y:-999}),c=e=>{let{x:t,y:n}=e;a.value={x:t,y:n}};v0([l,t],()=>{let{size:e}=l.value;0===e&&t.value?r():s.value>=e&&(s.value=0)},void 0);let u=(e,t)=>{let n=s.value,r="function"==typeof e?e(n):e;null==t||t(r),s.value=r},h=e=>{var t,n;let r=null==(t=o.value)?void 0:t.querySelector(`[data-index="${e}"]`),i=null==(n=o.value)?void 0:n.querySelector(".menu-groups");r&&i&&(i.scrollTop=r.offsetTop-i.offsetTop)},d=t=>{let n=l.value.groups.flatMap(e=>e.items).at(t);(null==n?void 0:n.onRun)&&e&&n.onRun(e),r()},p=e=>{let{size:t,groups:n}=l.value;if("Escape"===e.key){e.preventDefault(),null==r||r();return}return"ArrowDown"===e.key?(e.preventDefault(),u(e=>e<t-1?e+1:e,h)):"ArrowUp"===e.key?(e.preventDefault(),u(e=>e<=0?e:e-1,h)):"ArrowLeft"===e.key?(e.preventDefault(),u(e=>{let t=n.find(t=>t.range[0]<=e&&t.range[1]>e);if(!t)return e;let r=n[n.indexOf(t)-1];return r?r.range[1]-1:e},h)):"ArrowRight"===e.key?(e.preventDefault(),u(e=>{let t=n.find(t=>t.range[0]<=e&&t.range[1]>e);if(!t)return e;let r=n[n.indexOf(t)+1];return r?r.range[0]:e},h)):void("Enter"===e.key&&(e.preventDefault(),d(s.value)))};return vQ(()=>{t.value?window.addEventListener("keydown",p,{capture:!0}):window.removeEventListener("keydown",p,{capture:!0})}),yy(()=>{window.removeEventListener("keydown",p,{capture:!0})}),()=>bR("div",{ref:o,onPointerdown:e=>e.preventDefault()},bR("nav",{class:"tab-group"},bR("ul",null,l.value.groups.map(e=>bR("li",{key:e.key,onPointerdown:()=>u(e.range[0],h),class:s.value>=e.range[0]&&s.value<e.range[1]?"selected":""},e.label)))),bR("div",{class:"menu-groups",onPointermove:c},l.value.groups.map(e=>bR("div",{key:e.key,class:"menu-group"},bR("h6",null,e.label),bR("ul",null,e.items.map(e=>{let t;return bR("li",{key:e.key,"data-index":e.index,class:s.value===e.index?"hover":"",onPointerenter:(t=e.index,e=>{let n=a.value;if(!n)return;let{x:r,y:i}=e;(r!==n.x||i!==n.y)&&u(t)}),onPointerdown:()=>{var t,n;null==(n=null==(t=o.value)?void 0:t.querySelector(`[data-index="${e.index}"]`))||n.classList.add("active")},onPointerup:()=>{var t,n;null==(n=null==(t=o.value)?void 0:t.querySelector(`[data-index="${e.index}"]`))||n.classList.remove("active"),d(e.index)}},bR(b6,{icon:e.icon}),bR("span",null,e.label))}))))))}});var Pi=e=>{throw TypeError(e)},Po=(e,t,n)=>t.has(e)||Pi("Cannot "+n),Pl=(e,t,n)=>(Po(e,t,"read from private field"),n?n.call(e):t.get(e)),Ps=(e,t,n)=>t.has(e)?Pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pa=(e,t,n,r)=>(Po(e,t,"write to private field"),t.set(e,n),n);let Pc=(P="CREPE_MENU",w=dw({},`${P}_SLASH_SPEC`),x=dv(e=>{let t=e.get(w.key);return new sD({key:new s_(`${P}_SLASH`),...t})}),(k=[w,x]).key=w.key,k.pluginKey=x.key,w.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${P}`},x.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${P}`},k),Pu=dw({show:()=>{},hide:()=>{}},"menuAPICtx");class Ph{constructor(e,t,n){Ps(this,eG),Ps(this,eK),Ps(this,eJ),Ps(this,eZ),Ps(this,eY,null),this.update=e=>{Pl(this,eZ).update(e)},this.show=e=>{Pa(this,eY,e),Pl(this,eJ).value="",Pl(this,eZ).show()},this.hide=()=>{Pa(this,eY,null),Pl(this,eZ).hide()},this.destroy=()=>{Pl(this,eZ).destroy(),Pl(this,eK).unmount(),Pl(this,eG).remove()};const r=document.createElement("div");r.classList.add("milkdown-slash-menu");const i=vd(!1),o=vd("");Pa(this,eJ,o);const l=b3(Pr,{ctx:e,config:n,show:i,filter:o,hide:this.hide});Pa(this,eK,l),l.mount(r),Pa(this,eG,r);const s=this;Pa(this,eZ,new xZ({content:Pl(this,eG),debounce:20,shouldShow(e){if(z7(e.state.selection)||z6(e.state.selection))return!1;let t=this.getContent(e,e=>["paragraph","heading"].includes(e.type.name));if(null==t||!function(e){if(!(e instanceof sv))return!1;let{$head:t}=e,n=t.parent;return t.parentOffset===n.content.size}(e.state.selection))return!1;let n=Pl(s,eY);if(o.value=t.startsWith("/")?t.slice(1):t,"number"==typeof n){let t=Math.min(n,e.state.doc.nodeSize-2);return e.state.doc.resolve(t).node()===e.state.doc.resolve(e.state.selection.from).node()||(Pa(s,eY,null),!1)}return!!t.startsWith("/")},offset:10})),Pl(this,eZ).onShow=()=>{i.value=!0},Pl(this,eZ).onHide=()=>{i.value=!1},this.update(t),e.set(Pu.key,{show:e=>this.show(e),hide:()=>this.hide()})}}eG=new WeakMap,eK=new WeakMap,eJ=new WeakMap,eZ=new WeakMap,eY=new WeakMap,zH(bR,bn);let Pd=ye({props:{onAdd:{type:Function,required:!0},addIcon:{type:String,required:!0},handleIcon:{type:String,required:!0}},setup(e){let t=vd();return()=>bR(bn,null,bR("div",{ref:t,class:"operation-item",onPointerdown:e=>{var n;e.preventDefault(),e.stopPropagation(),null==(n=t.value)||n.classList.add("active")},onPointerup:n=>{var r;n.preventDefault(),n.stopPropagation(),null==(r=t.value)||r.classList.remove("active"),e.onAdd()}},bR(b6,{icon:e.addIcon})),bR("div",{class:"operation-item"},bR(b6,{icon:e.handleIcon})))}});var Pp=e=>{throw TypeError(e)},Pf=(e,t,n)=>t.has(e)||Pp("Cannot "+n),Pm=(e,t,n)=>(Pf(e,t,"read from private field"),n?n.call(e):t.get(e)),Pg=(e,t,n)=>t.has(e)?Pp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pv=(e,t,n,r)=>(Pf(e,t,"write to private field"),t.set(e,n),n);class Py{constructor(e,t){var n,r,i;Pg(this,eX),Pg(this,eQ),Pg(this,e0),Pg(this,e1),this.update=()=>{Pm(this,eQ).update()},this.destroy=()=>{Pm(this,eQ).destroy(),Pm(this,eX).remove(),Pm(this,e0).unmount()},this.onAdd=()=>{let e=Pm(this,e1),t=e.get(hg);t.hasFocus()||t.focus();let{state:n,dispatch:r}=t,i=Pm(this,eQ).active;if(!i)return;let o=i.$pos.pos+i.node.nodeSize,l=n.tr.insert(o,wz.type(e).create());r((l=l.setSelection(sv.near(l.doc.resolve(o)))).scrollIntoView()),Pm(this,eQ).hide(),e.get(Pu.key).show(l.selection.from)},Pv(this,e1,e);const o=document.createElement("div");o.classList.add("milkdown-block-handle");const l=b3(Pd,{onAdd:this.onAdd,addIcon:null!=(n=null==t?void 0:t.handleAddIcon)?n:R3,handleIcon:null!=(r=null==t?void 0:t.handleDragIcon)?r:R5});l.mount(o),Pv(this,e0,l),Pv(this,eX,o);const s=null!=(i=null==t?void 0:t.blockHandle)?i:{};Pv(this,eQ,new wl({ctx:e,content:o,getOffset:()=>16,getPlacement:({active:e,blockDom:t})=>{if("heading"===e.node.type.name)return"left";let n=0;e.node.descendants(e=>{n+=e.childCount});let r=e.el,i=r.getBoundingClientRect(),o=t.getBoundingClientRect(),l=window.getComputedStyle(r),s=Number.parseInt(l.paddingTop,10)||0,a=Number.parseInt(l.paddingBottom,10)||0,c=i.height-s-a,u=o.height;return n>2||u<c?"left-start":"left"},...s})),this.update()}}eX=new WeakMap,eQ=new WeakMap,e0=new WeakMap,e1=new WeakMap;let Pb=wQ.extendSchema(e=>t=>{let n=e(t);return{...n,toMarkdown:{match:n.toMarkdown.match,runner:(e,t)=>{var r,i;if("latex"!==(null!=(r=t.attrs.language)?r:"").toLowerCase())return n.toMarkdown.runner(e,t);e.addNode("math",void 0,(null==(i=t.content.firstChild)?void 0:i.text)||"")}}}}),Pw="math_inline",Px=dx(Pw,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${Pw}"]`,getAttrs:e=>{var t;return{value:null!=(t=e.dataset.value)?t:""}}}],toDOM:e=>{let t=e.attrs.value,n=document.createElement("span");return n.dataset.type=Pw,n.dataset.value=t,LT(t,n,{throwOnError:!1}),n},parseMarkdown:{match:e=>"inlineMath"===e.type,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===Pw,runner:(e,t)=>{e.addNode("inlineMath",void 0,t.attrs.value)}}})),Pk=df("ToggleLatex",e=>()=>(t,n)=>{let{hasNode:r,pos:i,target:o}=aL(t,Px.type(e)),{selection:l,doc:s,tr:a}=t;if(!r){let t=s.textBetween(l.from,l.to),r=a.replaceSelectionWith(Px.type(e).create({value:t}));return n&&n(r.setSelection(sb.create(r.doc,l.from))),!0}let{from:c,to:u}=l;if(!o||i<0)return!1;let h=a.delete(i,i+1),d=o.attrs.value;return h=h.insertText(d,i),n&&n(h.setSelection(sv.create(h.doc,c,u+d.length-1))),!0}),PC=mB("INLINE_LATEX");zH(bR);let PS=ye({props:{config:{type:Object,required:!0},innerView:{type:Object,required:!0},updateValue:{type:Object,required:!0}},setup(e){let t=t=>{if(t&&t instanceof HTMLElement){for(;t.firstChild;)t.removeChild(t.firstChild);e.innerView.value&&t.appendChild(e.innerView.value.dom)}},n=t=>{t.preventDefault(),e.updateValue.value()};return()=>bR("div",{class:"container"},e.innerView&&bR("div",{ref:t}),bR("button",{type:"button",onPointerdown:n},bR(b6,{icon:e.config.inlineEditConfirm})))}});var PM=e=>{throw TypeError(e)},PA=(e,t,n)=>t.has(e)||PM("Cannot "+n),PT=(e,t,n)=>(PA(e,t,"read from private field"),n?n.call(e):t.get(e)),PO=(e,t,n)=>t.has(e)?PM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),PE=(e,t,n,r)=>(PA(e,t,"write to private field"),t.set(e,n),n);class PN{constructor(e,t,n){this.ctx=e,PO(this,e4),PO(this,e5),PO(this,e2),PO(this,e3,vp(null,!0)),PO(this,e7,function(e){return vp(e,!0)}(()=>{})),PO(this,e6),PO(this,e8,()=>{PT(this,e3).value&&(PT(this,e3).value.destroy(),PT(this,e3).value=null)}),PO(this,e9,e=>{let t=(()=>{if(!e.editable)return!1;let{selection:t,schema:n}=e.state;if(t.empty||!(t instanceof sb))return!1;let r=t.node;if(r.type.name!==Pw)return!1;let i=t.from,o=n.nodes.paragraph.create(null,n.text(r.attrs.value)),l=new ha(PT(this,e2),{state:sN.create({doc:o,schema:new lA({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},text:{group:"inline"}}}),plugins:[aB({"Mod-z":AG,"Mod-Z":AK,"Mod-y":AK,Enter:()=>(PT(this,e7).value(),!0)})]})});return PT(this,e3).value=l,PT(this,e7).value=()=>{let{tr:t}=e.state;t.setNodeAttribute(i,"value",l.state.doc.textContent),e.dispatch(t),requestAnimationFrame(()=>{e.focus()})},!0})();return t||PT(this,e8).call(this),t}),this.update=(e,t)=>{PT(this,e5).update(e,t)},this.destroy=()=>{PT(this,e6).unmount(),PT(this,e5).destroy(),PT(this,e4).remove()};const r=document.createElement("div");r.className="milkdown-latex-inline-edit",PE(this,e4,r),PE(this,e6,b3(PS,{config:n,innerView:PT(this,e3),updateValue:PT(this,e7)})),PT(this,e6).mount(r),PE(this,e5,new mP({debounce:0,content:PT(this,e4),shouldShow:PT(this,e9),offset:10,floatingUIOptions:{placement:"bottom"}})),PT(this,e5).update(t),PE(this,e2,document.createElement("div"))}}e4=new WeakMap,e5=new WeakMap,e2=new WeakMap,e3=new WeakMap,e7=new WeakMap,e6=new WeakMap,e8=new WeakMap,e9=new WeakMap;let PD=dm(e=>(function(e,t,n={}){return new s2(e,(e,r,i,o)=>{var l,s,a;let{tr:c}=e,u=r[1],h=r[0],d={group:u,fullMatch:h,start:i,end:o},p=null==(l=n.updateCaptured)?void 0:l.call(n,d);if(Object.assign(d,p),{group:u,fullMatch:h,start:i,end:o}=d,null===h||!u||""===u.trim())return null;let f=null==(s=n.getAttr)?void 0:s.call(n,r),m=t.createAndFill(f);return m&&(c.replaceRangeWith(t.isBlock?c.doc.resolve(i).before():i,o,m),null==(a=n.beforeDispatch)||a.call(n,{match:[h,u],start:i,end:o,tr:c})),c})})(/(?:\$)([^$]+)(?:\$)$/,Px.type(e),{getAttr:e=>{var t;return{value:null!=(t=e[1])?t:""}}})),PI=dm(e=>s6(/^\$\$[\s\n]$/,wQ.type(e),()=>({language:"LaTeX"}))),PL=dA("remarkMath",()=>LL);function P_(e){return i6(e,"math",(e,t,n)=>{let{value:r}=e;n.children.splice(t,1,{type:"code",lang:"LaTeX",value:r})})}let PR=dA("remarkMathBlock",()=>()=>P_),Pz=dw({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),PP=dv(e=>new sD({key:new s_("CREPE_PLACEHOLDER"),props:{decorations:t=>{var n,r,i;if(e.get("CrepeCtx").readonly)return null;let o=e.get(Pz.key);if("doc"===o.mode&&!((r=t.doc).childCount<=1&&!(null==(i=r.firstChild)?void 0:i.content.size))||z7(t.selection)||z6(t.selection))return null;let l=function(e,t){let{selection:n}=e;if(!n.empty)return null;let r=n.$anchor,i=r.parent;if(i.content.size>0||aD(e=>"table"===e.type.name)(r))return null;let o=r.before();return uU.node(o,o+i.nodeSize,{class:"crepe-placeholder","data-placeholder":t})}(t,null!=(n=o.text)?n:"Please enter...");return l?uJ.create(t.doc,[l]):null}}}));zH(bR,bn);let PB=ye({props:{ctx:{type:Object,required:!0},hide:{type:Function,required:!0},show:{type:Object,required:!0},selection:{type:Object,required:!0},config:{type:Object,required:!1}},setup(e){let{ctx:t,config:n}=e,r=b_(()=>(function(e,t){var n,r,i,o,l,s,a,c,u;let h=new Pn;h.addGroup("formatting","Formatting").addItem("bold",{icon:null!=(n=null==e?void 0:e.boldIcon)?n:RO,active:e=>e.get(hP).call(xO.key,wb.type(e)),onRun:e=>{e.get(hP).call(ww.key)}}).addItem("italic",{icon:null!=(r=null==e?void 0:e.italicIcon)?r:R0,active:e=>e.get(hP).call(xO.key,wp.type(e)),onRun:e=>{e.get(hP).call(wf.key)}}).addItem("strikethrough",{icon:null!=(i=null==e?void 0:e.strikethroughIcon)?i:zr,active:e=>e.get(hP).call(xO.key,SN.type(e)),onRun:e=>{e.get(hP).call(SD.key)}});let d=h.addGroup("function","Function");d.addItem("code",{icon:null!=(o=null==e?void 0:e.codeIcon)?o:RB,active:e=>e.get(hP).call(xO.key,wS.type(e)),onRun:e=>{e.get(hP).call(wM.key)}});let p=t&&zp(t).get();if((null==p?void 0:p.includes(Rk.Latex))&&d.addItem("latex",{icon:null!=(l=null==e?void 0:e.latexIcon)?l:za,active:e=>e.get(hP).call(xE.key,Px.type(e)),onRun:e=>{e.get(hP).call(Pk.key)}}),d.addItem("link",{icon:null!=(s=null==e?void 0:e.linkIcon)?s:R1,active:e=>e.get(hP).call(xO.key,wE.type(e)),onRun:e=>{e.get(hP).call(LJ.key)}}),t&&(null==p?void 0:p.includes(Rk.AI))){let n=t.get(zm.key);n.provider&&d.addItem("ai",{icon:null!=(c=null!=(a=null==e?void 0:e.aiIcon)?a:n.aiIcon)?c:RS,active:()=>!1,onRun:e=>{let t=e.get(zK.key),{from:n,to:r}=e.get(hg).state.selection;t.show(n,r)}})}return null==(u=null==e?void 0:e.buildToolbar)||u.call(e,h),h.build()})(n,t));return()=>bR(bn,null,r.value.map(n=>n.items.map(n=>{var r;let i;return bR("button",{type:"button",class:b7("toolbar-item",t&&(r=n.active,zH(e.selection.value),t.get(hb).status===dh.Created&&r(t))&&"active"),onPointerdown:(i=n.onRun,e=>{e.preventDefault(),t&&(null==i||i(t))})},bR(b6,{icon:n.icon}))})).reduce((e,t,n)=>(0===n?e.push(...t):e.push(bR("div",{class:"divider"}),...t),e),[]))}});var PF=e=>{throw TypeError(e)},PH=(e,t,n)=>t.has(e)||PF("Cannot "+n),Pq=(e,t,n)=>(PH(e,t,"read from private field"),n?n.call(e):t.get(e)),Pj=(e,t,n)=>t.has(e)?PF("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),PV=(e,t,n,r)=>(PH(e,t,"write to private field"),t.set(e,n),n);let P$=mB("CREPE_TOOLBAR");class PW{constructor(e,t,n){Pj(this,te),Pj(this,tt),Pj(this,tn),Pj(this,tr),Pj(this,ti,vd(!1)),this.update=(e,t)=>{Pq(this,te).update(e,t),Pq(this,tr).value=e.state.selection},this.destroy=()=>{Pq(this,te).destroy(),Pq(this,tn).unmount(),Pq(this,tt).remove()},this.hide=()=>{Pq(this,te).hide()};const r=document.createElement("div");r.className="milkdown-toolbar",PV(this,tr,function(e){return vp(e,!0)}(t.state.selection));const i=b3(PB,{ctx:e,hide:this.hide,config:n,selection:Pq(this,tr),show:Pq(this,ti)});i.mount(r),PV(this,tt,r),PV(this,tn,i),PV(this,te,new mP({content:Pq(this,tt),debounce:20,offset:10,shouldShow(e){let{doc:t,selection:n}=e.state,{empty:i,from:o,to:l}=n,s=!t.textBetween(o,l).length&&n instanceof sv,a=!(n instanceof sv),c=e.dom.getRootNode().activeElement,u=r.contains(c),h=!e.hasFocus()&&!u,d=!e.editable;return!h&&!a&&!i&&!s&&!d}})),Pq(this,te).onShow=()=>{Pq(this,ti).value=!0},Pq(this,te).onHide=()=>{Pq(this,ti).value=!1},this.update(t)}}te=new WeakMap,tt=new WeakMap,tn=new WeakMap,tr=new WeakMap,ti=new WeakMap;let PU=[{label:"Paragraph",level:null},{label:"Heading 1",level:1},{label:"Heading 2",level:2},{label:"Heading 3",level:3},{label:"Heading 4",level:4},{label:"Heading 5",level:5},{label:"Heading 6",level:6}];function PG(e,t){if(e.get(hP).call(xO.key,t))return!0;let{state:n}=e.get(hg);if(n.storedMarks)return n.storedMarks.some(e=>e.type===t);if(n.selection instanceof sv){let{$cursor:e}=n.selection;if(e)return e.marks().some(e=>e.type===t)}return!1}zH(bR,bn);let PK=ye({props:{ctx:{type:Object,required:!0},version:{type:Object,required:!0},config:{type:Object,required:!1}},setup(e){let{ctx:t,config:n}=e,r=vd(null);function i(){return t.get(hb).status===dh.Created}function o(){zH(e.version.value)}let l=e=>{e.target.closest(".top-bar-heading-selector")||(r.value=null)};yf(()=>{window.addEventListener("pointerdown",l)}),yy(()=>{window.removeEventListener("pointerdown",l)});let s=b_(()=>{var e,r,i,o,l,s,a,c,u,h,d,p,f,m,g,y,b;let w,x,k,C,S,M,A,T;return x=null==(w=t&&zp(t).get())?void 0:w.includes(Rk.Latex),k=null==w?void 0:w.includes(Rk.ImageBlock),C=null==w?void 0:w.includes(Rk.Table),(S=new Pn).addGroup("heading","Heading").addItem("heading-selector",{...(y=null==n?void 0:n.headingOptions,b=null==n?void 0:n.chevronDownIcon,{icon:"",active:()=>!1,selector:{chevronIcon:null!=b?b:R_,activeLabel:e=>(function(e,t){var n,r;let i=null!=t?t:PU,{$from:o}=e.get(hg).state.selection,l=o.parent,s=null!=(n=i.find(e=>null===e.level))?n:i[0];if(l.type===wj.type(e)){let e=l.attrs.level;return null!=(r=i.find(t=>t.level===e))?r:s}return s})(e,M).label,options:(M=null!=y?y:PU).map(e=>({label:e.label,onSelect:t=>(function(e,t){let n=e.get(hP);if(null==t){let t=wz.type(e);n.call(xD.key,{nodeType:t})}else{let r=wj.type(e);n.call(xD.key,{nodeType:r,attrs:{level:t}})}})(t,e.level)}))}})}),S.addGroup("formatting","Formatting").addItem("bold",{icon:null!=(e=null==n?void 0:n.boldIcon)?e:RO,active:e=>PG(e,wb.type(e)),onRun:e=>{e.get(hP).call(ww.key)}}).addItem("italic",{icon:null!=(r=null==n?void 0:n.italicIcon)?r:R0,active:e=>PG(e,wp.type(e)),onRun:e=>{e.get(hP).call(wf.key)}}).addItem("strikethrough",{icon:null!=(i=null==n?void 0:n.strikethroughIcon)?i:zr,active:e=>PG(e,SN.type(e)),onRun:e=>{e.get(hP).call(SD.key)}}).addItem("code",{icon:null!=(o=null==n?void 0:n.codeIcon)?o:RB,active:e=>PG(e,wS.type(e)),onRun:e=>{let t=e.get(hg),{state:n}=t;if(n.selection.empty){let r=wS.type(e);PG(e,r)?t.dispatch(n.tr.removeStoredMark(r)):t.dispatch(n.tr.addStoredMark(r.create()))}else e.get(hP).call(wM.key)}}),S.addGroup("list","List").addItem("bullet-list",{icon:null!=(l=null==n?void 0:n.bulletListIcon)?l:RN,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xl.type(e);t.call(xI.key,{nodeType:n})}}).addItem("ordered-list",{icon:null!=(s=null==n?void 0:n.orderedListIcon)?s:R2,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xh.type(e);t.call(xI.key,{nodeType:n})}}).addItem("task-list",{icon:null!=(a=null==n?void 0:n.taskListIcon)?a:zl,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xg.type(e);t.call(xI.key,{nodeType:n,attrs:{checked:!1}})}}),(A=S.addGroup("insert","Insert")).addItem("link",{icon:null!=(c=null==n?void 0:n.linkIcon)?c:R1,active:e=>PG(e,wE.type(e)),onRun:e=>{let t=e.get(hg),{state:n}=t,r=wE.type(e);n.selection.empty&&PG(e,r)?t.dispatch(n.tr.removeStoredMark(r)):e.get(hP).call(LJ.key)}}),k&&A.addItem("image",{icon:null!=(u=null==n?void 0:n.imageIcon)?u:RQ,active:()=>!1,onRun:e=>{let t=e.get(hP),n=ki.type(e);t.call(xL.key,{nodeType:n})}}),C&&A.addItem("table",{icon:null!=(h=null==n?void 0:n.tableIcon)?h:zi,active:()=>!1,onRun:e=>{let t=e.get(hP),{from:n}=e.get(hg).state.selection;t.call(xL.key,{nodeType:SH(e,3,3)}),t.call(x_.key,{pos:n})}}),(T=S.addGroup("block","Block")).addItem("code-block",{icon:null!=(d=null==n?void 0:n.codeBlockIcon)?d:RF,active:()=>!1,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xD.key,{nodeType:n})}}),x&&T.addItem("math",{icon:null!=(p=null==n?void 0:n.mathIcon)?p:za,active:()=>!1,onRun:e=>{let t=e.get(hP),n=wQ.type(e);t.call(xL.key,{nodeType:n,attrs:{language:"LaTeX"}})}}),S.addGroup("more","More").addItem("quote",{icon:null!=(f=null==n?void 0:n.quoteIcon)?f:R7,active:()=>!1,onRun:e=>{let t=e.get(hP),n=wK.type(e);t.call(xI.key,{nodeType:n})}}).addItem("hr",{icon:null!=(m=null==n?void 0:n.hrIcon)?m:Rj,active:()=>!1,onRun:e=>{let t=e.get(hP),n=xn.type(e);t.call(xL.key,{nodeType:n})}}),null==(g=null==n?void 0:n.buildTopBar)||g.call(n,S),S.build()});return()=>{let e=i()?t.get(hg):null;return e&&!e.editable?null:bR("div",{class:"top-bar-inner"},s.value.map(e=>e.items.map(e=>{var n,l,s,a,c;let u;if(e.selector){let c,u;return n=e.key,l=e.selector,c=r.value===n,bR("div",{key:n,class:"top-bar-heading-selector"},bR("button",{type:"button",class:"top-bar-heading-button",onPointerdown:e=>{e.preventDefault(),e.stopPropagation(),r.value=r.value===n?null:n}},bR("span",{class:"top-bar-heading-label"},(o(),u=i()?l.activeLabel(t):null!=(a=null==(s=l.options[0])?void 0:s.label)?a:"")),l.chevronIcon&&bR("span",{class:"top-bar-chevron"},bR(b6,{icon:l.chevronIcon}))),c&&bR("div",{class:"top-bar-heading-dropdown"},l.options.map((e,i)=>bR("button",{key:`${n}-${i}`,type:"button",class:b7("top-bar-heading-option",u===e.label&&"active"),onPointerdown:n=>{n.preventDefault(),n.stopPropagation(),r.value=null,e.onSelect(t)}},e.label))))}return e.onRun?bR("button",{key:e.key,type:"button",class:b7("top-bar-item",(c=e.active,o(),!!i()&&c(t)&&"active")),onPointerdown:(u=e.onRun,e=>{e.preventDefault(),t&&u(t)})},bR(b6,{icon:e.icon})):null})).reduce((e,t,n)=>{var r,i;if(0===n)e.push(...t);else{let o=null!=(i=null==(r=s.value[n])?void 0:r.key)?i:n;e.push(bR("div",{key:`divider-${o}`,class:"top-bar-divider"}),...t)}return e},[]))}}});var PJ=e=>{throw TypeError(e)},PZ=(e,t,n)=>t.has(e)||PJ("Cannot "+n),PY=(e,t,n)=>(PZ(e,t,"read from private field"),n?n.call(e):t.get(e)),PX=(e,t,n)=>t.has(e)?PJ("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),PQ=(e,t,n,r)=>(PZ(e,t,"write to private field"),t.set(e,n),n);let P0=new s_("CREPE_TOP_BAR");class P1{constructor(e,t,n){PX(this,to),PX(this,tl),PX(this,ts),this.update=(e,t)=>{PY(this,to).style.display=e.editable?"":"none",PY(this,ts).value++},this.destroy=()=>{PY(this,tl).unmount(),PY(this,to).remove()},PQ(this,ts,vd(0));const r=document.createElement("div");r.className="milkdown-top-bar";const i=b3(PK,{ctx:e,config:n,version:PY(this,ts)});i.mount(r),PQ(this,to,r),PQ(this,tl,i);const o=t.dom.parentElement;o&&o.insertBefore(r,o.firstChild),this.update(t)}}to=new WeakMap,tl=new WeakMap,ts=new WeakMap;let P4=dw({view:()=>({update:()=>{},destroy:()=>{}})},"topBarConfig"),P5=dv(e=>new sD({key:P0,view:e.get(P4.key).view}));var P2=e=>{throw TypeError(e)},P3=(e,t,n)=>t.has(e)||P2("Cannot "+n),P7=(e,t,n)=>(P3(e,t,"read from private field"),n?n.call(e):t.get(e)),P6=(e,t,n)=>t.has(e)?P2("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),P8=(e,t,n,r)=>(P3(e,t,"write to private field"),t.set(e,n),n);class P9{constructor({root:e,defaultValue:t=""}={}){var n;P6(this,ta),P6(this,tc),P6(this,tu,!0),this.addFeature=(e,t)=>(e(P7(this,ta),t),this),this.create=()=>P7(this,ta).create(),this.destroy=()=>P7(this,ta).destroy(),this.setReadonly=e=>(P8(this,tu,!e),P7(this,ta).action(t=>{P7(this,ta).status===dh.Created&&t.get(hg).setProps({editable:()=>!e})}),this),this.getMarkdown=()=>P7(this,ta).action(e=>{let t=e.get(hg),n=(e.get(hD),e.get(h0));return n(t.state.doc)}),this.on=e=>(P7(this,ta).status!==dh.Created?P7(this,ta).config(t=>{e(t.get(Rp))}):P7(this,ta).action(t=>{e(t.get(Rp))}),this),P8(this,tc,null!=(n="string"==typeof e?document.querySelector(e):e)?n:document.body),P8(this,ta,dd.make().config(e=>{e.inject(zd,this),e.inject(zh,[])}).config(e=>{e.set(dl,P7(this,tc)),e.set(h4,t),e.set(di,{editable:()=>P7(this,tu)}),e.update(Rc.key,e=>({...e,size:4})),e.update(Rb.key,e=>({...e,uploader:async(e,t,n)=>{let r=zp(n).get().includes(Rk.ImageBlock),i=r?t.nodes["image-block"]:t.nodes.image;if(!i)return[];let o=r?n.get(x3.key).onUpload:void 0,l=[];for(let t=0;t<e.length;t++){let n=e.item(t);n&&n.type.includes("image")&&l.push(n)}return await Promise.all(l.map(async e=>{let t=o?await o(e):URL.createObjectURL(e);return i.createAndFill({src:t})}))}}))}).use(xJ).use(Rm).use(Ra).use(Rh).use(Ry).use(Rt).use(Rx).use(Mg))}get editor(){return P7(this,ta)}get readonly(){return!P7(this,tu)}}ta=new WeakMap,tc=new WeakMap,tu=new WeakMap;class Be extends P9{constructor({features:e={},featureConfigs:t={},...n}={}){super(n);const r=n$(t,zu);Object.entries({...RC,...e}).filter(([,e])=>e).map(([e])=>e).forEach(e=>{let t=r[e];!function(e,t,n){switch(e){case Rk.CodeMirror:return((e,t={})=>{e.config(zf(Rk.CodeMirror)).config(e=>{let{languages:n=[],theme:r}=t,i=[nJ.keymap.of(AN.concat(AD)),Ok];r&&i.push(r),t.extensions&&i.push(...t.extensions),e.update(A1.key,e=>{var r;return{extensions:i,languages:n,expandIcon:t.expandIcon||R_,searchIcon:t.searchIcon||R9,clearSearchIcon:t.clearSearchIcon||RP,searchPlaceholder:t.searchPlaceholder||"Search language",copyText:t.copyText||"Copy",copyIcon:t.copyIcon||Rq,onCopy:t.onCopy||(()=>{}),noResultText:t.noResultText||"No result",renderLanguage:t.renderLanguage||e.renderLanguage,renderPreview:t.renderPreview||e.renderPreview,previewToggleButton:e=>{var n,r;return[(null==(n=t.previewToggleIcon)?void 0:n.call(t,e))||(e?R$:zc),(null==(r=t.previewToggleText)?void 0:r.call(t,e))||(e?"Edit":"Hide")].map(e=>e.trim()).join(" ")},previewLabel:t.previewLabel||e.previewLabel,previewLoading:t.previewLoading||e.previewLoading,previewOnlyByDefault:null!=(r=t.previewOnlyByDefault)?r:e.previewOnlyByDefault}})}).use(Ti)})(t,n);case Rk.ListItem:return t.config(zf(Rk.ListItem)).config(e=>{e.set(_O.key,{renderLabel:({label:e,listType:t,checked:r})=>{var i,o,l;return null==r?"bullet"===t?null!=(i=null==n?void 0:n.bulletIcon)?i:RE:e:r?null!=(o=null==n?void 0:n.checkBoxCheckedIcon)?o:RI:null!=(l=null==n?void 0:n.checkBoxUncheckedIcon)?l:RL}})}).use(_L);case Rk.LinkTooltip:return t.config(zf(Rk.LinkTooltip)).config(_w).config(e=>{e.update(LK.key,e=>{var t,r,i,o,l,s;return{...e,linkIcon:null!=(t=null==n?void 0:n.linkIcon)?t:Rq,editButton:null!=(r=null==n?void 0:n.editButton)?r:R$,removeButton:null!=(i=null==n?void 0:n.removeButton)?i:R6,confirmButton:null!=(o=null==n?void 0:n.confirmButton)?o:RH,inputPlaceholder:null!=(l=null==n?void 0:n.inputPlaceholder)?l:"Paste link...",onCopyLink:null!=(s=null==n?void 0:n.onCopyLink)?s:()=>{}}})}).use(_x);case Rk.ImageBlock:return t.config(zf(Rk.ImageBlock)).config(e=>{e.update(OZ.key,e=>{var t,r,i,o,l,s;return{uploadButton:null!=(t=null==n?void 0:n.inlineUploadButton)?t:"Upload",imageIcon:null!=(r=null==n?void 0:n.inlineImageIcon)?r:RQ,confirmButton:null!=(i=null==n?void 0:n.inlineConfirmButton)?i:RH,uploadPlaceholderText:null!=(o=null==n?void 0:n.inlineUploadPlaceholderText)?o:"or paste link",onUpload:null!=(s=null!=(l=null==n?void 0:n.inlineOnUpload)?l:null==n?void 0:n.onUpload)?s:e.onUpload,proxyDomURL:null==n?void 0:n.proxyDomURL}}),e.update(x3.key,e=>{var t,r,i,o,l,s,a,c,u;return{uploadButton:null!=(t=null==n?void 0:n.blockUploadButton)?t:"Upload file",imageIcon:null!=(r=null==n?void 0:n.blockImageIcon)?r:RQ,captionIcon:null!=(i=null==n?void 0:n.blockCaptionIcon)?i:RD,confirmButton:null!=(o=null==n?void 0:n.blockConfirmButton)?o:"Confirm",captionPlaceholderText:null!=(l=null==n?void 0:n.blockCaptionPlaceholderText)?l:"Write Image Caption",uploadPlaceholderText:null!=(s=null==n?void 0:n.blockUploadPlaceholderText)?s:"or paste link",onUpload:null!=(c=null!=(a=null==n?void 0:n.blockOnUpload)?a:null==n?void 0:n.onUpload)?c:e.onUpload,proxyDomURL:null==n?void 0:n.proxyDomURL,onImageLoadError:null!=(u=null==n?void 0:n.onImageLoadError)?u:e.onImageLoadError,maxWidth:null==n?void 0:n.maxWidth,maxHeight:null==n?void 0:n.maxHeight}})}).use(kv).use(O5);case Rk.Cursor:var r,i;let o,l;if(t.config(zf(Rk.Cursor)).config(e=>{e.update(OR.key,()=>{var e,t;return{class:"crepe-drop-cursor",width:null!=(e=null==n?void 0:n.width)?e:4,color:null!=(t=null==n?void 0:n.color)&&t}})}).use(OH),(null==n?void 0:n.virtual)===!1)return;let s=(o=!1,l="u"<typeof document?null:document.createElement("div"),new sD({key:Oq,view:e=>{let t;!0!==o&&function(e,t){for(let[n,r]of Object.entries(e.marks))!1!==r.spec.inclusive||t.includes(n)||console.warn(`[prosemirror-virtual-cursor] Virtual cursor does not work well with marks that have inclusive set to false. Please consider removing the inclusive option from the "${n}" mark or adding it to the "skipWarning" option.`)}(e.state.schema,o||[]);let n=e.dom.ownerDocument,r=l=l||document.createElement("div"),i=()=>{!function(e,t){var n,r;if(!e||!e.dom||e.isDestroyed||!t)return;let{state:i,dom:o}=e,{selection:l}=i;if(!OV(l))return;let s=function(e,t){var n;let r=window.getSelection();if(!r||!r.rangeCount)return null;let i=null==(n=null==r?void 0:r.getRangeAt(0))?void 0:n.cloneRange();if(!i)return null;i.collapse(t);let o=i.getClientRects(),l=(null==o?void 0:o.length)?o[o.length-1]:null;return(null==l?void 0:l.height)?l:e.coordsAtPos(e.state.selection.head)}(e,l.$head===l.$from);if(!s)return;let a=o.getBoundingClientRect(),c="prosemirror-virtual-cursor",u=i.selection.$head,[h,d]=Oj(u),p=i.storedMarks||u.marks();l.$cursor&&h&&d&&p&&!o7.sameSet(h,d)&&(o7.sameSet(h,p)?c+=" prosemirror-virtual-cursor-left":o7.sameSet(d,p)&&(c+=" prosemirror-virtual-cursor-right")),t.className=c,r="prosemirror-virtual-cursor-animation",(n=t).classList.remove(r),n.offsetWidth,n.classList.add(r),t.style.height=`${s.bottom-s.top}px`,t.style.left=`${s.left-a.left}px`,t.style.top=`${s.top-a.top}px`}(e,r)};return window.ResizeObserver&&(t=new window.ResizeObserver(()=>i())).observe(e.dom),n.addEventListener("selectionchange",i),{update:()=>{i()},destroy:()=>{n.removeEventListener("selectionchange",i),t&&t.unobserve(e.dom)}}},props:{handleKeyDown:(e,t)=>{var n;let{selection:r}=e.state;if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||t.isComposing||!["ArrowLeft","ArrowRight"].includes(t.key)||!OV(r)||!r.empty)return!1;let i=r.$head,[o,l]=Oj(i),s=e.state.storedMarks||i.marks();if(o&&l&&!o7.sameSet(o,l)){if("ArrowLeft"===t.key&&!o7.sameSet(o,s))return e.dispatch(e.state.tr.setStoredMarks(o)),!0;if("ArrowRight"===t.key&&!o7.sameSet(l,s))return e.dispatch(e.state.tr.setStoredMarks(l)),!0}return"ArrowLeft"===t.key&&1===i.textOffset?(e.dispatch(e.state.tr.setSelection(sv.create(e.state.doc,i.pos-1)).setStoredMarks(i.marks())),!0):"ArrowRight"===t.key&&i.textOffset+1===(null==(n=i.parent.maybeChild(i.index()))?void 0:n.nodeSize)&&(e.dispatch(e.state.tr.setSelection(sv.create(e.state.doc,i.pos+1)).setStoredMarks(i.marks())),!0)},decorations:e=>{if(l&&OV(e.selection)&&e.selection.empty)return uJ.create(e.doc,[uU.widget(0,l,{key:"prosemirror-virtual-cursor"})])},attributes:{class:"virtual-cursor-enabled"}}}));t.use(dv(()=>s));return;case Rk.BlockEdit:return t.config(zf(Rk.BlockEdit)).config(e=>{e.set(b9.key,{filterNodes:e=>!aD(e=>["table","blockquote","math_inline"].includes(e.type.name))(e)}),e.set(ws.key,{view:()=>new Py(e,n)})}).config(e=>{e.set(Pc.key,{view:t=>new Ph(e,t,n)})}).use(Pu).use(ws).use(Pc);case Rk.Placeholder:return t.config(zf(Rk.Placeholder)).config(e=>{n&&e.update(Pz.key,e=>({...e,...n}))}).use(PP).use(Pz);case Rk.Toolbar:return t.config(zf(Rk.Toolbar)).config(e=>{e.set(P$.key,{view:t=>new PW(e,t,n)})}).use(P$);case Rk.Table:return t.config(zf(Rk.Table)).config(e=>{e.update(_W.key,e=>({...e,renderButton:e=>{var t,r,i,o,l,s,a,c,u;switch(e){case"add_row":return null!=(t=null==n?void 0:n.addRowIcon)?t:R3;case"add_col":return null!=(r=null==n?void 0:n.addColIcon)?r:R3;case"delete_row":return null!=(i=null==n?void 0:n.deleteRowIcon)?i:R6;case"delete_col":return null!=(o=null==n?void 0:n.deleteColIcon)?o:R6;case"align_col_left":return null!=(l=null==n?void 0:n.alignLeftIcon)?l:RA;case"align_col_center":return null!=(s=null==n?void 0:n.alignCenterIcon)?s:RM;case"align_col_right":return null!=(a=null==n?void 0:n.alignRightIcon)?a:RT;case"col_drag_handle":return null!=(c=null==n?void 0:n.colDragHandleIcon)?c:RV;case"row_drag_handle":return null!=(u=null==n?void 0:n.rowDragHandleIcon)?u:RV}}}))}).use(_9);case Rk.Latex:return t.config(zf(Rk.Latex)).config(e=>{if(!zp(e).get().includes(Rk.CodeMirror))throw Error("You need to enable CodeMirror to use LaTeX feature");e.update(A1.key,e=>({...e,renderPreview:(t,r,i)=>"latex"===t.toLowerCase()&&r.length>0?LA(r,{...null==n?void 0:n.katexOptions,throwOnError:!1,displayMode:!0}).toMarkup():(0,e.renderPreview)(t,r,i)})),e.set(PC.key,{view:t=>{var r;return new PN(e,t,{inlineEditConfirm:null!=(r=null==n?void 0:n.inlineEditConfirm)?r:RH,...n})}})}).use(PL).use(PR).use(Px).use(PC).use(PD).use(PI).use(Pb).use(Pk);case Rk.TopBar:return t.config(zf(Rk.TopBar)).config(e=>{e.set(P4.key,{view:t=>new P1(e,t,n)})}).use(P4).use(P5);case Rk.AI:let a,c;return a=null!=(r=null==n?void 0:n.diff)?r:{},c=null!=(i=null==n?void 0:n.streaming)?i:{},t.config(zf(Rk.AI)).config(e=>{e.update(dV.key,e=>{var t;return{...e,ignoreAttrs:null!=(t=a.ignoreAttrs)?t:z3}});let{ignoreAttrs:t,...n}=a;e.update(d9.key,e=>{var t;return{...e,customBlockTypes:null!=(t=n.customBlockTypes)?t:z2,...n}})}).use(d1).use(pp).config(e=>{e.update(pm.key,e=>{var t;return{...e,...c,ignoreAttrs:null!=(t=c.ignoreAttrs)?t:z3,...(null==n?void 0:n.diffReviewOnEnd)!==void 0?{diffReviewOnEnd:n.diffReviewOnEnd}:{}}})}).use(pA).config(e=>{e.update(zm.key,e=>{var t;return{...e,...(null==n?void 0:n.provider)!==void 0?{provider:n.provider}:{},...(null==n?void 0:n.buildContext)!==void 0?{buildContext:n.buildContext}:{},diffReviewOnEnd:null!=(t=null==n?void 0:n.diffReviewOnEnd)?t:e.diffReviewOnEnd,...(null==n?void 0:n.onError)!==void 0?{onError:n.onError}:{},...(null==n?void 0:n.aiIcon)!==void 0?{aiIcon:n.aiIcon}:{}}})}).use(zm).use(zg).use(zw).use(zx).config(e=>{var t,r,i,o,l,s,a,c,u,h,d,p,f;let m,g=((m=new zF).addItem("improve",{icon:RS,label:"Improve writing",streamingLabel:"Improving writing",prompt:"Improve the writing while preserving the original meaning."}).addItem("grammar",{icon:RU,label:"Fix grammar & spelling",streamingLabel:"Fixing grammar & spelling",prompt:"Fix any grammar and spelling errors without changing the meaning."}).addItem("shorter",{icon:zn,label:"Make shorter",streamingLabel:"Making shorter",prompt:"Make this shorter while preserving the key information."}).addItem("longer",{icon:R4,label:"Make longer",streamingLabel:"Expanding",prompt:"Expand this with more detail and examples."}),m.addSubmenu("tone",{icon:R$,label:"Change tone…",title:"Change tone",searchPlaceholder:"Search tones…"},e=>{for(let[t,n]of[["professional","Professional"],["casual","Casual"],["confident","Confident"],["friendly","Friendly"],["direct","Direct"],["formal","Formal"]])e.addItem(t,{icon:R$,label:n,streamingLabel:"Adjusting tone",prompt:`Rewrite this in a ${n.toLowerCase()} tone.`})}),m.addSubmenu("translate",{icon:zs,label:"Translate…",title:"Translate",searchPlaceholder:"Search languages…"},e=>{for(let[t,n,r]of[["english","English","English"],["chinese","Chinese","Chinese (Simplified)"],["japanese","Japanese","Japanese"],["korean","Korean","Korean"],["spanish","Spanish","Spanish"],["french","French","French"],["german","German","German"]])e.addItem(t,{icon:zs,label:n,streamingLabel:`Translating to ${n}`,prompt:`Translate this to ${r}.`})}),null==(t=null==n?void 0:n.buildAISuggestions)||t.call(n,m),{placeholder:null!=(r=null==n?void 0:n.instructionPlaceholder)?r:"Tell AI what to do with the selection…",chrome:{aiIcon:null!=(i=null==n?void 0:n.aiIcon)?i:RS,sendIcon:null!=(o=null==n?void 0:n.sendIcon)?o:ze,sendPromptIcon:null!=(l=null==n?void 0:n.sendPromptIcon)?l:zt,enterKeyIcon:null!=(s=null==n?void 0:n.enterKeyIcon)?s:RW,chevronLeftIcon:null!=(a=null==n?void 0:n.chevronLeftIcon)?a:RR,chevronRightIcon:null!=(c=null==n?void 0:n.chevronRightIcon)?c:Rz,suggestionsHeaderLabel:null!=(u=null==n?void 0:n.suggestionsHeaderLabel)?u:"SUGGESTIONS",sendAsPromptHeaderLabel:null!=(h=null==n?void 0:n.sendAsPromptHeaderLabel)?h:"SEND AS PROMPT",sendAsPromptLabel:null!=(d=null==n?void 0:n.sendAsPromptLabel)?d:"Ask AI:",submitButtonLabel:null!=(p=null==n?void 0:n.submitButtonLabel)?p:"Send prompt",listboxLabel:null!=(f=null==n?void 0:n.listboxLabel)?f:"AI suggestions"},suggestions:m.build()}),y=null;e.update(zK.key,e=>({...e,show:(e,t)=>{null==y||y.show(e,t)}})),e.set(zJ.key,{view:t=>y=new zG(e,t,g)})}).use(zK).use(zJ).use(function(e={}){var t,n;let{config:r}=e,i=null!=(t=null==r?void 0:r.fallbackLabel)?t:"Generating",o=null!=(n=null==r?void 0:r.cancelHint)?n:"Esc to cancel";return dv(e=>{let t=null;function n(){t&&(t.destroy(),t=null)}return new sD({key:z4,state:{init:()=>uJ.empty,apply(r,l,s,a){let c=pw.getState(a);if(!(null==c?void 0:c.active)||null==c.insertEndPos)return n(),uJ.empty;if(r.getMeta(pw)||r.docChanged){var u;let n,r;return u=a.doc,n=Math.min(c.insertEndPos,u.content.size),r=uU.widget(n,(t?t.setLabel(e):t=new z5(e,i,o),t).dom,{side:1,key:"ai-streaming-indicator"}),uJ.create(u,[r])}return l.map(r.mapping,r.doc)}},view:()=>({destroy(){n()}}),props:{decorations(e){var t;return null!=(t=z4.getState(e))?t:uJ.empty},handleKeyDown(t,n){var r;if("Escape"!==n.key)return!1;let i=e.get(hP);return e.get(zg.key).abortController?(n.preventDefault(),i.call(zx.key,{keep:!0}),!0):null!=(r=pw.getState(t.state))&&!!r.active&&(n.preventDefault(),i.call(pM.key,{keep:!0}),!0)}}})})}({config:null==n?void 0:n.streamingIndicator})).use(function(e={}){let t=function(e){var t,n,r,i,o,l,s;let{config:a,enterKeyIcon:c}=e;return{retryLabel:null!=(t=null==a?void 0:a.retryLabel)?t:"Retry",rejectAllLabel:null!=(n=null==a?void 0:a.rejectAllLabel)?n:"Reject all",acceptAllLabel:null!=(r=null==a?void 0:a.acceptAllLabel)?r:"Accept all",retryIcon:null!=(i=null==a?void 0:a.retryIcon)?i:R8,rejectIcon:null!=(o=null==a?void 0:a.rejectIcon)?o:RP,acceptIcon:null!=(l=null==a?void 0:a.acceptIcon)?l:RH,enterKeyIcon:null!=c?c:RW,modSymbol:null!=(s=null==a?void 0:a.modSymbol)?s:zI}}(e);return dv(e=>new sD({key:zD,view:n=>new zN(e,n,t),props:{handleKeyDown(t,n){var r;return"Enter"===n.key&&!!(n.metaKey||n.ctrlKey)&&!!(null==(r=d$.getState(t.state))?void 0:r.active)&&!!e.get(zg.key).diffOwnedByAI&&(n.preventDefault(),e.get(hP).call(dQ.key),!0)}}}))}({config:null==n?void 0:n.diffActions,enterKeyIcon:null==n?void 0:n.enterKeyIcon}))}}(e,this.editor,t)})}}Be.Feature=Rk;let Bt=(0,td.forwardRef)(({content:e,readOnly:t,onChange:n,className:r},i)=>{let o=(0,td.useRef)(null),l=(0,td.useRef)(null),s=(0,td.useRef)(n),[a,c]=(0,td.useState)(!1);return(0,td.useEffect)(()=>{s.current=n},[n]),(0,td.useImperativeHandle)(i,()=>({setMarkdown:e=>{l.current&&a&&l.current.editor.action(dT(e))},getMarkdown:()=>l.current?.getMarkdown()||""})),(0,td.useEffect)(()=>{if(!o.current)return;let n=new Be({root:o.current,defaultValue:e,featureConfigs:{[Be.Feature.Placeholder]:{text:"输入 / 以使用命令..."},[Be.Feature.ImageBlock]:{inlineUploadButton:"上传图片",inlineUploadPlaceholderText:"或粘贴图片链接...",blockUploadButton:"上传图片",blockUploadPlaceholderText:"或粘贴图片链接...",blockCaptionPlaceholderText:"添加标题..."},[Be.Feature.BlockEdit]:{textGroup:{label:"基础",text:{label:"文本"},h1:{label:"一级标题"},h2:{label:"二级标题"},h3:{label:"三级标题"},h4:{label:"四级标题"},h5:{label:"五级标题"},h6:{label:"六级标题"},quote:{label:"引用"},divider:{label:"分割线"}},listGroup:{label:"列表",bulletList:{label:"无序列表"},orderedList:{label:"有序列表"},taskList:{label:"任务列表"}},advancedGroup:{label:"高级",image:{label:"图片"},codeBlock:{label:"代码块"},table:{label:"表格"},math:{label:"数学公式"}}}}});n.editor.config(e=>{e.set(wO.key,()=>({rel:"noopener noreferrer",target:"_blank"}))}),n.on(e=>{e.markdownUpdated((e,t,n)=>{s.current&&t!==n&&s.current(t)})});let r=!1;return n.create().then(()=>{r?n.destroy():(l.current=n,n.setReadonly(!!t),c(!0))}),()=>{r=!0,l.current&&(l.current.destroy(),l.current=null)}},[]),(0,td.useEffect)(()=>{l.current&&a&&l.current.setReadonly(!!t)},[t,a]),(0,td.useEffect)(()=>{l.current&&a&&e!==l.current.getMarkdown()&&l.current.editor.action(dT(e))},[e,a]),(0,th.jsx)("div",{ref:o,className:r||"milkdown-editor"})});Bt.displayName="MilkdownEditor",e.s(["MilkdownEditor",0,Bt],34859)},36975,e=>{e.n(e.i(34859))}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,96699,e=>{"use strict";let t=(0,e.i(56420).default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);e.s(["Moon",0,t],96699)},35965,e=>{"use strict";let t=(0,e.i(56420).default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);e.s(["Sun",0,t],35965)},66627,e=>{"use strict";let t=(0,e.i(56420).default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);e.s(["Wifi",0,t],66627)},66595,e=>{"use strict";let t=(0,e.i(56420).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);e.s(["Search",0,t],66595)},31214,e=>{"use strict";let t=(0,e.i(56420).default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);e.s(["Cloud",0,t],31214)},68590,e=>{"use strict";let t=(0,e.i(56420).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);e.s(["MessageSquare",0,t],68590)},51921,e=>{"use strict";let t=(0,e.i(56420).default)("music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);e.s(["Music",0,t],51921)},30274,e=>{"use strict";let t=(0,e.i(56420).default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);e.s(["Send",0,t],30274)},40983,e=>{"use strict";var t=e.i(18050),n=e.i(71645),i=e.i(22016),r=e.i(96699),a=e.i(35965);function l({size:e=24}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",fill:"var(--accent)",opacity:"0.4"}),(0,t.jsx)("rect",{x:"14",y:"2",width:"8",height:"8",rx:"2",fill:"var(--accent)",opacity:"0.7"}),(0,t.jsx)("rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",fill:"var(--accent)",opacity:"0.7"}),(0,t.jsx)("rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",fill:"var(--accent)"})]})}function s(){let[e,s]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=localStorage.getItem("theme"),t=window.matchMedia("(prefers-color-scheme: dark)").matches;("dark"===e||!e&&t)&&s(!0)},[]),(0,n.useEffect)(()=>{document.documentElement.setAttribute("data-theme",e?"dark":"light"),localStorage.setItem("theme",e?"dark":"light")},[e]),(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("nav",{className:"mkt-nav",children:(0,t.jsxs)("div",{className:"mkt-nav-inner",children:[(0,t.jsxs)(i.default,{href:"/",className:"mkt-nav-logo",children:[(0,t.jsx)(l,{}),"MOST PEOPLE"]}),(0,t.jsxs)("div",{className:"mkt-nav-cta",children:[(0,t.jsx)("button",{className:"mkt-theme-toggle",onClick:()=>s(!e),"aria-label":"切换主题",children:e?(0,t.jsx)(a.Sun,{size:16}):(0,t.jsx)(r.Moon,{size:16})}),(0,t.jsx)(i.default,{href:"/app/",className:"btn btn-primary",children:"开始使用"})]})]})})})}let o=[{href:"/",label:"关于"},{href:"/ping/",label:"网络"},{href:"https://github.com/most-people/most",label:"GitHub",external:!0}];function c(){return(0,t.jsx)("footer",{className:"mkt-footer",children:(0,t.jsx)("div",{className:"mkt-container",children:(0,t.jsxs)("div",{className:"mkt-footer-inner",children:[(0,t.jsx)("div",{className:"mkt-footer-links",children:o.map(e=>(0,t.jsx)(i.default,{href:e.href,...e.external?{target:"_blank",rel:"noopener noreferrer"}:{},children:e.label},e.href))}),(0,t.jsxs)("span",{className:"mkt-footer-copy",children:["© ",new Date().getFullYear()," MOST PEOPLE · MIT License"]})]})})})}e.s(["MarketingLayout",0,function({children:e}){return(0,t.jsxs)("div",{className:"mkt-layout",children:[(0,t.jsx)(s,{}),(0,t.jsx)("main",{className:"mkt-layout-main",children:e}),(0,t.jsx)(c,{})]})}],40983)},23449,e=>{"use strict";let t;var n,i=e.i(18050),r=e.i(71645);let a=Object.freeze({left:0,top:0,width:16,height:16}),l=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),s=Object.freeze({...a,...l}),o=Object.freeze({...s,body:"",hidden:!1});function c(e,t){let n,i,r=(n={},!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0),(i=((e.rotate||0)+(t.rotate||0))%4)&&(n.rotate=i),n);for(let n in o)n in l?n in e&&!(n in r)&&(r[n]=l[n]):n in t?r[n]=t[n]:n in e&&(r[n]=e[n]);return r}function u(e,t){let n,i,r,a=[];if("object"!=typeof e||"object"!=typeof e.icons)return a;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),a.push(e)});let l=(n=e.icons,i=e.aliases||Object.create(null),r=Object.create(null),Object.keys(n).concat(Object.keys(i)).forEach(function e(t){if(n[t])return r[t]=[];if(!(t in r)){r[t]=null;let n=i[t]&&i[t].parent,a=n&&e(n);a&&(r[t]=[n].concat(a))}return r[t]}),r);for(let n in l){let i=l[n];i&&(t(n,function(e,t,n){let i=e.icons,r=e.aliases||Object.create(null),a={};function l(e){a=c(i[e]||r[e],a)}return l(t),n.forEach(l),c(e,a)}(e,n,i)),a.push(n))}return a}let f={provider:"",aliases:{},not_found:{},...a};function d(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function h(e){if("object"!=typeof e||null===e||"string"!=typeof e.prefix||!e.icons||"object"!=typeof e.icons||!d(e,f))return null;let t=e.icons;for(let e in t){let n=t[e];if(!e||"string"!=typeof n.body||!d(n,o))return null}let n=e.aliases||Object.create(null);for(let e in n){let i=n[e],r=i.parent;if(!e||"string"!=typeof r||!t[r]&&!n[r]||!d(i,o))return null}return e}let p=Object.create(null);function g(e,t){let n=p[e]||(p[e]=Object.create(null));return n[t]||(n[t]={provider:e,prefix:t,icons:Object.create(null),missing:new Set})}function m(e,t){return h(t)?u(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}let y=/^[a-z0-9]+(-[a-z0-9]+)*$/,x=(e,t,n,i="")=>{let r=e.split(":");if("@"===e.slice(0,1)){if(r.length<2||r.length>3)return null;i=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){let e=r.pop(),n=r.pop(),a={provider:r.length>0?r[0]:i,prefix:n,name:e};return t&&!b(a)?null:a}let a=r[0],l=a.split("-");if(l.length>1){let e={provider:i,prefix:l.shift(),name:l.join("-")};return t&&!b(e)?null:e}if(n&&""===i){let e={provider:i,prefix:"",name:a};return t&&!b(e,n)?null:e}return null},b=(e,t)=>!!e&&!!((t&&""===e.prefix||e.prefix)&&e.name),k=!1;function v(e){return"boolean"==typeof e&&(k=e),k}function j(e){let t="string"==typeof e?x(e,!0,k):e;if(t){let e=g(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}let w=Object.freeze({width:null,height:null}),M=Object.freeze({...w,...l}),E=/(-?[0-9.]*[0-9]+[0-9.]*)/g,N=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function S(e,t,n){if(1===t)return e;if(n=n||100,"number"==typeof e)return Math.ceil(e*t*n)/n;if("string"!=typeof e)return e;let i=e.split(E);if(null===i||!i.length)return e;let r=[],a=i.shift(),l=N.test(a);for(;;){if(l){let e=parseFloat(a);isNaN(e)?r.push(a):r.push(Math.ceil(e*t*n)/n)}else r.push(a);if(void 0===(a=i.shift()))return r.join("");l=!l}}let z=/\sid="(\S+)"/g,T="IconifyId"+Date.now().toString(16)+(0x1000000*Math.random()|0).toString(16),O=0,C=Object.create(null);function F(e){return C[e]||C[""]}function A(e){let t;if("string"==typeof e.resources)t=[e.resources];else if(!((t=e.resources)instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:!0===e.random,index:e.index||0,dataAfterTimeout:!1!==e.dataAfterTimeout}}let I=Object.create(null),L=["https://api.simplesvg.com","https://api.unisvg.com"],$=[];for(;L.length>0;)1===L.length||Math.random()>.5?$.push(L.shift()):$.push(L.pop());I[""]=A({resources:["https://api.iconify.design"].concat($)});let P=(()=>{let e;try{if(e=fetch,"function"==typeof e)return e}catch(e){}})();function H(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}let R=0,q={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function _(e){let t={...q,...e},n=[];function i(){n=n.filter(e=>"pending"===e().status)}return{query:function(e,r,a){let l=function(e,t,n,i){let r,a,l=e.resources.length,s=e.random?Math.floor(Math.random()*l):e.index;if(e.random){let t=e.resources.slice(0);for(r=[];t.length>1;){let e=Math.floor(Math.random()*t.length);r.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}r=r.concat(t)}else r=e.resources.slice(s).concat(e.resources.slice(0,s));let o=Date.now(),c="pending",u=0,f=null,d=[],h=[];function p(){f&&(clearTimeout(f),f=null)}function g(){"pending"===c&&(c="aborted"),p(),d.forEach(e=>{"pending"===e.status&&(e.status="aborted")}),d=[]}function m(e,t){t&&(h=[]),"function"==typeof e&&h.push(e)}function y(){c="failed",h.forEach(e=>{e(void 0,a)})}function x(){d.forEach(e=>{"pending"===e.status&&(e.status="aborted")}),d=[]}return"function"==typeof i&&h.push(i),setTimeout(function i(){if("pending"!==c)return;p();let l=r.shift();if(void 0===l){if(d.length){f=setTimeout(()=>{p(),"pending"===c&&(x(),y())},e.timeout);return}y();return}let s={status:"pending",resource:l,callback:(t,n)=>{!function(t,n,l){let s="success"!==n;switch(d=d.filter(e=>e!==t),c){case"pending":break;case"failed":if(s||!e.dataAfterTimeout)return;break;default:return}if("abort"===n){a=l,y();return}if(s){a=l,d.length||(r.length?i():y());return}if(p(),x(),!e.random){let n=e.resources.indexOf(t.resource);-1!==n&&n!==e.index&&(e.index=n)}c="completed",h.forEach(e=>{e(l)})}(s,t,n)}};d.push(s),u++,f=setTimeout(i,e.rotate),n(l,t,s.callback)}),function(){return{startTime:o,payload:t,status:c,queriesSent:u,queriesPending:d.length,subscribe:m,abort:g}}}(t,e,r,(e,t)=>{i(),a&&a(e,t)});return n.push(l),l},find:function(e){return n.find(t=>e(t))||null},setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:i}}let V=Object.create(null);function D(){}function U(e,t,n){function i(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&"object"==typeof n)try{if(!m(e,n).length)return void i()}catch(e){console.error(e)}i(),e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,i=e.provider,r=e.prefix;t.forEach(t=>{let a=t.icons,l=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==r)return!0;let l=t.name;if(e.icons[l])a.loaded.push({provider:i,prefix:r,name:l});else{if(!e.missing.has(l))return n=!0,!0;a.missing.push({provider:i,prefix:r,name:l})}return!1}),a.pending.length!==l&&(n||H([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}))}function B(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}let G=/[\s,]+/,W={...M,inline:!1},Q={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},J={display:"inline-block"},K={backgroundColor:"currentColor"},X={backgroundColor:"transparent"},Y={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Z={WebkitMask:K,mask:K,background:X};for(let e in Z){let t=Z[e];for(let n in Y)t[e+n]=Y[n]}let ee={...W,inline:!0};function et(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}if(v(!0),n={prepare:(e,t,n)=>{let i=[],r=function(e,t){let n,i=I[e];if(!i)return 0;if(i.maxURL){let e=0;i.resources.forEach(t=>{e=Math.max(e,t.length)}),n=i.maxURL-e-i.path.length-(t+".json?icons=").length}else n=0;return n}(e,t),a="icons",l={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,o)=>{(s+=n.length+1)>=r&&o>0&&(i.push(l),l={type:a,provider:e,prefix:t,icons:[]},s=n.length),l.icons.push(n)}),i.push(l),i},send:(e,t,n)=>{if(!P)return void n("abort",424);let i=function(e){if("string"==typeof e){let t=I[e];if(t)return t.path}return"/"}(t.provider);switch(t.type){case"icons":i+=t.prefix+".json?"+new URLSearchParams({icons:t.icons.join(",")}).toString();break;case"custom":{let e=t.uri;i+="/"===e.slice(0,1)?e.slice(1):e;break}default:n("abort",400);return}let r=503;P(e+i).then(e=>{let t=e.status;return 200!==t?void setTimeout(()=>{n(404===t?"abort":"next",t)}):(r=501,e.json())}).then(e=>{"object"!=typeof e||null===e?setTimeout(()=>{404===e?n("abort",e):n("next",r)}):setTimeout(()=>{n("success",e)})}).catch(()=>{n("next",r)})}},C[""]=n,"u">typeof document&&"u">typeof window){let e=window;if(void 0!==e.IconifyPreload){let t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";"object"==typeof t&&null!==t&&(t instanceof Array?t:[t]).forEach(e=>{try{("object"!=typeof e||null===e||e instanceof Array||"object"!=typeof e.icons||"string"!=typeof e.prefix||!function(e,t){if("object"!=typeof e)return!1;if("string"!=typeof t&&(t=e.provider||""),k&&!t&&!e.prefix){let t=!1;return h(e)&&(e.prefix="",u(e,(e,n)=>{(function(e,t){let n=x(e,!0,k);if(!n)return!1;let i=g(n.provider,n.prefix);if(!t)return i.missing.add(n.name),!0;var r=n.name;try{if("string"==typeof t.body)return i.icons[r]={...t},!0}catch(e){}return!1})(e,n)&&(t=!0)})),t}let n=e.prefix;return!!b({prefix:n,name:"a"})&&!!m(g(t,n),e)}(e))&&console.error(n)}catch(e){console.error(n)}})}if(void 0!==e.IconifyProviders){let t=e.IconifyProviders;if("object"==typeof t&&null!==t)for(let e in t){let n="IconifyProviders["+e+"] is invalid.";try{let i=t[e];if("object"!=typeof i||!i||void 0===i.resources)continue;!function(e,t){let n=A(t);return null!==n&&(I[e]=n,!0)}(e,i)&&console.error(n)}catch(e){console.error(n)}}}}function en(e){let[n,i]=(0,r.useState)(!!e.ssr),[a,l]=(0,r.useState)({}),[o,c]=(0,r.useState)(function(t){if(t){let t=e.icon;if("object"==typeof t)return{name:"",data:t};let n=j(t);if(n)return{name:t,data:n}}return{name:""}}(!!e.ssr));function u(){let e=a.callback;e&&(e(),l({}))}function f(e){if(JSON.stringify(o)!==JSON.stringify(e))return u(),c(e),!0}(0,r.useEffect)(()=>(i(!0),u),[]),(0,r.useEffect)(()=>{n&&function t(){var n;let i=e.icon;if("object"==typeof i)return void f({name:"",data:i});let r=j(i);f({name:i,data:r})&&(void 0===r?l({callback:((e,t)=>{var n;let i,r,a,l,s,o=(n=function(e,t=!0,n=!1){let i=[];return e.forEach(e=>{let r="string"==typeof e?x(e,t,n):e;r&&i.push(r)}),i}(e,!0,v()),a={loaded:[],missing:[],pending:[]},l=Object.create(null),n.sort((e,t)=>e.provider!==t.provider?e.provider.localeCompare(t.provider):e.prefix!==t.prefix?e.prefix.localeCompare(t.prefix):e.name.localeCompare(t.name)),s={provider:"",prefix:"",name:""},n.forEach(e=>{if(s.name===e.name&&s.prefix===e.prefix&&s.provider===e.provider)return;s=e;let t=e.provider,n=e.prefix,i=e.name,r=l[t]||(l[t]=Object.create(null)),o=r[n]||(r[n]=g(t,n));(i in o.icons?a.loaded:""===n||o.missing.has(i)?a.missing:a.pending).push({provider:t,prefix:n,name:i})}),a);if(!o.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(o.loaded,o.missing,o.pending,D)}),()=>{e=!1}}let c=Object.create(null),u=[];return o.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===r&&t===i)return;i=t,r=n,u.push(g(t,n));let a=c[t]||(c[t]=Object.create(null));a[n]||(a[n]=[])}),o.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,r=g(t,n),a=r.pendingIcons||(r.pendingIcons=new Set);a.has(i)||(a.add(i),c[t][n].push(i))}),u.forEach(e=>{let t=c[e.provider][e.prefix];t.length&&(e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{let t,n;e.iconsQueueFlag=!1;let{provider:i,prefix:r}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;let l=e.loadIcon;if(e.loadIcons&&(a.length>1||!l))return void B(e.loadIcons(a,r,i),t=>{U(e,a,t)});if(l)return void a.forEach(t=>{B(l(t,r,i),n=>{let i=n?{prefix:r,icons:{[t]:n}}:null;U(e,[t],i)})});let{valid:s,invalid:o}=(t=[],n=[],a.forEach(e=>{(e.match(y)?t:n).push(e)}),{valid:t,invalid:n});if(o.length&&U(e,o,null),!s.length)return;let c=r.match(y)?F(i):null;c?c.prepare(i,r,s).forEach(t=>{!function(e,t,n){let i,r;if("string"==typeof e){let t=F(e);if(!t)return n(void 0,424);r=t.send;let a=function(e){if(!V[e]){let t=I[e];if(!t)return;let n=_(t);V[e]={config:t,redundancy:n}}return V[e]}(e);a&&(i=a.redundancy)}else{let t=A(e);if(t){i=_(t);let n=F(e.resources?e.resources[0]:"");n&&(r=n.send)}}i&&r?i.query(t,r,n)().abort:n(void 0,424)}(i,t,n=>{U(e,t.icons,n)})}):U(e,s,null)})))}),t?function(e,t,n){let i=R++,r=H.bind(null,n,i);if(!t.pending.length)return r;let a={id:i,icons:t,callback:e,abort:r};return n.forEach(e=>{(e.loaderCallbacks||(e.loaderCallbacks=[])).push(a)}),r}(t,o,u):D})([i],t)}):r&&(null==(n=e.onLoad)||n.call(e,i)))}()},[e.icon,n]);let{name:d,data:h}=o;return h?((e,n,i)=>{var a;let l,o,c,u,f,d,h,p,g,m,y,b,k,v=n.inline?ee:W,j=function(e,t){let n={...e};for(let e in t){let i=t[e],r=typeof i;e in w?(null===i||i&&("string"===r||"number"===r))&&(n[e]=i):r===typeof n[e]&&(n[e]="rotate"===e?i%4:i)}return n}(v,n),E=n.mode||"svg",N={},C=n.style||{},F={..."svg"===E?Q:{}};if(i){let e=x(i,!1,!0);if(e){let t=["iconify"];for(let n of["provider","prefix"])e[n]&&t.push("iconify--"+e[n]);F.className=t.join(" ")}}for(let e in n){let t=n[e];if(void 0!==t)switch(e){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":F.ref=t;break;case"className":F[e]=(F[e]?F[e]+" ":"")+t;break;case"inline":case"hFlip":case"vFlip":j[e]=!0===t||"true"===t||1===t;break;case"flip":"string"==typeof t&&function(e,t){t.split(G).forEach(t=>{switch(t.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0}})}(j,t);break;case"color":N.color=t;break;case"rotate":"string"==typeof t?j[e]=function(e,t=0){let n=e.replace(/^-?[0-9.]*/,"");function i(e){for(;e<0;)e+=4;return e%4}if(""===n){let t=parseInt(e);return isNaN(t)?0:i(t)}if(n!==e){let t=0;switch(n){case"%":t=25;break;case"deg":t=90}if(t){let r=parseFloat(e.slice(0,e.length-n.length));return isNaN(r)?0:(r/=t)%1==0?i(r):0}}return t}(t):"number"==typeof t&&(j[e]=t);break;case"ariaHidden":case"aria-hidden":!0!==t&&"true"!==t&&delete F["aria-hidden"];break;default:void 0===v[e]&&(F[e]=t)}}let A=(c={...s,...e},u={...M,...j},f={left:c.left,top:c.top,width:c.width,height:c.height},d=c.body,[c,u].forEach(e=>{var t,n,i,r;let a,l,s=[],o=e.hFlip,c=e.vFlip,u=e.rotate;switch(o?c?u+=2:(s.push("translate("+(f.width+f.left).toString()+" "+(0-f.top).toString()+")"),s.push("scale(-1 1)"),f.top=f.left=0):c&&(s.push("translate("+(0-f.left).toString()+" "+(f.height+f.top).toString()+")"),s.push("scale(1 -1)"),f.top=f.left=0),u<0&&(u-=4*Math.floor(u/4)),u%=4){case 1:s.unshift("rotate(90 "+(a=f.height/2+f.top).toString()+" "+a.toString()+")");break;case 2:s.unshift("rotate(180 "+(f.width/2+f.left).toString()+" "+(f.height/2+f.top).toString()+")");break;case 3:s.unshift("rotate(-90 "+(a=f.width/2+f.left).toString()+" "+a.toString()+")")}u%2==1&&(f.left!==f.top&&(a=f.left,f.left=f.top,f.top=a),f.width!==f.height&&(a=f.width,f.width=f.height,f.height=a)),s.length&&(t=d,n='<g transform="'+s.join(" ")+'">',i=(l=function(e,t="defs"){let n="",i=e.indexOf("<"+t);for(;i>=0;){let r=e.indexOf(">",i),a=e.indexOf("</"+t);if(-1===r||-1===a)break;let l=e.indexOf(">",a);if(-1===l)break;n+=e.slice(r+1,a).trim(),e=e.slice(0,i).trim()+e.slice(l+1)}return{defs:n,content:e}}(t)).defs,r=n+l.content+"</g>",d=i?"<defs>"+i+"</defs>"+r:r)}),h=u.width,p=u.height,g=f.width,m=f.height,null===h?l=S(o=null===p?"1em":"auto"===p?m:p,g/m):(l="auto"===h?g:h,o=null===p?S(l,m/g):"auto"===p?m:p),y={},(b=(e,t)=>{"unset"!==t&&"undefined"!==t&&"none"!==t&&(y[e]=t.toString())})("width",l),b("height",o),y.viewBox=(k=[f.left,f.top,g,m]).join(" "),{attributes:y,viewBox:k,body:d}),I=A.attributes;if(j.inline&&(N.verticalAlign="-0.125em"),"svg"===E){F.style={...N,...C},Object.assign(F,I);let e=0,i=n.id;return"string"==typeof i&&(i=i.replace(/-/g,"_")),F.dangerouslySetInnerHTML={__html:(a=function(e,t=T){let n,i=[];for(;n=z.exec(e);)i.push(n[1]);if(!i.length)return e;let r="suffix"+(0x1000000*Math.random()|Date.now()).toString(16);return i.forEach(n=>{let i="function"==typeof t?t(n):t+(O++).toString(),a=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(RegExp('([#;"])('+a+')([")]|\\.[a-z])',"g"),"$1"+i+r+"$3")}),e=e.replace(RegExp(r,"g"),"")}(A.body,i?()=>i+"ID"+e++:"iconifyReact"),void 0===t&&function(){try{t=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){t=null}}(),t?t.createHTML(a):a)},(0,r.createElement)("svg",F)}let{body:L,width:$,height:P}=e,H="mask"===E||"bg"!==E&&-1!==L.indexOf("currentColor"),R=function(e,t){let n=-1===e.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(let e in t)n+=" "+e+'="'+t[e]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}(L,{...I,width:$+"",height:P+""});return F.style={...N,"--svg":'url("data:image/svg+xml,'+R.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")+'")',width:et(I.width),height:et(I.height),...J,...H?K:X,...C},(0,r.createElement)("span",F)})({...s,...h},e,d):e.children?e.children:e.fallback?e.fallback:(0,r.createElement)("span",{})}let ei=(0,r.forwardRef)((e,t)=>en({...e,_ref:t}));(0,r.forwardRef)((e,t)=>en({inline:!0,...e,_ref:t}));var er=e.i(66595),ea=e.i(31214),el=e.i(56420);let es=(0,el.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),eo=(0,el.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),ec=(0,el.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),eu=(0,el.default)("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),ef=(0,el.default)("camera",[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);var ed=e.i(68590);let eh=(0,el.default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ep=(0,el.default)("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);var eg=e.i(30274);let em=(0,el.default)("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]);var ey=e.i(51921);let ex=(0,el.default)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),eb=(0,el.default)("triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]),ek=(0,el.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);var ev=e.i(66627);let ej=[{name:"Google",host:"google.com",icon:"simple-icons:google",fallback:(0,i.jsx)(er.Search,{size:20})},{name:"Cloudflare",host:"cloudflare.com",icon:"simple-icons:cloudflare",fallback:(0,i.jsx)(ea.Cloud,{size:20})},{name:"YouTube",host:"youtube.com",icon:"simple-icons:youtube",fallback:(0,i.jsx)(es,{size:20})},{name:"GitHub",host:"github.com",icon:"simple-icons:github",fallback:(0,i.jsx)(eo,{size:20})},{name:"ChatGPT",host:"chatgpt.com",icon:"simple-icons:openai",fallback:(0,i.jsx)(ec,{size:20})},{name:"X",host:"x.com",icon:"simple-icons:x",fallback:(0,i.jsx)(eu,{size:20})},{name:"Instagram",host:"instagram.com",icon:"simple-icons:instagram",fallback:(0,i.jsx)(ef,{size:20})},{name:"Reddit",host:"reddit.com",icon:"simple-icons:reddit",fallback:(0,i.jsx)(ed.MessageSquare,{size:20})},{name:"Wikipedia",host:"wikipedia.org",icon:"simple-icons:wikipedia",fallback:(0,i.jsx)(eh,{size:20})},{name:"Apple",host:"apple.com",icon:"simple-icons:apple",fallback:(0,i.jsx)(ep,{size:20})},{name:"Telegram",host:"telegram.org",icon:"simple-icons:telegram",fallback:(0,i.jsx)(eg.Send,{size:20})},{name:"Discord",host:"discord.com",icon:"simple-icons:discord",fallback:(0,i.jsx)(em,{size:20})},{name:"TikTok",host:"tiktok.com",icon:"simple-icons:tiktok",fallback:(0,i.jsx)(ey.Music,{size:20})},{name:"npm",host:"npmjs.com",icon:"simple-icons:npm",fallback:(0,i.jsx)(ex,{size:20})},{name:"Vercel",host:"vercel.com",icon:"simple-icons:vercel",fallback:(0,i.jsx)(eb,{size:20})}];function ew({icon:e,fallback:t}){let[n,a]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let t=new Image;t.onload=()=>a(!0),t.onerror=()=>a(!1),t.src=`https://api.iconify.design/${e.replace(":","/")}.svg`},[e]),(0,i.jsxs)("span",{className:"brand-icon-wrap",children:[(0,i.jsx)("span",{className:`brand-icon-fallback ${n?"hidden":""}`,children:t}),(0,i.jsx)("span",{className:`brand-icon-real ${n?"visible":""}`,children:(0,i.jsx)(ei,{icon:e,width:20,height:20})})]})}function eM(){let[e,t]=(0,r.useState)(new Map),[n,a]=(0,r.useState)(!1),l=(0,r.useRef)(new Map),s=(0,r.useCallback)(e=>{t(t=>{let n=new Map(t);return n.set(e,{status:"pending",latency:0}),n});let n=new AbortController;l.current.set(e,n);let i=performance.now(),r=(n,i)=>{t(t=>{let r=new Map(t);return r.set(e,{status:n,latency:i}),r})},a=setTimeout(()=>{n.abort()},5e3);fetch(`https://${e}/`,{method:"HEAD",mode:"no-cors",cache:"no-store",signal:n.signal}).then(()=>{clearTimeout(a),r("ok",Math.round(performance.now()-i))}).catch(()=>{clearTimeout(a),r("timeout",0)})},[]),o=(0,r.useCallback)(()=>{a(!0);let e=new Map;ej.forEach(t=>{e.set(t.host,{status:"pending",latency:0})}),t(e);let n=new Set(ej.map(e=>e.host));ej.forEach(e=>{let i=new AbortController;l.current.set(e.host,i);let r=performance.now(),s=(i,r)=>{n.has(e.host)&&(n.delete(e.host),t(t=>{let n=new Map(t);return n.set(e.host,{status:i,latency:r}),n}),0===n.size&&a(!1))},o=setTimeout(()=>{i.abort()},5e3);fetch(`https://${e.host}/`,{method:"HEAD",mode:"no-cors",cache:"no-store",signal:i.signal}).then(()=>{clearTimeout(o),s("ok",Math.round(performance.now()-r))}).catch(()=>{clearTimeout(o),s("timeout",0)})})},[]);return(0,r.useEffect)(()=>(o(),()=>{l.current.forEach(e=>e.abort()),l.current.clear()}),[o]),(0,i.jsxs)("div",{className:"ping-page",children:[(0,i.jsxs)("div",{className:"ping-header",children:[(0,i.jsxs)("div",{className:"ping-title-wrap",children:[(0,i.jsx)(ev.Wifi,{size:28,className:"ping-title-icon"}),(0,i.jsxs)("div",{children:[(0,i.jsx)("h1",{className:"ping-title",children:"网络连通性"}),(0,i.jsx)("p",{className:"ping-subtitle",children:"通过向对应网站发送请求进行测试,延迟值仅供参考。"})]})]}),(0,i.jsx)("button",{className:"btn btn-icon",onClick:o,disabled:n,"aria-label":"重新测试全部",title:"重新测试全部",children:(0,i.jsx)(ek,{size:18,className:n?"ping-spin":""})})]}),(0,i.jsx)("div",{className:"ping-grid",children:ej.map(t=>{let n=e.get(t.host),r=!n||"pending"===n.status,a=n?.status==="timeout";return(0,i.jsxs)("div",{className:`ping-card ${r?"pending":""}`,children:[(0,i.jsxs)("div",{className:"ping-card-top",children:[(0,i.jsx)("span",{className:"ping-card-icon",children:(0,i.jsx)(ew,{icon:t.icon,fallback:t.fallback})}),(0,i.jsx)("a",{href:`https://${t.host}`,target:"_blank",rel:"noreferrer",className:"ping-card-name",children:t.name}),(0,i.jsx)("button",{className:"ping-card-refresh",onClick:()=>s(t.host),disabled:r,"aria-label":`重新测试 ${t.name}`,title:"重新测试",children:(0,i.jsx)(ek,{size:13,className:r?"ping-spin":""})})]}),(0,i.jsxs)("div",{className:"ping-card-bottom",children:[r?(0,i.jsx)("span",{className:"ping-pulse-dot"}):(0,i.jsx)("span",{className:`ping-status-label ${a?"is-error":"is-success"}`,children:a?"不可用":"可用"}),(0,i.jsx)("span",{className:`ping-latency ${r?"is-muted":a?"is-error":"is-success"}`,children:r?"--":a?"超时":`${n.latency} ms`})]})]},t.host)})})]})}var eE=e.i(40983);e.s(["default",0,function(){return(0,i.jsx)(eE.MarketingLayout,{children:(0,i.jsx)(eM,{})})}],23449)}]);
|