@tryghost/koenig-lexical 0.0.93 → 0.0.94

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.
@@ -427,7 +427,7 @@ function print() { __p += __j.call(arguments, '') }
427
427
  </tbody>
428
428
  </table>
429
429
  </div>
430
- `,w=H4(q4(v));h.innerHTML=h.innerHTML+w}return u&&h.appendChild(t.createElement("hr")),h}const jL=U.createCommand(),VL="email-cta";let Pue=class extends Xi{constructor(){let{alignment:t,buttonText:i,buttonUrl:r,html:o,segment:s,showButton:a,showDividers:l}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=arguments.length>1?arguments[1]:void 0;super(u);ke(this,"__alignment");ke(this,"__buttonText");ke(this,"__buttonUrl");ke(this,"__html");ke(this,"__segment");ke(this,"__showButton");ke(this,"__showDividers");this.__alignment=t||"left",this.__buttonText=i||"",this.__buttonUrl=r||"",this.__html=o||"",this.__segment=s||"status:free",this.__showButton=a||!1,this.__showDividers=l??!0}static getType(){return VL}static clone(t){return new this(t.getDataset(),t.__key)}static get urlTransformMap(){return{buttonUrl:"url",html:"html"}}getDataset(){const t=this.getLatest();return{alignment:t.__alignment,buttonText:t.__buttonText,buttonUrl:t.__buttonUrl,html:t.__html,segment:t.__segment,showButton:t.__showButton,showDividers:t.__showDividers}}static importJSON(t){const{alignment:i,buttonText:r,buttonUrl:o,html:s,segment:a,showButton:l,showDividers:u}=t;return new this({alignment:i,buttonText:r,buttonUrl:o,html:s,segment:a,showButton:l,showDividers:u})}exportJSON(){return{type:VL,version:1,alignment:this.getAlignment(),buttonText:this.getButtonText(),buttonUrl:this.getButtonUrl(),html:this.getHtml(),segment:this.getSegment(),showButton:this.getShowButton(),showDividers:this.getShowDividers()}}exportDOM(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{element:Nue(this,t)}}createDOM(){return document.createElement("div")}updateDOM(){return!1}isInline(){return!1}getAlignment(){return this.getLatest().__alignment}setAlignment(t){const i=this.getWritable();return i.__alignment=t}getButtonText(){return this.getLatest().__buttonText}setButtonText(t){const i=this.getWritable();return i.__buttonText=t}getButtonUrl(){return this.getLatest().__buttonUrl}setButtonUrl(t){const i=this.getWritable();return i.__buttonUrl=t}getHtml(){return this.getLatest().__html}setHtml(t){const i=this.getWritable();return i.__html=t}getSegment(){return this.getLatest().__segment}setSegment(t){const i=this.getWritable();return i.__segment=t}getShowButton(){return this.getLatest().__showButton}setShowButton(t){const i=this.getWritable();return i.__showButton=t}getShowDividers(){return this.getLatest().__showDividers}setShowDividers(t){const i=this.getWritable();return i.__showDividers=t}hasEditMode(){return!0}isEmpty(){return!this.__html&&(!this.__showButton||!this.__buttonText&&!this.__buttonUrl)}decorate(){return""}};var Xk={},ZL=B;let GL=ZL.createContext(null);Xk.LexicalComposerContext=GL,Xk.createLexicalComposerContext=function(n,e){let t=null;return n!=null&&(t=n[1]),{getTheme:function(){return e??(t!=null?t.getTheme():null)}}},Xk.useLexicalComposerContext=function(){let n=ZL.useContext(GL);if(n==null)throw Error("Minified Lexical error #8; visit https://lexical.dev/docs/error?code=8 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return n};var Ye=Xk;const Due=({text:n="Type here"})=>C("div",{className:"pointer-events-none absolute top-0 left-0 m-0 min-w-full cursor-text font-sans text-sm font-normal tracking-wide text-grey-500 dark:text-grey-800",children:n});function Mue({parentEditor:n}){const[e]=Ye.useLexicalComposerContext(),{setCaptionHasFocus:t,captionHasFocus:i,nodeKey:r,isSelected:o}=B.useContext(or),s=B.useCallback(a=>{o&&(a.target.matches("input, textarea")||!i&&a.key.length===1&&!a.ctrlKey&&!a.metaKey&&!a.altKey&&e.focus())},[e,i,o]);return B.useEffect(()=>(document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}),[s,e]),B.useEffect(()=>Ut.mergeRegister(e.registerCommand(U.FOCUS_COMMAND,()=>(t(!0),!1),U.COMMAND_PRIORITY_LOW),e.registerCommand(U.BLUR_COMMAND,()=>(t(!1),e.update(()=>{U.$setSelection(null)}),!1),U.COMMAND_PRIORITY_LOW),e.registerCommand(U.KEY_ENTER_COMMAND,()=>(n.update(()=>{const a=U.$getNodeByKey(r),l=U.$createParagraphNode();a.getTopLevelElementOrThrow().insertAfter(l),l.selectStart()}),!1),U.COMMAND_PRIORITY_LOW)),[e,t,n,r]),null}const Lue=({paragraphs:n=1,captionEditor:e,captionEditorInitialState:t,placeholderText:i,className:r="koenig-lexical-caption"})=>{const[o]=Ye.useLexicalComposerContext();return C(D9,{initialEditor:e,initialEditorState:t,initialNodes:Jn,children:fe(L_,{className:r,markdownTransformers:QT,placeholder:C(Due,{text:i}),children:[C(Mue,{parentEditor:o}),C(lO,{paragraphs:n})]})})};var Ju={},xo=U;function Z4(n,e=!0){return n?!1:(n=XL(),e&&(n=n.trim()),n==="")}function XL(){return xo.$getRoot().getTextContent()}function YL(n){if(!Z4(n,!1))return!1;n=xo.$getRoot().getChildren();let e=n.length;if(1<e)return!1;for(let i=0;i<e;i++){var t=n[i];if(xo.$isDecoratorNode(t))return!1;if(xo.$isElementNode(t)){if(!xo.$isParagraphNode(t)||t.__indent!==0)return!1;t=t.getChildren();let r=t.length;for(let o=0;o<r;o++)if(!xo.$isTextNode(t[i]))return!1}}return!0}Ju.$canShowPlaceholder=YL,Ju.$canShowPlaceholderCurry=function(n){return()=>YL(n)},Ju.$findTextIntersectionFromCharacters=function(n,e){var t=n.getFirstChild();n=0;e:for(;t!==null;){if(xo.$isElementNode(t)){var i=t.getFirstChild();if(i!==null){t=i;continue}}else if(xo.$isTextNode(t)){if(i=t.getTextContentSize(),n+i>e)return{node:t,offset:e-n};n+=i}if(i=t.getNextSibling(),i!==null)t=i;else{for(t=t.getParent();t!==null;){if(i=t.getNextSibling(),i!==null){t=i;continue e}t=t.getParent()}break}}return null},Ju.$isRootTextContentEmpty=Z4,Ju.$isRootTextContentEmptyCurry=function(n,e){return()=>Z4(n,e)},Ju.$rootTextContent=XL,Ju.registerLexicalTextEntity=function(n,e,t,i){let r=s=>{const a=xo.$createTextNode(s.getTextContent());a.setFormat(s.getFormat()),s.replace(a)},o=n.registerNodeTransform(xo.TextNode,s=>{if(s.isSimpleText()){var a=s.getPreviousSibling(),l=s.getTextContent(),u=s;if(xo.$isTextNode(a)){var f=a.getTextContent(),h=e(f+l);if(a instanceof t){if(h===null||a.getLatest().__mode!==0){r(a);return}if(h=h.end-f.length,0<h){u=l.slice(0,h),u=f+u,a.select(),a.setTextContent(u),h===l.length?s.remove():(a=l.slice(h),s.setTextContent(a));return}}else if(h===null||h.start<f.length)return}for(;;){if(s=e(l),l=h=s===null?"":l.slice(s.end),h===""){if(f=u.getNextSibling(),xo.$isTextNode(f)){if(h=u.getTextContent()+f.getTextContent(),h=e(h),h===null){f instanceof t?r(f):f.markDirty();break}else if(h.start!==0)break}}else if(f=e(h),f!==null&&f.start===0)break;if(s===null)break;if(s.start===0&&xo.$isTextNode(a)&&a.isTextEntity())continue;let p;if(s.start===0?[p,u]=u.splitText(s.end):[,p,u]=u.splitText(s.start,s.end),s=i(p),p.replace(s),u==null)break}}});return n=n.registerNodeTransform(t,s=>{var a=s.getTextContent();const l=e(a);l===null||l.start!==0?r(s):a.length>l.end?s.splitText(l.end):(a=s.getPreviousSibling(),xo.$isTextNode(a)&&a.isTextEntity()&&(r(a),r(s)),a=s.getNextSibling(),xo.$isTextNode(a)&&a.isTextEntity()&&(r(a),s instanceof t&&r(s)))}),[o,n]};var Sl=Ju;function KL({value:n}){const[e,t]=B.useState(null),[i,r]=B.useState(0),[o,s]=B.useState(0);function a(l){r(l.target.selectionStart),s(l.target.selectionEnd)}return B.useEffect(()=>{e&&(e.selectionStart=i,e.selectionEnd=o)},[e,o,i,n]),{saveSelectionRange:a,setRef:t}}function Iue({value:n,onChange:e,...t}){const{setRef:i,saveSelectionRange:r}=KL({value:n});return C("input",{ref:i,value:n,onChange:s=>{r(s),e(s.target.value)},...t})}function Rue({captionEditor:n,captionEditorInitialState:e,placeholder:t,dataTestId:i}){return C("div",{className:"m-0 w-full px-9 text-center","data-testid":i,children:C(Lue,{captionEditor:n,captionEditorInitialState:e,placeholderText:t})})}function Fue({value:n,placeholder:e,onChange:t,readOnly:i,dataTestId:r,autoFocus:o=!0}){return C(Iue,{autoFocus:o,className:"not-kg-prose w-full bg-transparent px-9 text-center font-sans text-sm font-normal leading-8 tracking-wide text-grey-900 placeholder:text-grey-800 dark:text-grey-500","data-testid":r,placeholder:e,readOnly:i,value:n,onChange:t})}function Que({isEditingAlt:n,onClick:e}){return C("button",{className:`absolute bottom-0 right-0 m-2 cursor-pointer rounded border px-1 font-sans text-[1.3rem] font-normal leading-7 tracking-wide transition-all duration-100 ${n?"border-green bg-green text-white":"border-grey text-grey"} `,name:"alt-toggle-button",type:"button",onClick:e,children:"Alt"})}function Gg({altText:n,altTextPlaceholder:e,setAltText:t,captionEditor:i,captionEditorInitialState:r,captionPlaceholder:o,isSelected:s,readOnly:a,dataTestId:l}){const[u,f]=B.useState(!1),h=v=>{v.stopPropagation(),f(!u)};B.useEffect(()=>{s||f(!1)},[s,f]);const p=i.getEditorState().read(Sl.$canShowPlaceholderCurry(!1));return(s||!p)&&fe("figcaption",{className:"flex min-h-[40px] w-full p-2",children:[u?C(Fue,{dataTestId:l,placeholder:e,readOnly:a,value:n,onChange:t}):C(Rue,{captionEditor:i,captionEditorInitialState:r,dataTestId:l,placeholder:o}),t&&C(Que,{isEditingAlt:u,onClick:h})]})}const w0=n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",strokeWidth:1.5,viewBox:"0 0 24 24",...n},re.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M.75 23.249l22.5-22.5M23.25 23.249L.75.749"}));function Bue({value:n,onEnter:e}){const[t]=Ye.useLexicalComposerContext();B.useEffect(i=>Ut.mergeRegister(t.registerCommand(U.KEY_ENTER_COMMAND,()=>(e(i),!1),U.COMMAND_PRIORITY_LOW)),[t,e,n])}function JL({dataTestId:n,value:e,placeholder:t,handleUrlChange:i,handleUrlSubmit:r,hasError:o,handlePasteAsLink:s,handleRetry:a,handleClose:l,isLoading:u}){return u?C("div",{className:"flex w-full items-center justify-center rounded border border-grey-300 p-2 font-sans text-sm font-normal leading-snug text-grey-900 focus-visible:outline-none dark:border-grey-800 dark:bg-grey-900 dark:placeholder:text-grey-800","data-testid":`${n}-loading-container`,children:C("div",{className:"-ml-1 mr-3 inline-block h-5 w-5 animate-spin rounded-full border-4 border-green/20 text-white after:mt-[11px] after:block after:h-1 after:w-1 after:rounded-full after:bg-green/70 after:content-['']","data-testid":`${n}-loading-spinner`})}):o?fe("div",{className:"min-width-[500px] flex flex-row items-center justify-between rounded-sm border border-red bg-red/5 px-3 py-2 text-sm leading-snug text-red","data-testid":`${n}-error-container`,children:[fe("div",{children:[C("span",{className:"mr-3","data-testid":`${n}-error-message`,children:"There was an error when parsing the URL."}),C("button",{className:"mr-3 cursor-pointer","data-testid":`${n}-error-retry`,type:"button",children:C("span",{className:"underline",onClick:a,children:C("strong",{children:"Retry"})})}),C("button",{className:"mr-3 cursor-pointer","data-testid":`${n}-error-pasteAsLink`,type:"button",children:C("span",{className:"underline",onClick:s,children:C("strong",{children:"Paste URL as link"})})})]}),C("button",{className:"cursor-pointer p-1","data-testid":`${n}-error-close`,type:"button",onClick:l,children:C(w0,{className:"red h-3 w-3"})})]}):fe(yt,{children:[C(Bue,{value:e,onEnter:r}),C("input",{autoFocus:!0,className:"w-full rounded border border-grey-300 p-2 font-sans text-sm font-normal leading-snug text-grey-900 focus-visible:outline-none dark:border-grey-800 dark:bg-grey-900 dark:placeholder:text-grey-800","data-testid":n,placeholder:t,value:e,onChange:i,onKeyDown:r})]})}function eI({author:n,handleClose:e,handlePasteAsLink:t,handleRetry:i,handleUrlChange:r,handleUrlSubmit:o,url:s,urlInputValue:a,urlPlaceholder:l,thumbnail:u,title:f,description:h,icon:p,publisher:v,captionEditor:w,captionEditorInitialState:O,isSelected:_,isLoading:E,urlError:T}){return s&&!T&&f?fe(yt,{children:[fe("div",{className:"flex min-h-[120px] w-full rounded border border-grey/40 bg-transparent font-sans dark:border-grey/20","data-testid":"bookmark-container",children:[fe("div",{className:"flex grow basis-full flex-col items-start justify-start p-5","data-testid":"bookmark-text-container",children:[C("div",{className:"text-[1.5rem] font-semibold leading-normal tracking-normal text-grey-900 dark:text-grey-100","data-testid":"bookmark-title",children:f}),C("div",{className:"mt-1 max-h-[44px] overflow-y-hidden text-sm font-normal leading-normal text-grey-800 line-clamp-2 dark:text-grey-600","data-testid":"bookmark-description",children:h}),fe("div",{className:"mt-[20px] flex items-center text-sm font-medium leading-9 text-grey-900",children:[p&&C(zue,{src:p}),C("span",{className:" db max-w-[240px] overflow-hidden text-ellipsis whitespace-nowrap leading-6 text-grey-900 dark:text-grey-100","data-testid":"bookmark-publisher",children:v}),n&&C("span",{className:"font-normal text-grey-800 before:mx-1.5 before:text-grey-900 before:content-['•'] dark:text-grey-600 dark:before:text-grey-100","data-testid":"bookmark-author",children:n})]})]}),u&&C("div",{className:"grow-1 relative m-0 min-w-[33%]","data-testid":"bookmark-thumbnail-container",children:C("img",{alt:"",className:"absolute inset-0 h-full w-full rounded-r-[.3rem] object-cover","data-testid":"bookmark-thumbnail",src:u})})]}),C(Gg,{captionEditor:w,captionEditorInitialState:O,captionPlaceholder:"Type caption for bookmark (optional)",dataTestId:"bookmark-caption",isSelected:_}),C("div",{className:"absolute inset-0 z-50 mt-0"})]}):C(JL,{dataTestId:"bookmark-url",handleClose:e,handlePasteAsLink:t,handleRetry:i,handleUrlChange:r,handleUrlSubmit:o,hasError:T,isLoading:E,placeholder:l,value:a})}function zue({src:n}){return C("img",{alt:"",className:"mr-2 h-5 w-5 shrink-0","data-testid":"bookmark-icon",src:n})}eI.propTypes={author:me.string,handleClose:me.func,handlePasteAsLink:me.func,handleRetry:me.func,handleUrlChange:me.func,handleUrlSubmit:me.func,url:me.string,urlInputValue:me.string,urlPlaceholder:me.string,thumbnail:me.string,title:me.string,description:me.string,icon:me.string,publisher:me.string,captionEditor:me.object,captionEditorInitialState:me.string,isSelected:me.bool,isLoading:me.bool,urlError:me.bool};var Qc={},tI=ar,G4=Ho,_0=Ut,Pt=U;function Bc(n){throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?code=${n} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function nI(n){let e=Pt.$getSelection();if(e==null)throw Error("Expected valid LexicalSelection");return Pt.$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?"":tI.$generateHtmlFromNodes(n,e)}function iI(n){let e=Pt.$getSelection();if(e==null)throw Error("Expected valid LexicalSelection");return Pt.$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(oI(n,e))}function X4(n,e,t){(Pt.DEPRECATED_$isGridSelection(t)||_0.$findMatchingParent(t.anchor.getNode(),i=>Pt.DEPRECATED_$isGridCellNode(i))!==null&&_0.$findMatchingParent(t.focus.getNode(),i=>Pt.DEPRECATED_$isGridCellNode(i))!==null)&&e.length===1&&Pt.DEPRECATED_$isGridNode(e[0])?Uue(e,t,!1,n):Wue(e,t)}function Wue(n,e){let t=[],i=null;for(let r=0;r<n.length;r++){let o=n[r],s=Pt.$isLineBreakNode(o);if(s||Pt.$isDecoratorNode(o)&&o.isInline()||Pt.$isElementNode(o)&&o.isInline()||Pt.$isTextNode(o)||o.isParentRequired()){if(i===null&&(i=o.createParentElementNode(),t.push(i),s))continue;i!==null&&i.append(o)}else t.push(o),i=null}Pt.$isRangeSelection(e)?e.insertNodes(t):Pt.DEPRECATED_$isGridSelection(e)&&(n=e.anchor.getNode(),Pt.DEPRECATED_$isGridCellNode(n)||Bc(41),n.append(...t))}function Uue(n,e,t,i){n.length===1&&Pt.DEPRECATED_$isGridNode(n[0])||Bc(42);var r=n[0];n=r.getChildren(),t=r.getFirstChildOrThrow().getChildrenSize();var o=r.getChildrenSize(),s=_0.$findMatchingParent(e.anchor.getNode(),v=>Pt.DEPRECATED_$isGridCellNode(v));e=(r=s&&_0.$findMatchingParent(s,v=>Pt.DEPRECATED_$isGridRowNode(v)))&&_0.$findMatchingParent(r,v=>Pt.DEPRECATED_$isGridNode(v)),Pt.DEPRECATED_$isGridCellNode(s)&&Pt.DEPRECATED_$isGridRowNode(r)&&Pt.DEPRECATED_$isGridNode(e)||Bc(43);var a=r.getIndexWithinParent(),l=Math.min(e.getChildrenSize()-1,a+o-1);o=s.getIndexWithinParent(),s=Math.min(r.getChildrenSize()-1,o+t-1),t=Math.min(o,s),r=Math.min(a,l),o=Math.max(o,s),a=Math.max(a,l),l=e.getChildren(),s=0;let u,f;for(let v=r;v<=a;v++){var h=l[v];Pt.DEPRECATED_$isGridRowNode(h)||Bc(24);var p=n[s];Pt.DEPRECATED_$isGridRowNode(p)||Bc(24),h=h.getChildren(),p=p.getChildren();let w=0;for(let O=t;O<=o;O++){let _=h[O];Pt.DEPRECATED_$isGridCellNode(_)||Bc(25);let E=p[w];Pt.DEPRECATED_$isGridCellNode(E)||Bc(25),v===r&&O===t?u=_.getKey():v===a&&O===o&&(f=_.getKey());let T=_.getChildren();E.getChildren().forEach(A=>{Pt.$isTextNode(A)&&Pt.$createParagraphNode().append(A),_.append(A)}),T.forEach(A=>A.remove()),w++}s++}u&&f&&(n=Pt.DEPRECATED_$createGridSelection(),n.set(e.getKey(),u,f),Pt.$setSelection(n),i.dispatchCommand(Pt.SELECTION_CHANGE_COMMAND,void 0))}function rI(n,e,t,i=[]){let r=e!=null?t.isSelected(e):!0,o=Pt.$isElementNode(t)&&t.excludeFromCopy("html");var s=t;if(e!==null){var a=G4.$cloneWithProperties(t);s=a=Pt.$isTextNode(a)&&e!=null?G4.$sliceSelectedTextNodeContent(e,a):a}let l=Pt.$isElementNode(s)?s.getChildren():[];var u=s;a=u.exportJSON(),a.type!==u.constructor.getType()&&Bc(58);var f=a.children;for(Pt.$isElementNode(u)&&(Array.isArray(f)||Bc(59)),Pt.$isTextNode(s)&&(s=s.__text,0<s.length?a.text=s:r=!1),s=0;s<l.length;s++)u=l[s],f=rI(n,e,u,a.children),!r&&Pt.$isElementNode(t)&&f&&t.extractWithChild(u,e,"clone")&&(r=!0);if(r&&!o)i.push(a);else if(Array.isArray(a.children))for(n=0;n<a.children.length;n++)i.push(a.children[n]);return r}function oI(n,e){let t=[],i=Pt.$getRoot().getChildren();for(let r=0;r<i.length;r++)rI(n,e,i[r],t);return{namespace:n._config.namespace,nodes:t}}function sI(n){let e=[];for(let t=0;t<n.length;t++){let i=Pt.$parseSerializedNode(n[t]);Pt.$isTextNode(i)&&G4.$addNodeStyle(i),e.push(i)}return e}let Xg=null;function aI(n,e){var t=window.getSelection();if(!t)return!1;var i=t.anchorNode;if(t=t.focusNode,i!==null&&t!==null&&!Pt.isSelectionWithinEditor(n,i,t)||(e.preventDefault(),e=e.clipboardData,i=Pt.$getSelection(),e===null||i===null))return!1;t=nI(n),n=iI(n);let r="";return i!==null&&(r=i.getTextContent()),t!==null&&e.setData("text/html",t),n!==null&&e.setData("application/x-lexical-editor",n),e.setData("text/plain",r),!0}Qc.$generateJSONFromSelectedNodes=oI,Qc.$generateNodesFromSerializedNodes=sI,Qc.$getHtmlContent=nI,Qc.$getLexicalContent=iI,Qc.$insertDataTransferForPlainText=function(n,e){n=n.getData("text/plain"),n!=null&&e.insertRawText(n)},Qc.$insertDataTransferForRichText=function(n,e,t){var i=n.getData("application/x-lexical-editor");if(i)try{let o=JSON.parse(i);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes)){let s=sI(o.nodes);return X4(t,s,e)}}catch{}if(i=n.getData("text/html"))try{var r=new DOMParser().parseFromString(i,"text/html");let o=tI.$generateNodesFromDOM(t,r);return X4(t,o,e)}catch{}if(n=n.getData("text/plain"),n!=null)if(Pt.$isRangeSelection(e))for(n=n.split(/\r?\n/),t=n.length,r=0;r<t;r++)e.insertText(n[r]),r<t-1&&e.insertParagraph();else e.insertRawText(n)},Qc.$insertGeneratedNodes=X4,Qc.copyToClipboard=async function(n,e){if(Xg!==null)return!1;if(e!==null)return new Promise(o=>{n.update(()=>{o(aI(n,e))})});var t=n.getRootElement();let i=document.getSelection();if(t===null||i===null)return!1;let r=document.createElement("span");return r.style.cssText="position: fixed; top: -1000px;",r.append(document.createTextNode("#")),t.append(r),t=new Range,t.setStart(r,0),t.setEnd(r,1),i.removeAllRanges(),i.addRange(t),new Promise(o=>{let s=n.registerCommand(Pt.COPY_COMMAND,a=>(a instanceof ClipboardEvent&&(s(),Xg!==null&&(window.clearTimeout(Xg),Xg=null),o(aI(n,a))),!0),Pt.COMMAND_PRIORITY_CRITICAL);Xg=window.setTimeout(()=>{s(),Xg=null,o(!1)},50),document.execCommand("copy"),r.remove()})};var x0=Qc;const que=n=>re.createElement("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},re.createElement("path",{d:"M4.47 1.867a4.525 4.525 0 015.02 1.378.4.4 0 01-.618.51 3.725 3.725 0 00-6.597 2.369v.159l.817-.817a.4.4 0 11.565.565l-1.48 1.48a.4.4 0 01-.605 0l-1.48-1.48a.4.4 0 11.565-.565l.818.817v-.16A4.526 4.526 0 014.47 1.868zm5.655 3.107a.4.4 0 01.283.117l1.5 1.5a.4.4 0 01-.566.565l-.822-.822A4.525 4.525 0 012.709 9.23a.4.4 0 01.582-.55 3.725 3.725 0 006.427-2.333l-.81.81a.4.4 0 11-.566-.565l1.5-1.5a.4.4 0 01.283-.117z"})),Hue=({snippets:n,onCreateSnippet:e,onUpdateSnippet:t,value:i,isCreateButtonActive:r,onKeyDown:o,activeMenuItem:s})=>{const a=B.useRef(null);return B.useEffect(()=>{var l,u;r?(l=a.current)==null||l.focus():(u=a.current)==null||u.blur()},[r]),fe("ul",{className:"absolute mt-[-1px] w-full max-w-[240px] rounded-b border border-grey-200 bg-white shadow dark:border-grey-900 dark:bg-grey-950",tabIndex:0,onKeyDown:o,children:[C("li",{className:"mb-0 block",children:fe("button",{ref:a,className:"flex w-full cursor-pointer items-center justify-between px-3 py-2 text-left text-sm font-medium text-green hover:bg-grey-100 focus:bg-grey-100 dark:hover:bg-black dark:focus:bg-black",type:"button",onClick:e,children:[fe("span",{children:['Create "',i,"“"]}),C(kb,{className:"h-3 w-3 stroke-green stroke-[3px]"})]})}),!!n.length&&C(jue,{activeMenuItem:s,list:n,onClick:t})]})},jue=({list:n=[],onClick:e,activeMenuItem:t})=>fe("li",{role:"separator",children:[C("span",{className:"tracking-loose block border-t border-grey-200 px-3 pt-3 pb-2 text-xs font-medium uppercase text-grey dark:border-grey-900 dark:text-grey-800",children:"Replace existing"}),C("ul",{role:"menu",children:n.map((i,r)=>C(Vue,{active:t,index:r,name:i.name,onClick:e},i.name))})]}),Vue=({onClick:n,name:e,active:t,index:i})=>{const r=B.useRef(null);return B.useEffect(()=>{var s,a;t===i?(s=r.current)==null||s.focus():(a=r.current)==null||a.blur()},[t,i]),C("li",{className:"mb-1",children:fe("button",{ref:r,className:"flex w-full cursor-pointer items-center justify-between py-2 px-3 text-left text-sm hover:bg-grey-100 focus:bg-grey-100 dark:hover:bg-black dark:focus:bg-black",type:"button",onClick:()=>n(e),children:[C("span",{children:e}),C("div",{className:"h-5 w-5 fill-grey-900",children:C(que,{className:"h-4 w-4 fill-grey-900 dark:fill-grey-600"})})]})})},Zue=({value:n,onChange:e,onClear:t,onKeyDown:i})=>fe("div",{className:"shadow-[0 18px 45px -5px rgba(0,0,0,.15)] relative m-0 flex h-[35px] min-w-[240px] items-center justify-evenly rounded bg-white py-0 font-sans text-sm font-medium before:absolute before:top-[35px] before:left-[calc(50%-8px)] before:w-0 before:border-x-[9px] before:border-t-[9px] before:border-x-transparent before:border-t-green after:absolute after:top-[35px] after:left-[calc(50%-8px)] after:ml-[1px] after:w-0 after:border-x-8 after:border-t-8 after:border-x-transparent after:border-t-white dark:after:border-t-grey-950",children:[C("input",{autoFocus:!0,className:`mb-[1px] h-auto w-full border bg-white py-1 pl-3 pr-9 font-normal leading-loose text-grey-900 selection:bg-grey/40 dark:bg-grey-950 dark:text-grey-100 dark:placeholder:text-grey-800 ${n?"rounded-t rounded-b-none border-grey-300 dark:border-grey-900":"rounded border-green"}`,"data-testid":"snippet-name",placeholder:"Snippet name",value:n,onChange:e,onKeyDown:i}),C("button",{"aria-label":"Close",className:"absolute right-3 cursor-pointer",type:"button",onClick:t,children:C(w0,{className:"h-3 w-3 stroke-2 text-grey"})})]});function lI({value:n,onChange:e,onCreateSnippet:t,onUpdateSnippet:i,onClose:r,darkMode:o,snippets:s=[]}){const a=B.useRef(null),[l,u]=B.useState(!1),[f,h]=B.useState(-1),v=(()=>s.filter(E=>E.name.toLowerCase().indexOf(n.toLowerCase())!==-1))();return B.useEffect(()=>{const E=T=>{a.current&&!a.current.contains(T.target)&&r()};return window.addEventListener("mousedown",E),()=>{window.removeEventListener("mousedown",E)}},[r]),fe("div",{ref:a,className:`${o?"dark":""}`,onClick:E=>E.stopPropagation(),children:[C("form",{onSubmit:E=>{E.preventDefault(),t()},children:C(Zue,{value:n,onChange:e,onClear:r,onKeyDown:E=>{(E.key==="Escape"||E.key==="Esc")&&(E.stopPropagation(),r()),(E.key==="ArrowDown"||E.key==="Down")&&(E.stopPropagation(),E.preventDefault(),u(!0))}})}),!!n&&C(Hue,{activeMenuItem:f,isCreateButtonActive:l,snippets:v,value:n,onCreateSnippet:t,onKeyDown:E=>{if(E.key==="ArrowDown"||E.key==="Down"){E.stopPropagation(),E.preventDefault();const T=f+1;T>v.length-1?(h(-1),u(!0)):(h(T),u(!1))}if(E.key==="ArrowUp"||E.key==="Up"){if(E.stopPropagation(),E.preventDefault(),l){h(v.length-1),u(!1);return}const T=f-1;T<0?(h(-1),u(!0)):(h(T),u(!1))}},onUpdateSnippet:i})]})}lI.propTypes={value:me.string,onChange:me.func,onCreateSnippet:me.func,onReplaceSnippet:me.func,onClose:me.func,suggestedList:me.arrayOf(me.shape({name:me.string.isRequired,value:me.string.isRequired}))};function Rr({onClose:n}){const{cardConfig:{snippets:e,createSnippet:t}}=B.useContext(bn),[i]=Ye.useLexicalComposerContext(),{selectedCardKey:r}=Nd(),[o,s]=B.useState(""),a=u=>{s(u.target.value)},l=u=>{i.update(()=>{if(r){const f=U.$createNodeSelection();f.add(r);const h=x0.$generateJSONFromSelectedNodes(i,f);t({name:u,value:JSON.stringify(h)}),i.dispatchCommand(S0,{cardKey:r})}else{const f=U.$getSelection(),h=x0.$generateJSONFromSelectedNodes(i,f);t({name:u,value:JSON.stringify(h)})}n==null||n()})};return C(lI,{snippets:e,value:o,onChange:a,onClose:n,onCreateSnippet:()=>l(o),onUpdateSnippet:u=>l(u)})}const Gue={bold:RA,italic:UA,headingOne:zA,headingTwo:WA,quote:qA,quoteOne:n=>re.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...n},re.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 8.00011H6C6.26522 8.00011 6.51957 8.10546 6.70711 8.293C6.89464 8.48054 7 8.73489 7 9.00011V13.0001C7 13.2653 6.89464 13.5197 6.70711 13.7072C6.51957 13.8947 6.26522 14.0001 6 14.0001H3C2.73478 14.0001 2.48043 13.8947 2.29289 13.7072C2.10536 13.5197 2 13.2653 2 13.0001V5.08211C2 3.90611 2.906 2.96211 4.538 2.11311C4.65448 2.05244 4.78177 2.0153 4.91261 2.00383C5.04344 1.99235 5.17525 2.00675 5.30052 2.04622C5.42579 2.08568 5.54205 2.14944 5.64268 2.23383C5.74331 2.31823 5.82633 2.42162 5.887 2.53811C5.94767 2.65459 5.9848 2.78188 5.99628 2.91271C6.00776 3.04355 5.99335 3.17536 5.95389 3.30063C5.91442 3.42589 5.85067 3.54216 5.76627 3.64279C5.68187 3.74342 5.57848 3.82644 5.462 3.88711C4.884 4.18711 4.469 4.47611 4.222 4.73411C4.054 4.90811 4 5.02011 4 5.08211V8.00011ZM13 8.00011C13.2652 8.00011 13.5196 8.10546 13.7071 8.293C13.8946 8.48054 14 8.73489 14 9.00011V9.5366C13.6143 9.60243 13.2536 9.7523 12.937 9.9445L12.9298 9.9489L12.4315 10.2608C11.9856 10.5357 11.5 11.0479 11.5 11.8252C11.5 12.5688 11.9611 13.2015 12.6323 13.4311V14.0001H10C9.73478 14.0001 9.48043 13.8947 9.29289 13.7072C9.10536 13.5197 9 13.2653 9 13.0001V5.08211C9 3.90611 9.906 2.96211 11.538 2.11311C11.6545 2.05244 11.7818 2.0153 11.9126 2.00383C12.0434 1.99235 12.1753 2.00675 12.3005 2.04622C12.4258 2.08568 12.5421 2.14944 12.6427 2.23383C12.7433 2.31823 12.8263 2.42162 12.887 2.53811C12.9477 2.65459 12.9848 2.78188 12.9963 2.91271C13.0078 3.04355 12.9934 3.17536 12.9539 3.30063C12.9144 3.42589 12.8507 3.54216 12.7663 3.64279C12.6819 3.74342 12.5785 3.82644 12.462 3.88711C11.884 4.18711 11.469 4.47611 11.222 4.73411C11.054 4.90811 11 5.02011 11 5.08211V8.00011H13ZM14.5428 15.4344C14.1182 15.4344 13.8823 15.1783 13.8823 14.7267V11.96H13.8722L13.6397 12.1082C13.4274 12.2329 13.3229 12.2734 13.1948 12.2734C12.9354 12.2734 12.75 12.0846 12.75 11.8252C12.75 11.6297 12.8646 11.4612 13.0904 11.323L13.5858 11.013C13.8688 10.8411 14.1587 10.7501 14.4249 10.7501C14.8933 10.7501 15.2 11.0635 15.2 11.5488V14.7267C15.2 15.1817 14.9641 15.4344 14.5428 15.4344Z"})),quoteTwo:n=>re.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},re.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 8.00015H6C6.26522 8.00015 6.51957 8.1055 6.70711 8.29304C6.89464 8.48058 7 8.73493 7 9.00015V13.0001C7 13.2654 6.89464 13.5197 6.70711 13.7073C6.51957 13.8948 6.26522 14.0001 6 14.0001H3C2.73478 14.0001 2.48043 13.8948 2.29289 13.7073C2.10536 13.5197 2 13.2654 2 13.0001V5.08215C2 3.90615 2.906 2.96215 4.538 2.11315C4.65448 2.05248 4.78177 2.01534 4.91261 2.00387C5.04344 1.99239 5.17525 2.00679 5.30052 2.04626C5.42579 2.08572 5.54205 2.14948 5.64268 2.23387C5.74331 2.31827 5.82633 2.42166 5.887 2.53815C5.94767 2.65463 5.9848 2.78192 5.99628 2.91275C6.00776 3.04359 5.99335 3.1754 5.95389 3.30067C5.91442 3.42593 5.85067 3.5422 5.76627 3.64283C5.68187 3.74346 5.57848 3.82648 5.462 3.88715C4.884 4.18715 4.469 4.47615 4.222 4.73415C4.054 4.90815 4 5.02015 4 5.08215V8.00015ZM13 8.00015C13.2652 8.00015 13.5196 8.1055 13.7071 8.29304C13.8946 8.48058 14 8.73493 14 9.00015V9.51812C13.4378 9.57694 12.9087 9.77735 12.4803 10.0918C11.9785 10.4601 11.5 11.0848 11.5 11.9043C11.5 12.3632 11.6772 12.8135 12.0264 13.1451C12.0604 13.1774 12.0955 13.208 12.1312 13.2369C11.9419 13.4409 11.7509 13.6922 11.6323 14.0001H10C9.73478 14.0001 9.48043 13.8948 9.29289 13.7073C9.10536 13.5197 9 13.2654 9 13.0001V5.08215C9 3.90615 9.906 2.96215 11.538 2.11315C11.6545 2.05248 11.7818 2.01534 11.9126 2.00387C12.0434 1.99239 12.1753 2.00679 12.3005 2.04626C12.4258 2.08572 12.5421 2.14948 12.6427 2.23387C12.7433 2.31827 12.8263 2.42166 12.887 2.53815C12.9477 2.65463 12.9848 2.78192 12.9963 2.91275C13.0078 3.04359 12.9934 3.1754 12.9539 3.30067C12.9144 3.42593 12.8507 3.5422 12.7663 3.64283C12.6819 3.74346 12.5785 3.82648 12.462 3.88715C11.884 4.18715 11.469 4.47615 11.222 4.73415C11.054 4.90815 11 5.02015 11 5.08215V8.00015H13ZM13.2256 15.1428C12.8903 15.1428 12.6626 14.9404 12.6626 14.6432C12.6626 14.4218 12.7891 14.2257 13.1591 13.8779L14.1616 12.907C14.4937 12.5876 14.6391 12.3789 14.6391 12.1607C14.6391 11.9045 14.4526 11.7337 14.1806 11.7337C13.9687 11.7337 13.8169 11.8255 13.6556 12.0532C13.4785 12.2872 13.3457 12.3694 13.1402 12.3694C12.8524 12.3694 12.65 12.1765 12.65 11.9045C12.65 11.2973 13.371 10.7502 14.247 10.7502C15.1546 10.7502 15.825 11.2973 15.825 12.0373C15.825 12.4959 15.5879 12.926 15.0787 13.3908L14.2881 14.1245V14.172H15.4203C15.765 14.172 15.98 14.3585 15.98 14.6621C15.98 14.9626 15.7713 15.1428 15.4203 15.1428H13.2256Z"})),link:XS,imageRegular:ZS,imageWide:GS,imageFull:jS,imageReplace:HA,add:IA,edit:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...n},re.createElement("path",{d:"M16.19 3.51a.51.51 0 0 0-.71 0L4.07 14.92a.5.5 0 0 0 0 .71l4.28 4.28a.48.48 0 0 0 .7 0L20.47 8.5a.51.51 0 0 0 0-.71ZM3 16.71a.51.51 0 0 0-.47-.13.48.48 0 0 0-.36.33L0 23.33a.49.49 0 0 0 .12.51.5.5 0 0 0 .54.16l6.42-2.14a.52.52 0 0 0 .33-.36.49.49 0 0 0-.14-.5ZM23 1a3.6 3.6 0 0 0-5 0l-.71.71a.5.5 0 0 0 0 .71l4.28 4.28a.51.51 0 0 0 .7 0L23 6a3.53 3.53 0 0 0 0-5Z"})),snippet:wb};function Fr({children:n,hide:e,...t}){return e?null:C("ul",{className:"relative m-0 flex items-center justify-evenly rounded bg-black px-1 py-0 font-sans text-md font-normal text-white after:absolute after:top-[36px] after:left-[calc(50%-8px)] after:w-0 after:border-x-8 after:border-t-8 after:border-x-transparent after:border-t-black",...t,children:n})}function qt({label:n,isActive:e,onClick:t,icon:i,dataTestId:r,hide:o,...s}){if(o)return null;const a=Gue[i];return C("li",{className:"m-0 flex p-0 first:m-0",...s,children:C("button",{"aria-label":n,className:"flex h-9 w-9 cursor-pointer items-center justify-center","data-kg-active":e,"data-testid":r,type:"button",onClick:t,children:C(a,{className:` h-4 w-4 ${e?"fill-green":"fill-white"} `})})})}function Qr({hide:n}){return n?null:C("li",{className:"m-0 mx-1 h-5 w-px bg-grey-900"})}function Xue({author:n,nodeKey:e,url:t,icon:i,title:r,description:o,publisher:s,thumbnail:a,captionEditor:l,captionEditorInitialState:u,createdWithUrl:f}){const[h]=Ye.useLexicalComposerContext(),{cardConfig:p}=B.useContext(bn),{isSelected:v}=B.useContext(or),[w,O]=B.useState(t),[_,E]=B.useState(!1),[T,A]=B.useState(!1),[D,M]=B.useState(!1),I=Z=>{O(Z.target.value)},z=async Z=>{Z.key==="Enter"&&te(Z.target.value)},V=async()=>{A(!1)},K=B.useCallback(()=>{h.update(()=>{const Z=U.$getNodeByKey(e),q=U.$createParagraphNode().append(Vs.$createLinkNode(w).append(U.$createTextNode(w)));Z.replace(q),q.selectEnd()})},[h,e,w]),X=()=>{h.update(()=>{U.$getNodeByKey(e).remove()})},te=async Z=>{E(!0);let q;try{q=await p.fetchEmbed(Z,{type:"bookmark"})}catch{E(!1),A(!0);return}h.update(()=>{const W=U.$getNodeByKey(e);W.setUrl(q.url),W.setAuthor(q.metadata.author),W.setIcon(q.metadata.icon),W.setTitle(q.metadata.title),W.setDescription(q.metadata.description),W.setPublisher(q.metadata.publisher),W.setThumbnail(q.metadata.thumbnail)}),E(!1)},se=B.useCallback(async()=>{E(!0);let Z;try{Z=await p.fetchEmbed(t,{type:"bookmark"})}catch{E(!1),A(!0);return}h.update(()=>{const q=U.$getNodeByKey(e);q.setUrl(Z.url),q.setAuthor(Z.metadata.author),q.setIcon(Z.metadata.icon),q.setTitle(Z.metadata.title),q.setDescription(Z.metadata.description),q.setPublisher(Z.metadata.publisher),q.setThumbnail(Z.metadata.thumbnail)}),E(!1)},[]);return B.useEffect(()=>{if(f){O(t);try{se(t)}catch{K(t)}}},[]),fe(yt,{children:[C(eI,{author:n,captionEditor:l,captionEditorInitialState:u,description:o,handleClose:X,handlePasteAsLink:K,handleRetry:V,handleUrlChange:I,handleUrlSubmit:z,icon:i,isLoading:_,isSelected:v,publisher:s,thumbnail:a,title:r,url:t,urlError:T,urlInputValue:w,urlPlaceholder:"Paste URL to add bookmark content..."}),C(pn,{"data-kg-card-toolbar":"bookmark",isVisible:D,children:C(Rr,{onClose:()=>M(!1)})}),C(pn,{"data-kg-card-toolbar":"bookmark",isVisible:r&&v&&!D&&p.createSnippet,children:C(Fr,{children:C(qt,{dataTestId:"create-snippet",hide:!p.createSnippet,icon:"snippet",isActive:!1,label:"Snippet",onClick:()=>M(!0)})})})]})}class Yk extends tue{constructor(t={},i){super(t,i);ke(this,"__captionEditor");ke(this,"__captionEditorInitialState");ke(this,"__createdWithUrl");if(this.__createdWithUrl=!!t.url,this.__captionEditor=t.captionEditor||U.createEditor({nodes:Jn}),this.__captionEditorInitialState=t.captionEditorInitialState,!this.__captionEditorInitialState){const r=t.caption?`<p>${t.caption}</p>`:null;this.__captionEditorInitialState=bo({editor:U.createEditor({nodes:Jn}),initialHtml:r})}}getIcon(){return LS}createDOM(){return document.createElement("div")}getDataset(){const t=super.getDataset(),i=this.getLatest();return t.captionEditor=i.__captionEditor,t.captionEditorInitialState=i.__captionEditorInitialState,t}exportJSON(){const t=super.exportJSON();return this.__captionEditor&&this.__captionEditor.getEditorState().read(()=>{const i=ar.$generateHtmlFromNodes(this.__captionEditor,null),r=so(i);t.caption=r}),t}updateDOM(){return!1}decorate(){return C(Yi,{nodeKey:this.getKey(),children:C(Xue,{author:this.__author,captionEditor:this.__captionEditor,captionEditorInitialState:this.__captionEditorInitialState,createdWithUrl:this.__createdWithUrl,description:this.__description,icon:this.__icon,nodeKey:this.getKey(),publisher:this.__publisher,thumbnail:this.__thumbnail,title:this.__title,url:this.__url})})}}ke(Yk,"kgMenu",[{label:"Bookmark",desc:"Embed a link as a visual bookmark",Icon:LS,insertCommand:DL,matches:["bookmark"],queryParams:["url"]}]);const cI=n=>new Yk(n),Gpt="";function uI({captionEditor:n,captionEditorInitialState:e,html:t,isSelected:i,urlInputValue:r,urlPlaceholder:o,urlError:s,isLoading:a,handleUrlChange:l,handleUrlSubmit:u,handleRetry:f,handlePasteAsLink:h,handleClose:p}){return t?fe(yt,{children:[C(Yue,{dataTestId:"embed-iframe",html:t}),C(Gg,{captionEditor:n,captionEditorInitialState:e,captionPlaceholder:"Type caption for embed (optional)",dataTestId:"embed-caption",isSelected:i}),C("div",{className:"absolute inset-0 z-50 mt-0"})]}):C(JL,{dataTestId:"embed-url",handleClose:p,handlePasteAsLink:h,handleRetry:f,handleUrlChange:l,handleUrlSubmit:u,hasError:s,isLoading:a,placeholder:o,value:r})}function Yue({dataTestId:n,html:e}){const t=B.useRef(null),i=()=>{const o=t.current.contentDocument.body.firstChild;if(!o)return;if(o.tagName==="IFRAME"){const a=o.getAttribute("width");if(a.indexOf("%")===-1){const u=parseInt(o.getAttribute("height"));if(a&&u){const f=a/u,h=t.current.offsetWidth/f;o.style.height=`${h}px`,t.current.style.height=`${h}px`,o.style.width="100%";return}}const l=o.getAttribute("height");if(l.indexOf("%")===-1){t.current.style.height=`${l}px`;return}}const s=t.current.contentDocument.scrollingElement.scrollHeight;t.current.style.height=`${s}px`},r=()=>{const o=t.current.contentDocument.body;o.style.display="flex",o.style.margin="0",o.style.justifyContent="center",i()};return B.useEffect(()=>{const o=new ResizeObserver(i);return o.observe(t.current),function(){o.disconnect()}},[]),C("iframe",{ref:t,className:"bn miw-100 w-full","data-testid":n,srcDoc:e,tabIndex:-1,title:"embed-card-iframe",onLoad:r})}uI.propTypes={html:me.string};function Kue({nodeKey:n,url:e,html:t,createdWithUrl:i,embedType:r,metadata:o,captionEditor:s,captionEditorInitialState:a}){const[l]=Ye.useLexicalComposerContext(),{cardConfig:u}=B.useContext(bn),{isSelected:f}=B.useContext(or),[h,p]=B.useState(""),[v,w]=B.useState(!1),[O,_]=B.useState(!1),[E,T]=B.useState(!1),A=K=>{p(K.target.value)},D=async K=>{K.key==="Enter"&&V(K.target.value)},M=async()=>{_(!1)},I=B.useCallback(()=>{l.update(()=>{const K=U.$getNodeByKey(n),X=U.$createParagraphNode().append(Vs.$createLinkNode(h).append(U.$createTextNode(h)));K.replace(X),X.selectEnd()})},[l,n,h]),z=()=>{l.update(()=>{U.$getNodeByKey(n).remove()})},V=async K=>{w(!0);let X;const te=i?"":"embed";try{if(X=await u.fetchEmbed(K,{type:te}),X.type==="bookmark"){l.update(()=>{const se=U.$getNodeByKey(n),Z=cI({url:X.url});se.replace(Z)});return}}catch{w(!1),_(!0);return}l.update(()=>{const se=U.$getNodeByKey(n);se.setUrl(X.url),se.setMetadata(X),se.setEmbedType(X.type),se.setHtml(X.html)}),w(!1)};return B.useEffect(()=>{if(i){p(e);try{V(e)}catch{I(e)}}},[]),fe(yt,{children:[C(uI,{captionEditor:s,captionEditorInitialState:a,handleClose:z,handlePasteAsLink:I,handleRetry:M,handleUrlChange:A,handleUrlSubmit:D,html:t,isLoading:v,isSelected:f,metadata:o,url:e,urlError:O,urlInputValue:h,urlPlaceholder:"Paste URL to add embedded content..."}),C(pn,{"data-kg-card-toolbar":"embed",isVisible:E,children:C(Rr,{onClose:()=>T(!1)})}),C(pn,{"data-kg-card-toolbar":"embed",isVisible:t&&f&&!E&&u.createSnippet,children:C(Fr,{children:C(qt,{dataTestId:"create-snippet",hide:!u.createSnippet,icon:"snippet",isActive:!1,label:"Snippet",onClick:()=>T(!0)})})})]})}class Kk extends _ue{constructor(t={},i){super(t,i);ke(this,"__captionEditor");ke(this,"__captionEditorInitialState");ke(this,"__createdWithUrl");if(this.__createdWithUrl=!!t.url,this.__captionEditor=t.captionEditor||U.createEditor({nodes:Jn}),this.__captionEditorInitialState=t.captionEditorInitialState,!this.__captionEditorInitialState){const r=t.caption?`<p>${t.caption}</p>`:null;this.__captionEditorInitialState=bo({editor:U.createEditor({nodes:Jn}),initialHtml:r})}}getIcon(){return KS}createDOM(){return document.createElement("div")}getDataset(){const t=super.getDataset(),i=this.getLatest();return t.captionEditor=i.__captionEditor,t.captionEditorInitialState=i.__captionEditorInitialState,t}exportJSON(){const t=super.exportJSON();return this.__captionEditor&&this.__captionEditor.getEditorState().read(()=>{const i=ar.$generateHtmlFromNodes(this.__captionEditor,null),r=so(i);t.caption=r}),t}updateDOM(){return!1}decorate(){return C(Yi,{nodeKey:this.getKey(),children:C(Kue,{captionEditor:this.__captionEditor,captionEditorInitialState:this.__captionEditorInitialState,createdWithUrl:this.__createdWithUrl,embedType:this.__embedType,html:this.__html,metadata:this.__metadata,nodeKey:this.getKey(),url:this.__url})})}}ke(Kk,"kgMenu",[{section:"Embed",label:"Other...",desc:"Embed a link as a visual embed",Icon:KS,insertCommand:Ku,matches:["embed"],queryParams:["url"]},{section:"Embed",label:"Twitter",desc:"/twitter [tweet url]",Icon:GA,insertCommand:Ku,queryParams:["url"],matches:["twitter"]},{section:"Embed",label:"YouTube",desc:"/youtube [video url]",Icon:YA,insertCommand:Ku,queryParams:["url"],matches:["youtube"]},{section:"Embed",label:"Vimeo",desc:"/vimeo [video url]",Icon:XA,insertCommand:Ku,queryParams:["url"],matches:["vimeo"]},{section:"Embed",label:"CodePen",desc:"/codepen [pen url]",Icon:FA,insertCommand:Ku,queryParams:["url"],matches:["codepen"]},{section:"Embed",label:"Spotify",desc:"/spotify [track or playlist url]",Icon:ZA,insertCommand:Ku,queryParams:["url"],matches:["spotify"]},{section:"Embed",label:"SoundCloud",desc:"/soundcloud [track or playlist url]",Icon:VA,insertCommand:Ku,queryParams:["url"],matches:["soundcloud"]}]);const fI=n=>new Kk(n),O0=({selectedNode:n,newNode:e})=>{const t=U.$isParagraphNode(n),i=n.getTextContent()==="";n.getTopLevelElementOrThrow().insertAfter(e),t&&i&&n.remove();const r=U.$createNodeSelection();if(r.add(e.getKey()),U.$setSelection(r),!e.getNextSibling()){const o=U.$createParagraphNode();e.getTopLevelElementOrThrow().insertAfter(o)}};function Y4(n){var r;let[e]=n.getNodes();U.$isTextNode(e)&&(e=e.getParent());const t=e.getIndexWithinParent(),i=(r=e.getTopLevelElement())==null?void 0:r.getIndexWithinParent();return t===0&&i===0&&n.anchor.offset===0&&n.focus.offset===0}function lo(n){const e=U.$createNodeSelection();e.add(n.getKey()),U.$setSelection(e)}var Oo={},Cn=U,Hd=Ut;function Yg(n){throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?code=${n} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function dI(n){let e=1;for(n=n.getParent();n!=null;){if(hi(n)){if(n=n.getParent(),tn(n)){e++,n=n.getParent();continue}Yg(40)}break}return e}function K4(n){n=n.getParent(),tn(n)||Yg(40);let e=n;for(;e!==null;)e=e.getParent(),tn(e)&&(n=e);return n}function hI(n){let e=[];n=n.getChildren().filter(hi);for(let t=0;t<n.length;t++){let i=n[t],r=i.getFirstChild();tn(r)?e=e.concat(hI(r)):e.push(i)}return e}function Cl(n){return hi(n)&&tn(n.getFirstChild())}function Jue(n){for(;n.getNextSibling()==null&&n.getPreviousSibling()==null;){let e=n.getParent();if(e==null||!hi(n)&&!tn(n))break;n=e}n.remove()}function gI(n){return Ks().append(n)}function pI(n,e){return hi(n)&&(e.length===0||e.length===1&&n.is(e[0])&&n.getChildrenSize()===0)}function jd(n,e){n.splice(n.getChildrenSize(),0,e)}function mI(n,e){if(tn(n))return n;let t=n.getPreviousSibling(),i=n.getNextSibling(),r=Ks();return r.setFormat(n.getFormatType()),r.setIndent(n.getIndent()),jd(r,n.getChildren()),tn(t)&&e===t.getListType()?(t.append(r),n.remove(),tn(i)&&e===i.getListType()&&(jd(t,i.getChildren()),i.remove()),t):tn(i)&&e===i.getListType()?(i.getFirstChildOrThrow().insertBefore(r),n.remove(),i):(e=Co(e),e.append(r),n.replace(e),So(e),e)}function vI(n,e){var t=n.getLastChild();let i=e.getFirstChild();t&&i&&Cl(t)&&Cl(i)&&(vI(t.getFirstChild(),i.getFirstChild()),i.remove()),t=e.getChildren(),0<t.length&&(n.append(...t),So(n)),e.remove()}function So(n,e){if(n=e||n.getChildren(),n!==void 0)for(e=0;e<n.length;e++){let o=n[e];if(hi(o)){let s=o.getValue();var t=o,i=t.getParent(),r=1;for(i!=null&&(tn(i)?r=i.getStart():Yg(44)),t=t.getPreviousSiblings(),i=0;i<t.length;i++){let a=t[i];hi(a)&&!tn(a.getFirstChild())&&r++}s!==r&&o.setValue(r)}}}function efe(n){if(!Cl(n)){var e=n.getParent(),t=e?e.getParent():void 0,i=t?t.getParent():void 0;if(tn(i)&&hi(t)&&tn(e)){var r=e?e.getFirstChild():void 0,o=e?e.getLastChild():void 0;if(n.is(r))t.insertBefore(n),e.isEmpty()&&t.remove();else if(n.is(o))t.insertAfter(n),e.isEmpty()&&t.remove();else{var s=e.getListType();r=Ks();let a=Co(s);r.append(a),n.getPreviousSiblings().forEach(l=>a.append(l)),o=Ks(),s=Co(s),o.append(s),jd(s,n.getNextSiblings()),t.insertBefore(r),t.insertAfter(o),t.replace(n)}So(e),So(i)}}}let Jk=class DA extends Cn.ElementNode{static getType(){return"listitem"}static clone(e){return new DA(e.__value,e.__checked,e.__key)}constructor(e,t,i){super(i),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){let t=document.createElement("li"),i=this.getParent();return tn(i)&&i.getListType()==="check"&&bI(t,this,null),t.value=this.__value,yI(t,e.theme,this),t}updateDOM(e,t,i){let r=this.getParent();return tn(r)&&r.getListType()==="check"&&bI(t,this,e),t.value=this.__value,yI(t,i.theme,this),!1}static transform(){return e=>{let t=e.getParent();tn(t)&&(So(t),t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0))}}static importDOM(){return{li:()=>({conversion:tfe,priority:0})}}static importJSON(e){let t=new DA(e.value,e.checked);return t.setFormat(e.format),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){let i=e[t];if(Cn.$isElementNode(i)&&this.canMergeWith(i)){let r=i.getChildren();this.append(...r),i.remove()}else super.append(i)}return this}replace(e,t){if(hi(e))return super.replace(e);this.setIndent(0);let i=this.getParentOrThrow();if(!tn(i))return e;if(i.__first===this.getKey())i.insertBefore(e);else if(i.__last===this.getKey())i.insertAfter(e);else{let r=Co(i.getListType()),o=this.getNextSibling();for(;o;){let s=o;o=o.getNextSibling(),r.append(s)}i.insertAfter(e),e.insertAfter(r)}return t&&this.getChildren().forEach(r=>{e.append(r)}),this.remove(),i.getChildrenSize()===0&&i.remove(),e}insertAfter(e,t=!0){var i=this.getParentOrThrow();tn(i)||Yg(39);var r=this.getNextSiblings();if(hi(e))return t=super.insertAfter(e,t),e=e.getParentOrThrow(),tn(e)&&So(e),t;if(tn(e)&&e.getListType()===i.getListType()){for(i=e,e=e.getChildren(),r=e.length-1;0<=r;r--)i=e[r],this.insertAfter(i,t);return i}if(i.insertAfter(e,t),r.length!==0){let o=Co(i.getListType());r.forEach(s=>o.append(s)),e.insertAfter(o,t)}return e}remove(e){let t=this.getPreviousSibling(),i=this.getNextSibling();super.remove(e),t&&i&&Cl(t)&&Cl(i)?(vI(t.getFirstChild(),i.getFirstChild()),i.remove()):i&&(e=i.getParent(),tn(e)&&So(e))}insertNewAfter(e,t=!0){return e=Ks(this.__checked==null?void 0:!1),this.insertAfter(e,t),e}collapseAtStart(e){let t=Cn.$createParagraphNode();this.getChildren().forEach(s=>t.append(s));var i=this.getParentOrThrow(),r=i.getParentOrThrow();let o=hi(r);return i.getChildrenSize()===1?o?(i.remove(),r.select()):(i.insertBefore(t),i.remove(),i=e.anchor,e=e.focus,r=t.getKey(),i.type==="element"&&i.getNode().is(this)&&i.set(r,i.offset,"element"),e.type==="element"&&e.getNode().is(this)&&e.set(r,e.offset,"element")):(i.insertBefore(t),this.remove()),!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){return this.getLatest().__checked}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var e=this.getParent();if(e===null)return this.getLatest().__indent;e=e.getParentOrThrow();let t=0;for(;hi(e);)e=e.getParentOrThrow().getParentOrThrow(),t++;return t}setIndent(e){typeof e=="number"&&-1<e||Yg(117);let t=this.getIndent();for(;t!==e;)if(t<e){e:{var i=new Set;if(Cl(this)||i.has(this.getKey()))break e;let a=this.getParent();var r=this.getNextSibling(),o=this.getPreviousSibling();if(Cl(r)&&Cl(o)){if(o=o.getFirstChild(),tn(o)){o.append(this);var s=r.getFirstChild();tn(s)&&(s=s.getChildren(),jd(o,s),r.remove(),i.add(r.getKey())),So(o)}}else Cl(r)?(r=r.getFirstChild(),tn(r)&&(i=r.getFirstChild(),i!==null&&i.insertBefore(this),So(r))):Cl(o)?(r=o.getFirstChild(),tn(r)&&(r.append(this),So(r))):tn(a)&&(i=Ks(),s=Co(a.getListType()),i.append(s),s.append(this),o?o.insertAfter(i):r?r.insertBefore(i):a.append(i),So(s));tn(a)&&So(a)}t++}else efe(this),t--;return this}insertBefore(e){if(hi(e)){let t=this.getParentOrThrow();if(tn(t)){let i=this.getNextSiblings();So(t,i)}}return super.insertBefore(e)}canInsertAfter(e){return hi(e)}canReplaceWith(e){return hi(e)}canMergeWith(e){return Cn.$isParagraphNode(e)||hi(e)}extractWithChild(e,t){if(!Cn.$isRangeSelection(t))return!1;e=t.anchor.getNode();let i=t.focus.getNode();return this.isParentOf(e)&&this.isParentOf(i)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Co("bullet")}};function yI(n,e,t){let i=[],r=[];var o=(e=e.list)?e.listitem:void 0;if(e&&e.nested)var s=e.nested.listitem;if(o!==void 0&&(o=o.split(" "),i.push(...o)),e){o=t.getParent(),o=tn(o)&&o.getListType()==="check";let a=t.getChecked();o&&!a||r.push(e.listitemUnchecked),o&&a||r.push(e.listitemChecked),o&&i.push(a?e.listitemChecked:e.listitemUnchecked)}s!==void 0&&(s=s.split(" "),t.getChildren().some(a=>tn(a))?i.push(...s):r.push(...s)),0<r.length&&Hd.removeClassNamesFromElement(n,...r),0<i.length&&Hd.addClassNamesToElement(n,...i)}function bI(n,e,t){tn(e.getFirstChild())?(n.removeAttribute("role"),n.removeAttribute("tabIndex"),n.removeAttribute("aria-checked")):(n.setAttribute("role","checkbox"),n.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||n.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function tfe(n){return n=Hd.isHTMLElement(n)&&n.getAttribute("aria-checked")==="true",{node:Ks(n)}}function Ks(n){return Cn.$applyNodeReplacement(new Jk(void 0,n))}function hi(n){return n instanceof Jk}let J4=class yK extends Cn.ElementNode{static getType(){return"list"}static clone(e){return new yK(e.__listType||_I[e.__tag],e.__start,e.__key)}constructor(e,t,i){super(i),this.__listType=e=_I[e]||e,this.__tag=e==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e){let t=document.createElement(this.__tag);return this.__start!==1&&t.setAttribute("start",String(this.__start)),t.__lexicalListType=this.__listType,kI(t,e.theme,this),t}updateDOM(e,t,i){return e.__tag!==this.__tag?!0:(kI(t,i.theme,this),!1)}static importDOM(){return{ol:()=>({conversion:wI,priority:0}),ul:()=>({conversion:wI,priority:0})}}static importJSON(e){let t=Co(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){return{element:e}=super.exportDOM(e),e&&(this.__start!==1&&e.setAttribute("start",String(this.__start)),this.__listType==="check"&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let i=0;i<e.length;i++){var t=e[i];if(hi(t))super.append(t);else{let r=Ks();tn(t)||Cn.$isElementNode(t)&&(t=Cn.$createTextNode(t.getTextContent())),r.append(t),super.append(r)}}return So(this),this}extractWithChild(e){return hi(e)}};function kI(n,e,t){let i=[],r=[];var o=e.list;if(o!==void 0){let a=o[`${t.__tag}Depth`]||[];e=dI(t)-1;let l=e%a.length;var s=a[l];let u=o[t.__tag],f;if(o=o.nested,o!==void 0&&o.list&&(f=o.list),u!==void 0&&i.push(u),s!==void 0)for(s=s.split(" "),i.push(...s),s=0;s<a.length;s++)s!==l&&r.push(t.__tag+s);f!==void 0&&(t=f.split(" "),1<e?i.push(...t):r.push(...t))}0<r.length&&Hd.removeClassNamesFromElement(n,...r),0<i.length&&Hd.addClassNamesToElement(n,...i)}function nfe(n){let e=[];for(let i=0;i<n.length;i++){var t=n[i];hi(t)?(e.push(t),t=t.getChildren(),1<t.length&&t.forEach(r=>{tn(r)&&e.push(gI(r))})):e.push(gI(t))}return e}function wI(n){let e=n.nodeName.toLowerCase(),t=null;return e==="ol"?t=Co("number",n.start):e==="ul"&&(t=Hd.isHTMLElement(n)&&n.getAttribute("__lexicallisttype")==="check"?Co("check"):Co("bullet")),{after:nfe,node:t}}let _I={ol:"number",ul:"bullet"};function Co(n,e=1){return Cn.$applyNodeReplacement(new J4(n,e))}function tn(n){return n instanceof J4}let ife=Cn.createCommand("INSERT_UNORDERED_LIST_COMMAND"),rfe=Cn.createCommand("INSERT_ORDERED_LIST_COMMAND"),ofe=Cn.createCommand("INSERT_CHECK_LIST_COMMAND"),sfe=Cn.createCommand("REMOVE_LIST_COMMAND");Oo.$createListItemNode=Ks,Oo.$createListNode=Co,Oo.$getListDepth=dI,Oo.$handleListInsertParagraph=function(){var n=Cn.$getSelection();if(!Cn.$isRangeSelection(n)||!n.isCollapsed()||(n=n.anchor.getNode(),!hi(n)||n.getTextContent()!==""))return!1;var e=K4(n),t=n.getParent();tn(t)||Yg(40);let i=t.getParent(),r;if(Cn.$isRootOrShadowRoot(i))r=Cn.$createParagraphNode(),e.insertAfter(r);else if(hi(i))r=Ks(),i.insertAfter(r);else return!1;if(r.select(),e=n.getNextSiblings(),0<e.length){let o=Co(t.getListType());Cn.$isParagraphNode(r)?r.insertAfter(o):(t=Ks(),t.append(o),r.insertAfter(t)),e.forEach(s=>{s.remove(),o.append(s)})}return Jue(n),!0},Oo.$isListItemNode=hi,Oo.$isListNode=tn,Oo.INSERT_CHECK_LIST_COMMAND=ofe,Oo.INSERT_ORDERED_LIST_COMMAND=rfe,Oo.INSERT_UNORDERED_LIST_COMMAND=ife,Oo.ListItemNode=Jk,Oo.ListNode=J4,Oo.REMOVE_LIST_COMMAND=sfe,Oo.insertList=function(n,e){n.update(()=>{var t=Cn.$getSelection();if(Cn.$isRangeSelection(t)||Cn.DEPRECATED_$isGridSelection(t)){var i=t.getNodes();t=t.anchor.getNode();var r=t.getParent();if(pI(t,i))i=Co(e),Cn.$isRootOrShadowRoot(r)?(t.replace(i),r=Ks(),Cn.$isElementNode(t)&&(r.setFormat(t.getFormatType()),r.setIndent(t.getIndent())),i.append(r)):hi(t)&&(t=t.getParentOrThrow(),jd(i,t.getChildren()),t.replace(i));else for(t=new Set,r=0;r<i.length;r++){var o=i[r];if(Cn.$isElementNode(o)&&o.isEmpty()&&!t.has(o.getKey()))mI(o,e);else if(Cn.$isLeafNode(o))for(o=o.getParent();o!=null;){let a=o.getKey();if(tn(o)){if(!t.has(a)){var s=Co(e);jd(s,o.getChildren()),o.replace(s),So(s),t.add(a)}break}else{if(s=o.getParent(),Cn.$isRootOrShadowRoot(s)&&!t.has(a)){t.add(a),mI(o,e);break}o=s}}}}})},Oo.removeList=function(n){n.update(()=>{let e=Cn.$getSelection();if(Cn.$isRangeSelection(e)){var t=new Set,i=e.getNodes(),r=e.anchor.getNode();if(pI(r,i))t.add(K4(r));else for(r=0;r<i.length;r++){var o=i[r];Cn.$isLeafNode(o)&&(o=Hd.$getNearestNodeOfType(o,Jk),o!=null&&t.add(K4(o)))}for(let s of t){t=s,i=hI(s);for(let a of i)i=Cn.$createParagraphNode(),jd(i,a.getChildren()),t.insertAfter(i),t=i,a.__key===e.anchor.key&&e.anchor.set(i.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(i.getKey(),0,"element"),a.remove();s.remove()}}})};var jo=Oo;const Sr=U.createCommand("INSERT_CARD_COMMAND"),S0=U.createCommand("SELECT_CARD_COMMAND"),afe=U.createCommand("DESELECT_CARD_COMMAND"),El=U.createCommand("EDIT_CARD_COMMAND"),Kg=U.createCommand("DELETE_CARD_COMMAND"),xI=10;function OI(n){n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);const e="[data-lexical-editor] > *";return n.closest(e)}function eE(n,e){const t=U.$createNodeSelection();t.add(e),U.$setSelection(t),n.getRootElement().focus()}function C0(n,e){var i;const t=U.$getNodeByKey(e);(i=t==null?void 0:t.isEmpty)!=null&&i.call(t)&&lfe(n,t)}function lfe(n,e){if(U.$getRoot().getLastChild().is(e)){const t=U.$createParagraphNode();U.$getRoot().append(t),t.select()}else{const t=e.getNextSibling();U.$isDecoratorNode(t)?(lo(t),n.getRootElement().focus()):t.selectStart()}e.remove()}function cfe({editor:n,containerElem:e,cursorDidExitAtTop:t,isNested:i}){const{selectedCardKey:r,setSelectedCardKey:o,isEditingCard:s,setIsEditingCard:a}=Nd();return B.useEffect(()=>{const l=u=>{e.current&&!e.current.contains(u.target)&&n.update(()=>{const f=U.$getSelection();U.$isNodeSelection(f)&&U.$setSelection(null)},{tag:"history-merge"})};return i||window.addEventListener("mousedown",l),()=>{window.removeEventListener("mousedown",l)}},[n,e,i]),B.useEffect(()=>Ut.mergeRegister(n.registerUpdateListener(({editorState:l,tags:u})=>{if(u.has("collaboration")||u.has("card-export")||i||document.activeElement.closest("[data-lexical-decorator]"))return;const{isCardSelected:f,cardKey:h,cardNode:p}=l.read(()=>{const v=U.$getSelection();if(U.$isNodeSelection(v)&&v.getNodes().length===1&&F4(v.getNodes()[0])){const O=v.getNodes()[0];return{isCardSelected:!0,cardKey:O.getKey(),cardNode:O}}else return{isCardSelected:!1}});f&&!r?(o(h),a(!1)):f&&r!==h&&n.update(()=>{C0(n,r),o(h),a(!1)},{tag:"history-merge"}),!f&&r&&n.update(()=>{C0(n,r),o(null),a(!1)},{tag:"history-merge"}),f&&p.__openInEditMode&&(n.update(()=>{p.clearOpenInEditMode()},{tag:"history-merge"}),a(!0))}),n.registerCommand(Sr,({cardNode:l,openInEditMode:u})=>{let f;const h=U.$getSelection();if(U.$isRangeSelection(h))f=h.focus.getNode();else if(U.$isNodeSelection(h))f=h.getNodes()[0];else return!1;return f!==null&&(O0({selectedNode:f,newNode:l}),o(l.getKey()),u&&a(!0)),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(S0,({cardKey:l})=>{var u;if(r===l&&s){const f=U.$getNodeByKey(l);if((u=f.isEmpty)!=null&&u.call(f))return n.dispatchCommand(Kg,{cardKey:l}),!0}r&&r!==l&&C0(n,r),eE(n,l),o(l),a(!1)},U.COMMAND_PRIORITY_LOW),n.registerCommand(El,({cardKey:l})=>{var f;r&&r!==l&&C0(n,r),eE(n,l),o(l);const u=U.$getNodeByKey(l);(f=u.hasEditMode)!=null&&f.call(u)&&a(!0)},U.COMMAND_PRIORITY_LOW),n.registerCommand(afe,({cardKey:l})=>{C0(n,l),o(null),a(!1)},U.COMMAND_PRIORITY_LOW),n.registerCommand(Kg,({cardKey:l,direction:u="forward"})=>{const f=U.$getNodeByKey(l),h=f.getPreviousSibling(),p=f.getNextSibling();if(u==="backward"&&h)if(h.selectEnd)h.selectEnd();else if(U.$isDecoratorNode(h)){const v=U.$createNodeSelection();v.add(h.getKey()),U.$setSelection(v)}else f.selectPrevious();else if(p)if(p.selectStart)p.selectStart();else if(U.$isDecoratorNode(p)){const v=U.$createNodeSelection();v.add(p.getKey()),U.$setSelection(v)}else f.selectNext();else{const v=U.$createParagraphNode();U.$getRoot().append(v),v.select()}return f.remove(),n.getRootElement().focus(),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ENTER_COMMAND,l=>{var u,f;if(r&&(l.metaKey||l.ctrlKey)){l.preventDefault();const h=U.$getNodeByKey(r);if((u=h.hasEditMode)!=null&&u.call(h))if(s){if(n.getRootElement().focus({preventScroll:!0}),(f=h.isEmpty)!=null&&f.call(h)){if(U.$getRoot().getLastChild().is(h)){const p=U.$createParagraphNode();U.$getRoot().append(p),p.select()}else n.dispatchCommand(U.KEY_ARROW_DOWN_COMMAND);h.remove()}else eE(n,r);a(!1)}else a(!0);return!0}if(!l._fromNested&&document.activeElement!==n.getRootElement())return!1;if(!i&&r){l.preventDefault();const h=U.$getNodeByKey(r),p=U.$createParagraphNode();return h.getTopLevelElementOrThrow().insertAfter(p),p.select(),!0}},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_UP_COMMAND,l=>{if(l.shiftKey)return!1;if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(U.$isNodeSelection(u)){const h=u.getNodes()[0].getPreviousSibling();return!h&&t?(u.clear(),t(),!0):U.$isDecoratorNode(h)?(lo(h),!0):(l.preventDefault(),h.selectEnd(),!0)}if(U.$isRangeSelection(u)&&u.isCollapsed){const f=u.anchor.getNode().getTopLevelElement(),h=window.getSelection();if(t&&Y4(u))return t(),!0;const p=(f==null?void 0:f.getTextContent().trim())===""&&u.anchor.offset===0,v=u.anchor.offset===0&&u.focus.offset===0;if(p||v){const w=f.getPreviousSibling();if(U.$isDecoratorNode(w))return lo(w),!0}else{const O=h.getRangeAt(0).cloneRange().getClientRects();if(O.length>0){const _=O[1]||O[0],T=OI(h.anchorNode).getBoundingClientRect();if(Math.abs(_.top-T.top)<=xI){const D=f.getPreviousSibling();if(U.$isDecoratorNode(D))return lo(D),!0}}}}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_DOWN_COMMAND,l=>{if(l!=null&&l.shiftKey)return!1;if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(U.$isNodeSelection(u)){const f=u.getNodes()[0],h=f.getNextSibling();if(!h){const p=U.$createParagraphNode();return f.insertAfter(p),p.select(),!0}return U.$isDecoratorNode(h)?(lo(h),!0):(l==null||l.preventDefault(),h.selectStart(),!0)}if(U.$isRangeSelection(u)&&u.isCollapsed){const f=u.anchor.getNode().getTopLevelElement(),h=window.getSelection(),p=OI(h.anchorNode),v=(f==null?void 0:f.getTextContent().trim())===""&&u.anchor.offset===0,w=h.rangeCount!==0&&h.anchorNode===p&&h.anchorOffset===p.children.length-1&&h.focusOffset===p.children.length-1;if(v||w){const O=f.getNextSibling();if(U.$isDecoratorNode(O))return lo(O),!0}else{const _=h.getRangeAt(0).cloneRange().getClientRects();if(_.length>0){const E=_[0],T=p.getBoundingClientRect();if(Math.abs(E.bottom-T.bottom)<xI){const A=f.getNextSibling();if(U.$isDecoratorNode(A))return lo(A),!0}}}}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_LEFT_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(t){if(U.$isNodeSelection(u)&&!u.getNodes()[0].getPreviousSibling())return l.preventDefault(),u.clear(),t==null||t(),!0;if(u.isCollapsed&&Y4(u))return l.preventDefault(),t(),!0}if(!U.$isNodeSelection(u))return!1;const p=u.getNodes()[0].getTopLevelElement().getPreviousSibling();return U.$isDecoratorNode(p)?(l.preventDefault(),lo(p),!0):!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_RIGHT_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(!U.$isNodeSelection(u))return!1;const f=u.getNodes(),v=f[f.length-1].getTopLevelElement().getNextSibling();return U.$isDecoratorNode(v)?(l.preventDefault(),lo(v),!0):!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_MODIFIER_COMMAND,l=>{const u=l.key==="ArrowUp"||l.keyCode===38,f=l.key==="ArrowDown"||l.keyCode===40;if(l.metaKey&&(u||f)){const h=U.$getSelection(),p=U.$isNodeSelection(h),v=U.$isDecoratorNode(U.$getRoot().getFirstChild()),w=U.$isDecoratorNode(U.$getRoot().getLastChild());if(p||v||w){if(f){l.preventDefault();const O=U.$getRoot().getLastChild();return U.$isDecoratorNode(O)?(lo(O),!0):(O.selectEnd(),!0)}if(u){l.preventDefault();const O=U.$getRoot().getFirstChild();return U.$isDecoratorNode(O)?(lo(O),!0):(O.selectStart(),!0)}}}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_BACKSPACE_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;if(!i&&r)return l.preventDefault(),n.dispatchCommand(Kg,{cardKey:r,direction:"backward"}),!0;const u=U.$getSelection();if(U.$isRangeSelection(u)&&u.isCollapsed){const h=u.anchor.getNode(),p=h.getTopLevelElement(),v=p.getPreviousSibling(),w=u.anchor.offset===0&&u.focus.offset===0;if(w&&jo.$isListItemNode(h)&&h.getIndent()===0&&h.isEmpty())return l.preventDefault(),n.dispatchCommand(U.INSERT_PARAGRAPH_COMMAND),!0;if(U.$isParagraphNode(h)&&h.isEmpty()&&U.$isDecoratorNode(v))return p.remove(),lo(v),!0;if(w&&jo.$isListItemNode(h.getParent())){const O=h.getParent();if(O.getIndent()===0){l.preventDefault();const _=U.$createParagraphNode();return _.append(...O.getChildren()),O.replace(_),!0}}if(w&&U.$isDecoratorNode(v))return l.preventDefault(),v.remove(),!0}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_DELETE_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;if(r)return l.preventDefault(),n.dispatchCommand(Kg,{cardKey:r,direction:"forward"}),!0;const u=U.$getSelection();if(U.$isRangeSelection(u)&&u.isCollapsed){const f=u.anchor,h=f.getNode(),p=h.getTopLevelElement(),v=p.getNextSibling();if((p==null?void 0:p.getTextContent().trim())===""&&u.anchor.offset===0&&U.$isDecoratorNode(v))return l.preventDefault(),p.remove(),lo(v),!0;if((f.type==="element"&&U.$isElementNode(h)&&f.offset===h.getChildrenSize()||f.type==="text"&&f.offset===h.getTextContentSize())&&U.$isDecoratorNode(v))return l.preventDefault(),v.remove(),!0}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_TAB_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;if(l.shiftKey&&t){const u=U.$getSelection();if(U.$isNodeSelection(u))return l.preventDefault(),u.clear(),t(),!0;let f;if(u.isCollapsed){const p=u.anchor.getNode();f=U.$isTextNode(p)?[p.getParent()]:[p]}else f=u.getNodes();return f.some(p=>p.getIndent&&p.getIndent()>0)?!1:(l.preventDefault(),t(),!0)}},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ESCAPE_COMMAND,l=>{l.preventDefault(),r&&s&&(n._parentEditor||n).dispatchCommand(S0,{cardKey:r})},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.PASTE_COMMAND,l=>{var v;if(document.activeElement!==n.getRootElement()&&!i)return!1;const u=(v=l==null?void 0:l.clipboardData)==null?void 0:v.getData("text"),f=u==null?void 0:u.match(/^(https?:\/\/[^\s]+)$/),h=U.$getSelection(),p=h.getTextContent();if(f&&p.length>0){const w=f[1];if(U.$isRangeSelection(h)){const O=h.extract()[0],_=Vs.$createLinkNode(w),E=U.$createTextNode(p);E.setFormat(O.getFormat()),_.append(E),O.replace(_)}return!0}if(f&&!p.length>0){const w=f[1],O=fI({url:w});return n.dispatchCommand(Sr,{cardNode:O,createdWithUrl:!0}),!0}},U.COMMAND_PRIORITY_LOW))),B.useEffect(()=>{if(n.hasNodes([jo.ListNode]))return Ut.mergeRegister(n.registerNodeTransform(jo.ListNode,l=>{const u=l.getNextSibling();jo.$isListNode(u)&&u.getListType()===l.getListType()&&(l.append(...u.getChildren()),u.remove())}))},[n]),null}function SI({containerElem:n=document.querySelector(".koenig-editor"),cursorDidExitAtTop:e,isNested:t}){const[i]=Ye.useLexicalComposerContext();return cfe({editor:i,containerElem:n,cursorDidExitAtTop:e,isNested:t})}const Yi=({nodeKey:n,width:e,wrapperStyle:t,IndicatorIcon:i,children:r})=>{const[o]=Ye.useLexicalComposerContext(),[s,a]=B.useState(null),[l,u]=B.useState(null),[f,h]=B.useState(e||"regular"),p=B.useRef(null),{selectedCardKey:v,isEditingCard:w,isDragging:O}=Nd(),_=v===n,E=_&&w;B.useLayoutEffect(()=>{o.getEditorState().read(()=>{const A=U.$getNodeByKey(n);a(A.getType())})},[]),B.useEffect(()=>Ut.mergeRegister(o.registerCommand(U.CLICK_COMMAND,A=>p.current.contains(A.target)?(_&&!E?o.dispatchCommand(El,{cardKey:n}):_||o.dispatchCommand(S0,{cardKey:n}),!0):!1,U.COMMAND_PRIORITY_LOW)));const T=A=>{A?o.dispatchCommand(El,{cardKey:n}):_||o.dispatchCommand(S0,{cardKey:n})};return C(or.Provider,{value:{isSelected:_,captionHasFocus:l,isEditing:E,cardWidth:f,setCardWidth:h,setCaptionHasFocus:u,setEditing:T,nodeKey:n,cardContainerRef:p},children:C(jb,{ref:p,cardType:s,cardWidth:f,IndicatorIcon:i,isDragging:O,isEditing:E,isSelected:_,wrapperStyle:t,children:r})})};var Tl={},ew=x0,tw=Ho,Jg=Ut,we=U;function CI(n,e){return typeof document.caretRangeFromPoint<"u"?(n=document.caretRangeFromPoint(n,e),n===null?null:{node:n.startContainer,offset:n.startOffset}):document.caretPositionFromPoint!=="undefined"?(n=document.caretPositionFromPoint(n,e),n===null?null:{node:n.offsetNode,offset:n.offset}):null}let ep=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ufe=ep&&"documentMode"in document?document.documentMode:null,ffe=ep&&"InputEvent"in window&&!ufe?"getTargetRanges"in new window.InputEvent("input"):!1,dfe=ep&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),hfe=ep&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,gfe=ep&&/^(?=.*Chrome).*/i.test(navigator.userAgent),pfe=ep&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!gfe,tE=we.createCommand("DRAG_DROP_PASTE_FILE"),nE=class bK extends we.ElementNode{static getType(){return"quote"}static clone(e){return new bK(e.__key)}constructor(e){super(e)}createDOM(e){let t=document.createElement("blockquote");return Jg.addClassNamesToElement(t,e.theme.quote),t}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:mfe,priority:0})}}static importJSON(e){let t=iE();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){e=we.$createParagraphNode();let i=this.getDirection();return e.setDirection(i),this.insertAfter(e,t),e}collapseAtStart(){let e=we.$createParagraphNode();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}};function iE(){return we.$applyNodeReplacement(new nE)}let rE=class kK extends we.ElementNode{static getType(){return"heading"}static clone(e){return new kK(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){let t=this.__tag,i=document.createElement(t);return e=e.theme.heading,e!==void 0&&Jg.addClassNamesToElement(i,e[t]),i}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:tp,priority:0}),h2:()=>({conversion:tp,priority:0}),h3:()=>({conversion:tp,priority:0}),h4:()=>({conversion:tp,priority:0}),h5:()=>({conversion:tp,priority:0}),h6:()=>({conversion:tp,priority:0}),p:e=>(e=e.firstChild,e!==null&&EI(e)?{conversion:()=>({node:null}),priority:3}:null),span:e=>EI(e)?{conversion:()=>({node:np("h1")}),priority:3}:null}}static importJSON(e){let t=np(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){e=e?e.anchor.offset:0,e=0<e&&e<this.getTextContentSize()?np(this.getTag()):we.$createParagraphNode();let i=this.getDirection();return e.setDirection(i),this.insertAfter(e,t),e}collapseAtStart(){let e=this.isEmpty()?we.$createParagraphNode():np(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}};function EI(n){return n.nodeName.toLowerCase()==="span"?n.style.fontSize==="26pt":!1}function tp(n){n=n.nodeName.toLowerCase();let e=null;return(n==="h1"||n==="h2"||n==="h3"||n==="h4"||n==="h5"||n==="h6")&&(e=np(n)),{node:e}}function mfe(){return{node:iE()}}function np(n){return we.$applyNodeReplacement(new rE(n))}function vfe(n,e){n.preventDefault(),e.update(()=>{let t=we.$getSelection(),i=n instanceof InputEvent||n instanceof KeyboardEvent?null:n.clipboardData;i!=null&&(we.$isRangeSelection(t)||we.DEPRECATED_$isGridSelection(t))&&ew.$insertDataTransferForRichText(i,t,e)},{tag:"paste"})}async function yfe(n,e){await ew.copyToClipboard(e,n instanceof ClipboardEvent?n:null),e.update(()=>{let t=we.$getSelection();we.$isRangeSelection(t)?t.removeText():we.$isNodeSelection(t)&&t.getNodes().forEach(i=>i.remove())})}function E0(n){let e=null;if(n instanceof DragEvent?e=n.dataTransfer:n instanceof ClipboardEvent&&(e=n.clipboardData),e===null)return[!1,[],!1];var t=e.types;return n=t.includes("Files"),t=t.includes("text/html")||t.includes("text/plain"),[n,Array.from(e.files),t]}function TI(n,e){var t=we.$getSelection();if(we.$isRangeSelection(t)){var i=new Set;t=t.getNodes();for(let r=0;r<t.length;r++){let o=t[r],s=o.getKey();if(i.has(s))continue;let a=Jg.$getNearestBlockElementAncestorOrThrow(o),l=a.getKey();a.canInsertTab()?(n(o),i.add(s)):a.canIndent()&&!i.has(l)&&(i.add(l),e(a))}}}function nw(n){return n=we.$getNearestNodeFromDOMNode(n),we.$isDecoratorNode(n)}Tl.$createHeadingNode=np,Tl.$createQuoteNode=iE,Tl.$isHeadingNode=function(n){return n instanceof rE},Tl.$isQuoteNode=function(n){return n instanceof nE},Tl.DRAG_DROP_PASTE=tE,Tl.HeadingNode=rE,Tl.QuoteNode=nE,Tl.eventFiles=E0,Tl.registerRichText=function(n){return Jg.mergeRegister(n.registerCommand(we.CLICK_COMMAND,()=>{const e=we.$getSelection();return we.$isNodeSelection(e)?(e.clear(),!0):!1},0),n.registerCommand(we.DELETE_CHARACTER_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.deleteCharacter(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DELETE_WORD_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.deleteWord(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DELETE_LINE_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.deleteLine(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.CONTROLLED_TEXT_INSERTION_COMMAND,e=>{const t=we.$getSelection();if(typeof e=="string")we.$isRangeSelection(t)?t.insertText(e):we.DEPRECATED_$isGridSelection(t);else{if(!we.$isRangeSelection(t)&&!we.DEPRECATED_$isGridSelection(t))return!1;const i=e.dataTransfer;i!=null?ew.$insertDataTransferForRichText(i,t,n):we.$isRangeSelection(t)&&(e=e.data)&&t.insertText(e)}return!0},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.REMOVE_TEXT_COMMAND,()=>{const e=we.$getSelection();return we.$isRangeSelection(e)?(e.removeText(),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.FORMAT_TEXT_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.formatText(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.FORMAT_ELEMENT_COMMAND,e=>{var t=we.$getSelection();if(!we.$isRangeSelection(t)&&!we.$isNodeSelection(t))return!1;t=t.getNodes();for(const i of t)Jg.$getNearestBlockElementAncestorOrThrow(i).setFormat(e);return!0},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.INSERT_LINE_BREAK_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.insertLineBreak(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.INSERT_PARAGRAPH_COMMAND,()=>{const e=we.$getSelection();return we.$isRangeSelection(e)?(e.insertParagraph(),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.INDENT_CONTENT_COMMAND,()=>(TI(()=>{n.dispatchCommand(we.CONTROLLED_TEXT_INSERTION_COMMAND," ")},e=>{const t=e.getIndent();t!==10&&e.setIndent(t+1)}),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.OUTDENT_CONTENT_COMMAND,()=>(TI(e=>{we.$isTextNode(e)&&(e=e.getTextContent(),e[e.length-1]===" "&&n.dispatchCommand(we.DELETE_CHARACTER_COMMAND,!0))},e=>{const t=e.getIndent();t!==0&&e.setIndent(t-1)}),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_UP_COMMAND,e=>{var t=we.$getSelection();if(we.$isNodeSelection(t)&&!nw(e.target)){if(e=t.getNodes(),0<e.length)return e[0].selectPrevious(),!0}else if(we.$isRangeSelection(t)){if(t=we.$getAdjacentNode(t.focus,!0),we.$isDecoratorNode(t)&&!t.isIsolated()&&!t.isInline())return t.selectPrevious(),e.preventDefault(),!0;if(we.$isElementNode(t)&&!t.isInline()&&!t.canBeEmpty())return t.select(),e.preventDefault(),!0}return!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_DOWN_COMMAND,e=>{var t=we.$getSelection();if(we.$isNodeSelection(t)){if(e=t.getNodes(),0<e.length)return e[0].selectNext(0,0),!0}else if(we.$isRangeSelection(t)){let i=t.focus;if(i.key==="root"&&i.offset===we.$getRoot().getChildrenSize())return e.preventDefault(),!0;if(t=we.$getAdjacentNode(t.focus,!1),we.$isDecoratorNode(t)&&!t.isIsolated()&&!t.isInline())return t.selectNext(),e.preventDefault(),!0}return!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_LEFT_COMMAND,e=>{const t=we.$getSelection();if(we.$isNodeSelection(t)){var i=t.getNodes();if(0<i.length)return e.preventDefault(),i[0].selectPrevious(),!0}return we.$isRangeSelection(t)&&tw.$shouldOverrideDefaultCharacterSelection(t,!0)?(i=e.shiftKey,e.preventDefault(),tw.$moveCharacter(t,i,!0),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_RIGHT_COMMAND,e=>{const t=we.$getSelection();if(we.$isNodeSelection(t)&&!nw(e.target)){var i=t.getNodes();if(0<i.length)return e.preventDefault(),i[0].selectNext(0,0),!0}return we.$isRangeSelection(t)?(i=e.shiftKey,tw.$shouldOverrideDefaultCharacterSelection(t,!1)?(e.preventDefault(),tw.$moveCharacter(t,i,!1),!0):!1):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_BACKSPACE_COMMAND,e=>{if(nw(e.target))return!1;const t=we.$getSelection();if(!we.$isRangeSelection(t))return!1;e.preventDefault(),{anchor:e}=t;const i=e.getNode();return t.isCollapsed()&&e.offset===0&&!we.$isRootNode(i)&&0<Jg.$getNearestBlockElementAncestorOrThrow(i).getIndent()?n.dispatchCommand(we.OUTDENT_CONTENT_COMMAND,void 0):n.dispatchCommand(we.DELETE_CHARACTER_COMMAND,!0)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_DELETE_COMMAND,e=>{if(nw(e.target))return!1;const t=we.$getSelection();return we.$isRangeSelection(t)?(e.preventDefault(),n.dispatchCommand(we.DELETE_CHARACTER_COMMAND,!1)):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ENTER_COMMAND,e=>{const t=we.$getSelection();if(!we.$isRangeSelection(t))return!1;if(e!==null){if((hfe||dfe||pfe)&&ffe)return!1;if(e.preventDefault(),e.shiftKey)return n.dispatchCommand(we.INSERT_LINE_BREAK_COMMAND,!1)}return n.dispatchCommand(we.INSERT_PARAGRAPH_COMMAND,void 0)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ESCAPE_COMMAND,()=>{const e=we.$getSelection();return we.$isRangeSelection(e)?(n.blur(),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DROP_COMMAND,e=>{const[,t]=E0(e);if(0<t.length){var i=CI(e.clientX,e.clientY);if(i!==null){const{offset:o,node:s}=i;var r=we.$getNearestNodeFromDOMNode(s);if(r!==null){if(i=we.$createRangeSelection(),we.$isTextNode(r))i.anchor.set(r.getKey(),o,"text"),i.focus.set(r.getKey(),o,"text");else{const a=r.getParentOrThrow().getKey();r=r.getIndexWithinParent()+1,i.anchor.set(a,r,"element"),i.focus.set(a,r,"element")}i=we.$normalizeSelection__EXPERIMENTAL(i),we.$setSelection(i)}n.dispatchCommand(tE,t)}return e.preventDefault(),!0}return e=we.$getSelection(),!!we.$isRangeSelection(e)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DRAGSTART_COMMAND,e=>{[e]=E0(e);const t=we.$getSelection();return!(e&&!we.$isRangeSelection(t))},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DRAGOVER_COMMAND,e=>{var[t]=E0(e);const i=we.$getSelection();return t&&!we.$isRangeSelection(i)?!1:(t=CI(e.clientX,e.clientY),t!==null&&(t=we.$getNearestNodeFromDOMNode(t.node),we.$isDecoratorNode(t)&&e.preventDefault()),!0)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.COPY_COMMAND,e=>(ew.copyToClipboard(n,e instanceof ClipboardEvent?e:null),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.CUT_COMMAND,e=>(yfe(e,n),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.PASTE_COMMAND,e=>{const[,t,i]=E0(e);if(0<t.length&&!i)return n.dispatchCommand(tE,t),!0;if(we.isSelectionCapturedInDecoratorInput(e.target))return!1;const r=we.$getSelection();return we.$isRangeSelection(r)||we.DEPRECATED_$isGridSelection(r)?(vfe(e,n),!0):!1},we.COMMAND_PRIORITY_EDITOR))};var Js=Tl;function oE(n){const e=n._nodes,t=[];for(const[i,{klass:r}]of e)r.kgMenu&&t.push([i,r]);return t}const iw=U.createCommand();function $I(n,e){const t=n.type;return Object.keys(e).find(r=>e[r].includes(t))}function bfe(n,e){const t=n[Symbol.iterator]();return new Promise((i,r)=>{const o=[],s=()=>{const{done:a,value:l}=t.next();if(a)return i({processed:o});const u=new FileReader;u.addEventListener("error",r),u.addEventListener("load",()=>{const h=u.result,p=$I(l,e);typeof h=="string"&&o.push({type:p,file:l}),s()}),$I(l,e)?u.readAsDataURL(l):(console.error("unsupported file type"),s())};s()})}async function kfe(n,e){const t=oE(n);let i={};for(const[r,o]of t)r&&o.uploadType&&(i[r]=e[o.uploadType].mimeTypes);return{acceptableMimeTypes:i}}function AI(){const[n]=Ye.useLexicalComposerContext(),{fileUploader:e}=B.useContext(bn),t=B.useCallback(async i=>{if(!e)return;const{acceptableMimeTypes:r}=await kfe(n,e.fileTypes),{processed:o}=await bfe(i,r);o.forEach(s=>{n.dispatchCommand(iw,s)})},[n,e]);return B.useEffect(()=>n.registerCommand(U.DROP_COMMAND,i=>{const r=Array.from(i.dataTransfer.files);return r.length>0?(i.preventDefault(),i.stopPropagation(),n.dispatchCommand(Js.DRAG_DROP_PASTE,r),!0):!1},U.COMMAND_PRIORITY_HIGH),[n]),B.useEffect(()=>{const i=n.getRootElement(),r=s=>{!s.dataTransfer||s.target.closest("[data-kg-card]")||(s.stopPropagation(),s.preventDefault())},o=s=>{s.preventDefault()};return i.addEventListener("dragover",r),i.addEventListener("dragleave",o),()=>{i.removeEventListener("dragover",r),i.removeEventListener("dragleave",o)}},[n]),B.useEffect(()=>n.registerCommand(Js.DRAG_DROP_PASTE,async i=>{try{return n.focus(),await t(i)}catch(r){console.error(r)}},U.COMMAND_PRIORITY_LOW),[n,t]),null}function ef({handleDrop:n,disabled:e=!1}){const[t,i]=B.useState(null),[r,o]=B.useState(!1);return B.useEffect(()=>{const s=t;if(!s||e)return;s.addEventListener("dragenter",a),s.addEventListener("dragover",l),s.addEventListener("dragleave",u),s.addEventListener("drop",f);function a(p){h(p),o(!0)}function l(p){h(p),o(!0)}function u(p){h(p),o(!1)}function f(p){h(p);const{dataTransfer:v}=p;v.files&&v.files.length>0&&n(Array.from(v.files)),o(!1)}function h(p){p.preventDefault(),p.stopPropagation()}return()=>{s.removeEventListener("dragenter",a),s.removeEventListener("dragover",l),s.removeEventListener("dragleave",u),s.removeEventListener("drop",f)}},[n,t,e]),{setRef:i,isDraggedOver:r}}function rw({onFileChange:n,fileInputRef:e,mimeTypes:t=["image/*"],multiple:i=!1,disabled:r}){const o=t.join(",");return C("form",{onChange:n,children:C("input",{ref:e,accept:o,disabled:r,hidden:!0,multiple:i,name:"image-input",type:"file"})})}const wfe=n=>re.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",...n},re.createElement("path",{d:"M11.25 17.25a6 6 0 1 0 12 0 6 6 0 1 0-12 0Zm6 3v-6m0 0L15 16.5m2.25-2.25 2.25 2.25"}),re.createElement("path",{d:"M8.25 20.25h-6a1.5 1.5 0 0 1-1.5-1.5V2.25a1.5 1.5 0 0 1 1.5-1.5h10.629a1.5 1.5 0 0 1 1.06.439l2.872 2.872a1.5 1.5 0 0 1 .439 1.06V8.25"}),re.createElement("path",{d:"M3.75 12.75a2.25 1.5 0 1 0 4.5 0 2.25 1.5 0 1 0-4.5 0Z"}),re.createElement("path",{d:"m8.25 12.75-.295-5.929 1.062-.113A2.685 2.685 0 0 1 11.6 7.99"})),NI=n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...n},re.createElement("path",{d:"M12.001 15.75v-12m4.5 4.5-4.5-4.5-4.5 4.5m15.75 7.5v1.5a3 3 0 0 1-3 3h-16.5a3 3 0 0 1-3-3v-1.5",style:{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5px"}})),_fe={image:VS,gallery:QA,video:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...n},re.createElement("g",{strokeLinecap:"round",strokeWidth:2,fill:"none",stroke:"currentColor",strokeLinejoin:"round",className:"nc-icon-wrapper"},re.createElement("rect",{x:2,y:18,width:31,height:26,rx:4}),re.createElement("circle",{cx:8.5,cy:7.5,r:5.5}),re.createElement("circle",{cx:25.5,cy:9.5,r:3.5}),re.createElement("path",{"data-cap":"butt",d:"m33 27 13-6v20l-13-6"}))),audio:wfe,file:NI,product:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...n},re.createElement("g",{strokeLinecap:"round",strokeWidth:2,fill:"none",stroke:"currentColor",strokeLinejoin:"round",className:"nc-icon-wrapper"},re.createElement("path",{d:"M4 10h40"}),re.createElement("path",{d:"M44 46H4V10l8-8h24l8 8z"}),re.createElement("path",{d:"M34 20c0 5.5-4.5 10-10 10s-10-4.5-10-10"})))},xfe=({text:n})=>C("span",{className:"font-sans text-sm font-bold text-grey-800 transition-all group-hover:text-grey-800","data-kg-card-drag-text":!0,children:n});function tf({desc:n,icon:e,filePicker:t,size:i,borderStyle:r,isDraggedOver:o,errors:s=[],placeholderRef:a,dataTestId:l="media-placeholder",errorDataTestId:u="media-placeholder-errors",multiple:f=!1,...h}){const p=_fe[e];return C("div",{ref:a,className:"h-full border border-transparent",...h,"data-testid":l,children:C("div",{className:`relative flex h-full items-center justify-center border bg-grey-50 dark:bg-grey-950 ${i==="xsmall"?"before:pb-[12.5%]":"before:pb-[62.5%]"} ${r==="dashed"?"rounded border-dashed border-grey/40":"border-grey/20 dark:border-grey/10"}`,children:o?C(xfe,{text:`Drop ${f?"'em":"it"} like it's hot 🔥`}):C(yt,{children:fe("button",{className:`group flex cursor-pointer select-none items-center justify-center ${i==="xsmall"?"p-4":"flex-col p-20"}`,name:"placeholder-button",type:"button",onClick:t,children:[i==="xsmall"&&s.length>0||fe(yt,{children:[C(p,{className:`shrink-0 opacity-80 transition-all ease-linear hover:scale-105 group-hover:opacity-100 ${i==="large"?"h-20 w-20 text-grey":i==="small"?"h-14 w-14 text-grey":i==="xsmall"?"h-6 w-6 text-grey-700":"h-16 w-16 text-grey"} ${i==="xsmall"&&n?"mr-3":""}`}),C("p",{className:`min-w-[auto] font-sans text-sm font-normal text-grey opacity-80 transition-all group-hover:opacity-100 ${i==="xsmall"?"mt-0":"mt-4"}`,children:n})]}),s.map(v=>C("span",{className:`font-sans text-sm font-semibold text-red ${i==="xsmall"||"mt-3 max-w-[65%]"}`,"data-testid":u,children:v.message},v.message))]})})})})}tf.propTypes={icon:me.string,desc:me.string,size:me.oneOf(["xsmall","small","medium","large"]),borderStyle:me.oneOf(["solid","dashed"])};function Ia({style:n,fullWidth:e,bgStyle:t}){return C("div",{className:`rounded-full bg-grey-200 dark:bg-black ${e?"w-full":"mx-auto w-3/5"} ${t==="transparent"?"bg-white/30":"bg-grey-200"}`,"data-testid":"progress-bar",children:C("div",{className:"rounded-full bg-green py-1 text-center text-xs leading-none text-white",style:n})})}Ia.propTypes={style:me.object,fullWidth:me.bool};function Br({fileInputRef:n}){n.current.click()}function Ofe({src:n,alt:e,previewSrc:t,imageUploader:i}){var s;const r={width:`${(s=i.progress)==null?void 0:s.toFixed(0)}%`},o=i.progress.toFixed(0)<100?`upload in progress, ${i.progress}`:"";return fe("div",{children:[C("img",{alt:e||o,className:`mx-auto block ${t?"opacity-40":""}`,"data-testid":i.isLoading?"image-card-loading":"image-card-populated",src:t||n}),i.isLoading?C("div",{className:"absolute inset-0 flex min-w-full items-center justify-center overflow-hidden bg-white/50","data-testid":"upload-progress",children:C(Ia,{style:r})}):C(yt,{})]})}function Sfe({onFileChange:n,setFileInputRef:e,imageDragHandler:t,errors:i}){const r=B.useRef(null),o=s=>{r.current=s,e(r)};return fe(yt,{children:[C(tf,{desc:"Click to select an image",errors:i,filePicker:()=>Br({fileInputRef:r}),icon:"image",isDraggedOver:t.isDraggedOver,placeholderRef:t.setRef}),C(rw,{fileInputRef:o,filePicker:()=>Br({fileInputRef:r}),onFileChange:n})]})}const PI=({src:n,altText:e,previewSrc:t,imageUploader:i,onFileChange:r,setFileInputRef:o,imageDragHandler:s})=>t||n?C(Ofe,{alt:e,imageUploader:i,previewSrc:t,src:n}):C(Sfe,{errors:i.errors,imageDragHandler:s,setFileInputRef:o,onFileChange:r});function DI({isSelected:n,src:e,onFileChange:t,captionEditor:i,captionEditorInitialState:r,altText:o,setAltText:s,setFigureRef:a,fileInputRef:l,cardWidth:u,previewSrc:f,imageUploader:h,imageDragHandler:p}){const v=B.useRef(null);return B.useEffect(()=>{a&&a(v)},[v,a]),C(yt,{children:fe("figure",{ref:v,"data-kg-card-width":u,children:[C(PI,{altText:o,imageDragHandler:p,imageUploader:h,previewSrc:f,setFileInputRef:O=>{l&&(l.current=O.current)},src:e,onFileChange:t}),C(Gg,{altText:o||"",altTextPlaceholder:"Type alt text for image (optional)",captionEditor:i,captionEditorInitialState:r,captionPlaceholder:"Type caption for image (optional)",dataTestId:"image-caption-editor",isSelected:n,readOnly:!n,setAltText:s})]})})}PI.propTypes={src:me.string,altText:me.string,previewSrc:me.string,imageUploader:me.object,onFileChange:me.func,setFileInputRef:me.func,imageDragHandler:me.object},DI.propTypes={isSelected:me.bool,src:me.string,onFileChange:me.func,captionEditor:me.object,captionEditorInitialState:me.string,altText:me.string,setAltText:me.func,setFigureRef:me.func,fileInputRef:me.object,cardWidth:me.string,previewSrc:me.string,imageUploader:me.object,imageDragHandler:me.object};function sE({href:n,update:e,cancel:t}){const[i,r]=B.useState(n),o=B.useRef(null),s=B.useRef(null);B.useEffect(()=>{r(n)},[n]),B.useEffect(()=>{o.current.focus()},[]);const a=B.useCallback(u=>{s.current&&!s.current.contains(u.target)&&t()},[t]);B.useEffect(()=>(window.addEventListener("mousedown",a),()=>{window.removeEventListener("mousedown",a)}),[a]);const l=B.useCallback(u=>{u.key==="Escape"&&t()},[t]);return B.useEffect(()=>(window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l)}),[l]),fe("div",{ref:s,className:"relative m-0 flex h-[36px] min-w-[240px] items-center justify-evenly rounded bg-black py-0 font-sans text-md font-medium after:absolute after:top-[36px] after:left-[calc(50%-8px)] after:w-0 after:border-x-8 after:border-t-8 after:border-x-transparent after:border-t-black",children:[C("input",{ref:o,className:"mb-[1px] h-auto w-full rounded bg-black pl-3 pr-9 leading-loose text-white selection:bg-grey/40","data-testid":"link-input",placeholder:"Enter url",value:i,onInput:u=>{r(u.target.value)},onKeyDown:u=>{if(u.key==="Enter"){u.preventDefault(),e(i);return}}}),!!i&&C("button",{"aria-label":"Close",className:"absolute right-3 cursor-pointer",type:"button",onClick:u=>{u.stopPropagation(),r(""),o.current.focus()},children:C(w0,{className:"h-3 w-3 stroke-2 text-grey"})})]})}sE.propTypes={href:me.string};async function MI(n){const e=new Image;return e.src=n,new Promise((t,i)=>{e.onload=()=>{t({width:e.naturalWidth,height:e.naturalHeight})},e.onerror=i})}const ow=async(n,e,t,i)=>{if(!n)return;let r=URL.createObjectURL(n[0]);r&&await t.update(()=>{U.$getNodeByKey(e).setPreviewSrc(r)});const{width:o,height:s}=await MI(r),a=await i(n),l=a==null?void 0:a[0].url;await t.update(()=>{const u=U.$getNodeByKey(e);u.setImgWidth(o),u.setImgHeight(s),u.setSrc(l),u.setPreviewSrc(null)})},Cfe=async(n,e)=>{if(!n)return;const t=await e(n);return{imageSrc:t==null?void 0:t[0].url}};function T0(n){return/\.(gif)$/.test(n)}function Efe({nodeKey:n,initialFile:e,src:t,altText:i,captionEditor:r,captionEditorInitialState:o,triggerFileDialog:s,previewSrc:a,href:l}){var q;const[u]=Ye.useLexicalComposerContext(),[f,h]=B.useState(!1),{fileUploader:p,cardConfig:v}=B.useContext(bn),{isSelected:w,cardWidth:O,setCardWidth:_}=B.useContext(or),E=B.useRef(),T=B.useRef(),[A,D]=B.useState(!1),M=p.useFileUpload("image"),I=ef({handleDrop:Z});B.useEffect(()=>{(async J=>{J&&!t&&await ow([J],n,u,M.upload)})(e)},[]);const z=async W=>{const J=W.target.files;return u.update(()=>{U.$getNodeByKey(n).setSrc("")}),await ow(J,n,u,M.upload)},V=W=>{u.update(()=>{U.$getNodeByKey(n).setHref(W)})},K=W=>{u.update(()=>{U.$getNodeByKey(n).setAltText(W)})};B.useEffect(()=>{if(!s)return;const W=setTimeout(()=>{Br({fileInputRef:E}),u.update(()=>{U.$getNodeByKey(n).setTriggerFileDialog(!1)})});return()=>{clearTimeout(W)}});const X=W=>{u.update(()=>{U.$getNodeByKey(n).setCardWidth(W),_(W)})},te=()=>{h(!1),se()},se=()=>{u.update(()=>{const W=U.$createNodeSelection();W.add(n),U.$setSelection(W)})};async function Z(W){await ow(W,n,u,M.upload)}return fe(yt,{children:[C(DI,{altText:i,captionEditor:r,captionEditorInitialState:o,cardWidth:O,fileInputRef:E,imageDragHandler:I,imageUploader:M,isSelected:w,previewSrc:a,setAltText:K,src:t,onFileChange:z}),C(pn,{"data-kg-card-toolbar":"image",isVisible:f,children:C(sE,{cancel:te,href:l,update:W=>{V(W),te()}})}),C(pn,{"data-kg-card-toolbar":"image",isVisible:A,children:C(Rr,{onClose:()=>D(!1)})}),fe(pn,{"data-kg-card-toolbar":"image",isVisible:t&&w&&!f&&!A,children:[C(rw,{fileInputRef:T,mimeTypes:(q=p.fileTypes.image)==null?void 0:q.mimeTypes,onFileChange:z}),fe(Fr,{children:[C(qt,{hide:T0(t),icon:"imageRegular",isActive:O==="regular",label:"Regular",onClick:()=>X("regular")}),C(qt,{hide:T0(t),icon:"imageWide",isActive:O==="wide",label:"Wide",onClick:()=>X("wide")}),C(qt,{hide:T0(t),icon:"imageFull",isActive:O==="full",label:"Full",onClick:()=>X("full")}),C(Qr,{hide:T0(t)}),C(qt,{icon:"link",isActive:l===!0||!1,label:"Link",onClick:()=>{h(!0)}}),C(qt,{hide:T0(t),icon:"imageReplace",isActive:!1,label:"Replace",onClick:()=>Br({fileInputRef:T})}),C(Qr,{hide:!v.createSnippet}),C(qt,{dataTestId:"create-snippet",hide:!v.createSnippet,icon:"snippet",isActive:!1,label:"Snippet",onClick:()=>D(!0)})]})]})]})}const Tfe="https://tenor.googleapis.com",$fe="v2",Afe=600,sw={COMMON:"common",INVALID_API_KEY:"invalid_key"};function Nfe({config:n}){const[e,t]=B.useState([]),[i,r]=B.useState(null),[o,s]=B.useState(!1),[a,l]=B.useState(!1),[u,f]=B.useState([]),h=B.useRef(null),p=B.useRef(""),v=B.useRef([]),w=B.useRef(null),O=B.useRef(""),_=B.useRef(4),E=B.useRef([]),T=B.useRef([]);function A(ce){return O.current=ce,z(),ce?M(ce):I()}const D=qd.debounce((ce="")=>A(ce),Afe);async function M(ce){p.current="search",await se(p.current,{params:{q:ce,media_filter:"minimal"}})}async function I(){p.current="featured",await se(p.current,{params:{q:"excited",media_filter:"minimal"}})}function z(){T.current=[],h.current=null,V()}function V(){let ce=[],be=[];for(let oe=0;oe<_.current;oe+=1)ce[oe]=[],be[oe]=0;E.current=ce,v.current=be,T.current.length&&K()}function K(){T.current.forEach(ce=>{X(ce)})}function X(ce){const be=Math.min(...v.current),oe=v.current.indexOf(be);v.current[oe]+=300*ce.ratio,E.current[oe].push(ce),ce.columnIndex=oe,ce.columnRowIndex=E.current[oe].length-1}function te(ce,be){const[oe,F]=ce.media_formats.tinygif.dims;ce.ratio=F/oe,T.current.push(ce),ce.index=be,X(ce)}async function se(ce,be){const oe=`${$fe}/${ce}`.replace(/\/+/,"/"),F=new URL(oe,Tfe),L=new URLSearchParams(be.params);return L.set("key",n.googleApiKey),L.set("client_key","ghost-editor"),L.set("contentfilter",ne()),F.search=L.toString(),w.current=arguments,r(null),s(!0),fetch(F).then(he=>Z(he)).then(he=>he.json()).then(he=>q(he)).then(he=>W(he)).then(()=>{t(E.current),f(T.current)}).catch(he=>{!be.ignoreErrors&&!i&&r(sw.COMMON),i&&i.startsWith("API key not valid")&&r(sw.INVALID_API_KEY),console.error(he)}).finally(()=>{s(!1),l(!1)})}async function Z(ce){if(ce.status>=200&&ce.status<300)return ce;let be;ce.headers.map["content-type"].startsWith("application/json")?be=await ce.json().then(F=>F.error.message||F.error):ce.headers.map["content-type"]==="text/xml"&&(be=await ce.text()),r(be);const oe=new Error(be);throw oe.response=ce,oe}async function q(ce){return h.current=ce.next,ce}async function W(ce){return ce.results.forEach((oe,F)=>te(oe,F)),ce}function J(){if(!o){if(!T.current.length)return I();if(h.current!==null){const ce={pos:h.current,media_filter:"minimal"};return p.current==="search"&&(ce.q=O),l(!0),se(p.current,{params:ce})}}}function ne(){return n.contentFilter||"off"}function G(ce){_.current=ce,V(),t(E.current)}return{updateSearch:D,isLoading:o,isLazyLoading:a,error:i,loadNextPage:J,columns:e,changeColumnCount:G,gifs:u}}function Pfe({error:n}){return n===sw.COMMON?C("p",{children:"Uh-oh! Trouble reaching the Tenor API, please check your connection"}):n===sw.INVALID_API_KEY?fe("p",{children:["This version of the Tenor API is no longer supported. Please update your API key by following our",C("a",{href:"https://ghost.org/docs/config/#tenor",rel:"noopener noreferrer",target:"_blank",children:" documentation here"}),"."]}):C("p",{children:n})}function Dfe({gif:n,onClick:e,highlightedGif:t={}}){const i=B.useRef(null),r=n.media_formats.tinygif;B.useEffect(()=>{var a,l;t.id===n.id?(a=i.current)==null||a.focus():(l=i.current)==null||l.blur()},[n.id,t.id]);const o=()=>{e(n)};return C("button",{ref:i,className:"cursor-pointer border-2 border-transparent focus:border-green-600","data-tenor-index":n.index,type:"button",onClick:o,children:C("img",{alt:r.content_description,height:r.dims[1],src:r.url,width:r.dims[0]})})}function Mfe({isLazyLoading:n}){return n?C("div",{className:"inset-y-0 w-full p-6 text-center",children:C("div",{className:"inline-block h-[50px] w-[50px] animate-spin rounded-full border border-black/10 before:z-10 before:mt-[7px] before:block before:h-[7px] before:w-[7px] before:rounded-full before:bg-grey-800"})}):C("div",{className:"absolute inset-y-0 left-0 flex w-full items-center justify-center overflow-hidden",children:C("div",{className:"relative inline-block h-[50px] w-[50px] animate-spin rounded-full border border-black/10 before:z-10 before:mt-[7px] before:block before:h-[7px] before:w-[7px] before:rounded-full before:bg-grey-800"})})}const LI=n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",strokeWidth:1.5,viewBox:"0 0 24 24",...n},re.createElement("title",null,"kg-search"),re.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M1.472 13.357a9.063 9.063 0 1 0 16.682-7.09 9.063 9.063 0 1 0-16.682 7.09Zm14.749 2.863 7.029 7.03"})),Lfe=540,Ife=940,Rfe=({onGifInsert:n,onClickOutside:e,updateSearch:t,columns:i,isLoading:r,isLazyLoading:o,error:s,changeColumnCount:a,loadNextPage:l,gifs:u})=>{const f=B.useRef(null),h=B.useRef(null),[p,v]=B.useState(void 0);B.useEffect(()=>{t()},[]),B.useEffect(()=>{if(!f.current)return;const G=new ResizeObserver(ce=>{const[be]=ce,F=(Array.isArray(be.contentBoxSize)?be.contentBoxSize[0]:be.contentBoxSize).inlineSize;let L=4;F<=Lfe?L=2:F<=Ife&&(L=3),a(L)});return G.observe(f.current),()=>{G==null||G.disconnect()}},[]),B.useEffect(()=>(document.addEventListener("keydown",X),()=>{document.removeEventListener("keydown",X)}),[X]),B.useEffect(()=>{const G=ce=>{f.current&&!f.current.contains(ce.target)&&e()};return window.addEventListener("mousedown",G),()=>{window.removeEventListener("mousedown",G)}},[e]);function w(G){const ce=G.media_formats.gif,be={src:ce.url,width:ce.dims[0],height:ce.dims[1]};n(be)}const O=G=>{t(G.target.value)},_=G=>{const ce=G.target;ce.scrollTop+ce.clientHeight>=ce.scrollHeight-1e3&&l()};function E(){var G;(G=h.current)==null||G.focus()}function T(){v(u[0])}function A(){p!==u[u.length-1]&&v(u[p.index+1])}function D(){p.index===0&&E(),v(u[p.index-1])}function M(){const G=i[p.columnIndex][p.columnRowIndex+1];G&&v(G)}function I(){const G=i[p.columnIndex][p.columnRowIndex-1];G?v(G):E()}function z(G){var De;const be=document.querySelector(`[data-tenor-index="${p.index}"]`).getBoundingClientRect();let oe;G==="left"?oe=be.left-be.width/2:oe=be.right+be.width/2;let F=be.top+be.height/3,L,he=0;for(;!L;){let $e=(De=document.elementFromPoint(oe,F))==null?void 0:De.closest("[data-tenor-index]");if(($e==null?void 0:$e.dataset.tenorIndex)!==void 0){L=$e;break}if(he+=1,F-=5,he>10)break}L&&v(u[L.dataset.tenorIndex])}function V(){p.columnIndex!==i.length-1&&z("right")}function K(){if(p.index===0)return E();p.columnIndex!==0&&z("left")}function X(G){switch(G.key){case"Tab":return te(G);case"ArrowLeft":return se(G);case"ArrowRight":return Z(G);case"ArrowUp":return q(G);case"ArrowDown":return W(G);case"Enter":return J(G);default:return null}}function te(G){if(G.shiftKey){if(p)return G.preventDefault(),D()}else{if((G==null?void 0:G.target.tagName)==="INPUT")return G.preventDefault(),G.target.blur(),T();if(p)return G==null||G.preventDefault(),A()}}function se(G){p&&(G.preventDefault(),K())}function Z(G){p&&(G.preventDefault(),V())}function q(G){p&&(G.preventDefault(),I())}function W(G){if(G.target.tagName==="INPUT")return G.preventDefault(),G.target.blur(),T();p&&(G.preventDefault(),M())}function J(G){if(G.preventDefault(),G.target.tagName==="INPUT")return G.target.blur(),T();if(p)return w(p)}return fe("div",{ref:f,className:"flex h-[540px] flex-col rounded border border-grey-200 bg-grey-50 dark:border-none dark:bg-grey-900","data-testid":"tenor-selector",onClick:G=>G.stopPropagation(),children:[C("header",{className:"p-6",children:fe("div",{className:"relative w-full",children:[C(LI,{className:"absolute top-1/2 left-4 h-4 w-4 -translate-y-2 text-grey-500 dark:text-grey-800"}),C("input",{ref:h,className:"h-10 w-full rounded-full border border-grey-300 pr-8 pl-10 font-sans text-md font-normal text-black focus:border-green focus:shadow-insetgreen dark:border-grey-800 dark:bg-grey-950 dark:text-white dark:placeholder:text-grey-800 dark:focus:border-green",placeholder:"Search Tenor for GIFs",autoFocus:!0,onChange:O})]})}),C("div",{className:"relative h-full overflow-hidden",children:fe("div",{className:"h-full overflow-auto px-6",onScroll:_,children:[!s&&!(r&&!o)&&C("div",{className:"flex gap-4",children:i.map((G,ce)=>C("section",{className:"flex grow basis-0 flex-col justify-start gap-4",children:G.map(be=>C(Dfe,{gif:be,highlightedGif:p,onClick:w},be.id))},ce))}),!!r&&!s&&C(Mfe,{isLazyLoading:o}),!!s&&C("div",{"data-testid":"tenor-selector-error",children:C(Pfe,{error:s})})]})})]})},Ffe=({nodeKey:n})=>{const{cardConfig:e}=B.useContext(bn),t=Nfe({config:e.tenor}),[i]=Ye.useLexicalComposerContext();return B.useEffect(()=>{const s=a=>{a.key==="Escape"&&i.dispatchCommand(Kg,{cardKey:n})};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]),C(Rfe,{onClickOutside:()=>{i.dispatchCommand(Kg,{cardKey:n})},onGifInsert:async s=>{i.dispatchCommand(zI,s)},...t})};function aw({children:n,to:e}){const t=e||document.body;if(!t)return n;function i(r){r.stopPropagation()}return Ec.createPortal(C("div",{className:"koenig-lexical",onMouseDown:i,children:n}),t)}const Qfe={heart:n=>re.createElement("svg",{viewBox:"0 0 32 32",...n},re.createElement("title",null,"unsplash-heart"),re.createElement("path",{d:"M17.4 29c-.8.8-2 .8-2.8 0L2.3 16.2C-.8 13.1-.8 8 2.3 4.8c3.1-3.1 8.2-3.1 11.3 0L16 7.6l2.3-2.8c3.1-3.1 8.2-3.1 11.3 0 3.1 3.1 3.1 8.2 0 11.4L17.4 29z"})),download:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...n},re.createElement("title",null,"download"),re.createElement("path",{d:"M20 5.5l-8 8-8-8m-3.5 13h23",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10,fill:"none"}))};function aE({icon:n,label:e,...t}){const i=Qfe[n];return fe("a",{className:"flex h-8 shrink-0 cursor-pointer items-center rounded-md bg-white py-2 px-3 font-sans text-sm font-medium leading-6 text-grey-700 opacity-90 transition-all ease-in-out first-of-type:mr-3 hover:opacity-100",type:"button",onClick:r=>r.stopPropagation(),...t,children:[n&&C(i,{className:`h-4 w-4 fill-red stroke-[3px] ${e&&"mr-1"}`}),e&&C("span",{children:e})]})}function II({payload:n,srcUrl:e,links:t,likes:i,user:r,alt:o,urls:s,height:a,width:l,zoomed:u,insertImage:f,selectImg:h}){return fe("div",{className:`relative mb-6 block bg-grey-100 ${u?"h-full w-[max-content] cursor-zoom-out":"w-full cursor-zoom-in"}`,"data-kg-unsplash-gallery-item":!0,onClick:p=>{p.stopPropagation(),h(u?null:n)},children:[C("img",{alt:o,className:`${u?"h-full w-auto object-contain":""}`,height:a,loading:"lazy",src:e,width:l,"data-kg-unsplash-gallery-img":!0}),fe("div",{className:"absolute inset-0 flex flex-col justify-between bg-gradient-to-b from-black/5 via-black/5 to-black/30 p-5 opacity-0 transition-all ease-in-out hover:opacity-100",children:[fe("div",{className:"flex items-center justify-end",children:[C(aE,{"data-kg-button":"unsplash-like",href:`${t.html}/?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit`,icon:"heart",label:i,rel:"noopener noreferrer",target:"_blank"}),C(aE,{"data-kg-button":"unsplash-download",href:`${t.download}/?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit&amp;force=true`,icon:"download"})]}),fe("div",{className:"flex items-center justify-between",children:[fe("div",{className:"flex items-center",children:[C("img",{alt:"author",className:"mr-2 h-8 w-8 rounded-full",src:r.profile_image.small}),C("div",{className:"mr-2 truncate font-sans text-sm font-medium text-white",children:r.name})]}),C(aE,{label:"Insert image","data-kg-unsplash-insert-button":!0,onClick:p=>{p.stopPropagation(),f({src:s.regular.replace(/&w=1080/,"&w=2000"),caption:`Photo by ${r.name} on Unsplash`,height:a,width:l,alt:o,links:t})}})]})]})]})}function RI({payload:n,insertImage:e,selectImg:t,zoomed:i}){return C("div",{className:"flex h-full grow basis-0 justify-center","data-kg-unsplash-zoomed":!0,onClick:()=>t(null),children:C(II,{alt:n.alt_description,height:n.height,insertImage:e,likes:n.likes,links:n.links,payload:n,selectImg:t,srcUrl:n.urls.regular,urls:n.urls,user:n.user,width:n.width,zoomed:i})})}RI.propTypes={payload:me.object,insertImage:me.func,selectImg:me.func,zoomed:me.object||me.bool,srcUrl:me.string,alt:me.string,links:me.object,likes:me.number,user:me.object,urls:me.object,height:me.number,width:me.number};function Bfe(){return C("div",{className:"absolute inset-y-0 left-0 flex w-full items-center justify-center overflow-hidden pb-[8vh]","data-kg-loader":!0,children:C("div",{className:"relative inline-block h-[50px] w-[50px] animate-spin rounded-full border border-black/10 before:z-10 before:mt-[7px] before:block before:h-[7px] before:w-[7px] before:rounded-full before:bg-grey-800"})})}function zfe(n){return C("div",{className:"mr-6 flex grow basis-0 flex-col justify-start last-of-type:mr-0",children:n.children})}function Wfe(n){return n!=null&&n.columns?n==null?void 0:n.columns.map((e,t)=>C(zfe,{children:e.map(i=>C(II,{alt:i.alt_description,height:i.height,insertImage:n==null?void 0:n.insertImage,likes:i.likes,links:i.links,payload:i,selectImg:n==null?void 0:n.selectImg,srcUrl:i.urls.regular,urls:i.urls,user:i.user,width:i.width,zoomed:n==null?void 0:n.zoomed},i.id))},t)):null}function lE(n){return C("div",{className:"relative h-full overflow-hidden","data-kg-unsplash-gallery":!0,children:fe("div",{ref:n.galleryRef,className:`flex h-full w-full justify-center overflow-auto px-20 ${n!=null&&n.zoomed?"pb-10":""}`,"data-kg-unsplash-gallery-scrollref":!0,children:[n.children,(n==null?void 0:n.isLoading)&&C(Bfe,{})]})})}function Ufe({zoomed:n,error:e,galleryRef:t,isLoading:i,dataset:r,selectImg:o,insertImage:s}){return n?C(lE,{galleryRef:t,zoomed:n,children:C(RI,{insertImage:s,payload:n,selectImg:o,zoomed:n})}):e?C(lE,{galleryRef:t,zoomed:n,children:fe("div",{className:"flex h-full flex-col items-center justify-center",children:[C("h1",{className:"mb-4 text-2xl font-bold",children:"Error"}),C("p",{className:"text-lg font-medium",children:e})]})}):C(lE,{dataset:r,galleryRef:t,isLoading:i,zoomed:n,children:C(Wfe,{columns:r,insertImage:s,selectImg:o,zoomed:n})})}function FI({closeModal:n,handleSearch:e,children:t,galleryRef:i}){return fe(yt,{children:[C("div",{className:"fixed inset-0 z-40 h-[100vh] bg-black opacity-60"}),fe("div",{ref:i,className:"not-kg-prose fixed inset-8 z-50 overflow-hidden rounded bg-white shadow-xl","data-kg-modal":"unsplash",children:[C("button",{className:"absolute top-6 right-6 cursor-pointer",type:"button",children:C(w0,{className:"h-4 w-4 stroke-2 text-grey-400","data-kg-modal-close-button":!0,onClick:()=>n()})}),fe("div",{className:"flex h-full flex-col",children:[fe("header",{className:"flex shrink-0 items-center justify-between py-10 px-20",children:[fe("h1",{className:"flex items-center gap-2 font-sans text-3xl font-bold text-black",children:[C(n3,{className:"mb-1"}),"Unsplash"]}),fe("div",{className:"relative w-full max-w-sm",children:[C(LI,{className:"absolute top-1/2 left-4 h-4 w-4 -translate-y-2 text-grey-700"}),C("input",{className:"h-10 w-full rounded-full border border-grey-300 pr-8 pl-10 font-sans text-md font-normal text-black focus:border-grey-400 focus-visible:outline-none",placeholder:"Search free high-resolution photos",autoFocus:!0,"data-kg-unsplash-search":!0,onChange:e})]})]}),t]})]})]})}FI.propTypes={closeModal:me.func,handleSearch:me.func};class qfe{constructor(e){this.columnCount=e||3,this.columns=null,this.columnHeights=null}reset(){let e=[],t=[];for(let i=0;i<this.columnCount;i+=1)e[i]=[],t[i]=0;this.columns=e,this.columnHeights=t}addColumns(){for(let e=0;e<this.columnCount;e++)this.columns.push([]),this.columnHeights.push(0)}addPhotoToColumns(e){this.columns||this.reset();let t=Math.min(...this.columnHeights),i=this.columnHeights.indexOf(t);this.columnHeights[i]+=300*e.ratio,this.columns[i].push(e)}getColumns(){return this.columns}changeColumnCount(e){e!==this.columnCount&&(this.columnCount=e,this.reset())}}const cE=new qfe(3);class Hfe{constructor({API_URL:e,HEADERS:t}){this.API_URL=e||"https://api.unsplash.com",this.HEADERS=t,this.photos=[],this._pagination=[],this.page=1,this.error=null,this.search_is_running=!1,this.request_is_running=!1,this.search_term="",this._lastRequestUrl="",this.isLoading=!1}extractPagination(e){e=e||e.results;let t={},i=new RegExp('<(.*)>; rel="(.*)"'),r=[];for(let o of e.headers.entries())o[0]==="link"&&r.push(o[1]);return r&&r.toString().split(",").forEach(o=>{if(o){let s=i.exec(o);t[s[2]]=s[1]}}),this._pagination=t,e}async checkStatus(e){if(e.status>=200&&e.status<300)return e;let t="",i;return e.headers.map["content-type"]==="application/json"?i=e.json().then(r=>r.errors[0]):e.headers.map["content-type"]==="text/xml"&&(i=e.text()),i.then(r=>{e.status===403&&e.headers.map["x-ratelimit-remaining"]==="0"&&(t="Unsplash API rate limit reached, please try again later."),t=t||r||`Error ${e.status}: Uh-oh! Trouble reaching the Unsplash API`,this.error=t;let o=new Error(t);throw o.response=e,o})}async makeRequest(e){if(this.request_is_running)return;this._lastRequestUrl=e;const t={method:"GET",headers:this.HEADERS};return this.request_is_running=!0,this.isLoading=!0,await fetch(e,t).then(i=>this.checkStatus(i)).then(i=>this.extractPagination(i)).then(i=>(this.request_is_running=!1,i.json())).catch(i=>this.error=i)}async loadNew(){this.reset();const e=`${this.API_URL}/photos?per_page=30`,t=await this.makeRequest(e);await this.addPhotosFromResponse(t)}async addPhotosFromResponse(e){(e.results||e).forEach(i=>{this.addPhoto(i)})}async addPhoto(e){e.ratio=e.width/e.height,this.photos.push(e),cE.addPhotoToColumns(e)}async loadNextPage(){if(!this.request_is_running&&!this.search_is_running&&this.photos.length!==0&&this._pagination.next){const e=`${this._pagination.next}`,t=await this.makeRequest(e);this.addPhotosFromResponse(t)}}async updateSearch(e){e!==this.search_term&&(this.request_is_running||(this.reset(),this.search_term=e,e?await this.search(e):await this.loadNew()))}async search(e){if(this.search_is_running!==!0){this.search_is_running=!0;const t=`${this.API_URL}/search/photos?query=${e}&per_page=30`,i=await this.makeRequest(t);i&&(this.addPhotosFromResponse(i),this.search_is_running=!1)}}triggerDownload(e){e.links.download_location&&this.makeRequest(e.links.download_location)}getPhotos(){return this.photos}clearPhotos(){this.photos=[]}getColumns(){return cE.getColumns()}reset(){this.clearPhotos(),cE.reset(),this.pagination=[]}setSearchTerm(e){this.search_term=e}}const jfe="https://api.unsplash.com",QI=({onClose:n,onImageInsert:e,unsplashConf:t})=>{const i=B.useMemo(()=>new Hfe({API_URL:jfe,HEADERS:t.defaultHeaders}),[t.defaultHeaders]),r=B.useRef(null),[o,s]=B.useState(0),[a,l]=B.useState(0),[u,f]=B.useState(i.search_is_running||!0),h=B.useRef(!1),[p,v]=B.useState(""),[w,O]=B.useState(null),[_,E]=B.useState(i.getColumns()||[]);B.useEffect(()=>{w===null&&a!==0&&(r.current.scrollTop=a,l(0))},[w,o,a]),B.useEffect(()=>{const V=r.current;if(!w)return V&&V.addEventListener("scroll",()=>{s(V.scrollTop)}),()=>{V&&V.removeEventListener("scroll",()=>{s(V.scrollTop)})}},[r,w]);const T=B.useCallback(async()=>{if(h.current===!1||p.length===0){E([]),await i.clearPhotos(),await i.loadNew();const V=i.getColumns();E(V),r.current.scrollTop!==0&&(r.current.scrollTop=0),f(!1)}},[i,p]),A=async V=>{const K=V.target.value;K.length>2&&(O(null),v(K)),K.length===0&&(v(""),h.current=!1,await T())},D=B.useCallback(async()=>{if(p){f(!0),i.clearPhotos(),await i.updateSearch(p);const V=i.getColumns();E(V),r.current.scrollTop!==0&&(r.current.scrollTop=0),f(!1)}},[p,i]);B.useEffect(()=>{const V=setTimeout(async()=>{p.length>2?await D():await T()},300);return()=>{h.current=!0,clearTimeout(V)}},[p,D,T]);const M=B.useCallback(async()=>{f(!0),await i.loadNextPage();const V=i.getColumns();E(V),f(!1)},[i]);B.useEffect(()=>{const V=r.current;if(V){const K=async()=>{w===null&&V.scrollTop+V.clientHeight>=V.scrollHeight-1e3&&await M()};return V.addEventListener("scroll",K),()=>{V.removeEventListener("scroll",K)}}},[r,M,w]);const I=V=>{V&&(O(V),l(o)),V===null&&(r.current.scrollTop=a,O(null))};async function z(V){V.src&&(i.triggerDownload(V),e(V))}return C(aw,{children:C(FI,{closeModal:n,handleSearch:A,children:C(Ufe,{dataset:_,error:i.error,galleryRef:r,insertImage:z,isLoading:u,selectImg:I,zoomed:w})})})},Vfe=({nodeKey:n,isModalOpen:e=!0})=>{const{cardConfig:t}=B.useContext(bn),[i]=Ye.useLexicalComposerContext(),[r,o]=B.useState(e),s=()=>{n&&i.update(()=>{U.$getNodeByKey(n).remove()})},a=async l=>{i.update(()=>{const u=U.$getNodeByKey(n);u.setSrc(l.src),u.setImgHeight(l.height),u.setImgWidth(l.width),u.setCaption(l.caption),u.setAltText(l.alt);const f=U.$createNodeSelection();f.add(u.getKey()),U.$setSelection(f)}),o(!1)};return r?C(QI,{unsplashConf:t.unsplash,onClose:s,onImageInsert:a}):null},BI=U.createCommand("OPEN_TENOR_SELECTOR_COMMAND"),zI=U.createCommand("INSERT_FROM_TENOR_COMMAND"),WI=U.createCommand("OPEN_UNSPLASH_SELECTOR_COMMAND"),Zfe=()=>{const[n]=Ye.useLexicalComposerContext();return B.useEffect(()=>{if(!n.hasNodes([nf])){console.error("ImagePlugin: ImageNode not registered");return}return Ut.mergeRegister(n.registerCommand(BI,async e=>{const t=ip({...e,selector:Ffe,isImageHidden:!0});return n.dispatchCommand(Sr,{cardNode:t}),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(zI,async e=>{const t=ip(e),r=U.$getSelection().getNodes()[0];return n.dispatchCommand(Sr,{cardNode:t}),r.remove(),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(WI,async e=>{const t=ip({...e,selector:Vfe});return n.dispatchCommand(Sr,{cardNode:t}),!0},U.COMMAND_PRIORITY_LOW))},[n]),null};class nf extends cce{constructor(t={},i){super(t,i);ke(this,"__triggerFileDialog",!1);ke(this,"__previewSrc",null);ke(this,"__captionEditor");ke(this,"__captionEditorInitialState");const{previewSrc:r,triggerFileDialog:o,initialFile:s,selector:a,isImageHidden:l,caption:u}=t;if(this.__previewSrc=r||"",this.__triggerFileDialog=!t.src&&o||!1,this.__initialFile=s||null,this.__selector=a,this.__isImageHidden=l,this.__captionEditor=t.captionEditor||U.createEditor({nodes:Jn}),this.__captionEditorInitialState=t.captionEditorInitialState,!this.__captionEditorInitialState){const f=u?`<p>${u}</p>`:null;this.__captionEditorInitialState=bo({editor:U.createEditor({nodes:Jn}),initialHtml:f})}}getIcon(){return HS}getDataset(){const t=super.getDataset();t.__previewSrc=this.__previewSrc,t.__triggerFileDialog=this.__triggerFileDialog;const i=this.getLatest();return t.captionEditor=i.__captionEditor,t.captionEditorInitialState=i.__captionEditorInitialState,t}getPreviewSrc(){return this.getLatest().__previewSrc}setPreviewSrc(t){const i=this.getWritable();return i.__previewSrc=t}setTriggerFileDialog(t){const i=this.getWritable();return i.__triggerFileDialog=t}createDOM(){return document.createElement("div")}exportJSON(){const t=super.exportJSON();return this.__captionEditor&&this.__captionEditor.getEditorState().read(()=>{const i=ar.$generateHtmlFromNodes(this.__captionEditor,null),r=so(i);t.caption=r}),t}decorate(){const t=this.__selector;return fe(Yi,{nodeKey:this.getKey(),width:this.__cardWidth,children:[this.__selector&&C(t,{nodeKey:this.getKey()}),!this.__isImageHidden&&C(Efe,{altText:this.__altText,captionEditor:this.__captionEditor,captionEditorInitialState:this.__captionEditorInitialState,href:this.__href,initialFile:this.__initialFile,nodeKey:this.getKey(),previewSrc:this.getPreviewSrc(),src:this.__src,triggerFileDialog:this.__triggerFileDialog})]})}}ke(nf,"kgMenu",[{label:"Image",desc:"Upload, or embed with /image [url]",Icon:HS,insertCommand:z4,insertParams:{triggerFileDialog:!0},matches:["image","img"],queryParams:["src"]},{section:"Embed",label:"Unsplash",desc:"/unsplash [search term or url]",Icon:n3,insertCommand:WI,insertParams:{triggerFileDialog:!1},matches:["unsplash","uns"],queryParams:["src"]},{label:"GIF",desc:"Search and embed gifs",Icon:BA,insertCommand:BI,insertParams:{triggerFileDialog:!1},matches:["gif","giphy","tenor"],queryParams:["src"],isHidden:({config:t})=>!(t!=null&&t.tenor)}]),ke(nf,"uploadType","image");const ip=n=>new nf(n);function Gfe(n){return n instanceof nf}var Xfe=typeof global=="object"&&global&&global.Object===Object&&global;const Yfe=Xfe;var Kfe=typeof self=="object"&&self&&self.Object===Object&&self,Jfe=Yfe||Kfe||Function("return this")();const uE=Jfe;var ede=uE.Symbol;const rf=ede;var UI=Object.prototype,tde=UI.hasOwnProperty,nde=UI.toString,$0=rf?rf.toStringTag:void 0;function ide(n){var e=tde.call(n,$0),t=n[$0];try{n[$0]=void 0;var i=!0}catch{}var r=nde.call(n);return i&&(e?n[$0]=t:delete n[$0]),r}var rde=Object.prototype,ode=rde.toString;function sde(n){return ode.call(n)}var ade="[object Null]",lde="[object Undefined]",qI=rf?rf.toStringTag:void 0;function fE(n){return n==null?n===void 0?lde:ade:qI&&qI in Object(n)?ide(n):sde(n)}function dE(n){return n!=null&&typeof n=="object"}var cde="[object Symbol]";function hE(n){return typeof n=="symbol"||dE(n)&&fE(n)==cde}function ude(n,e){for(var t=-1,i=n==null?0:n.length,r=Array(i);++t<i;)r[t]=e(n[t],t,n);return r}var fde=Array.isArray;const A0=fde;var dde=1/0,HI=rf?rf.prototype:void 0,jI=HI?HI.toString:void 0;function VI(n){if(typeof n=="string")return n;if(A0(n))return ude(n,VI)+"";if(hE(n))return jI?jI.call(n):"";var e=n+"";return e=="0"&&1/n==-dde?"-0":e}function lw(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}function hde(n){return n}var gde="[object AsyncFunction]",pde="[object Function]",mde="[object GeneratorFunction]",vde="[object Proxy]";function yde(n){if(!lw(n))return!1;var e=fE(n);return e==pde||e==mde||e==gde||e==vde}var bde=uE["__core-js_shared__"];const gE=bde;var ZI=function(){var n=/[^.]+$/.exec(gE&&gE.keys&&gE.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function kde(n){return!!ZI&&ZI in n}var wde=Function.prototype,_de=wde.toString;function xde(n){if(n!=null){try{return _de.call(n)}catch{}try{return n+""}catch{}}return""}var Ode=/[\\^$.*+?()[\]{}|]/g,Sde=/^\[object .+?Constructor\]$/,Cde=Function.prototype,Ede=Object.prototype,Tde=Cde.toString,$de=Ede.hasOwnProperty,Ade=RegExp("^"+Tde.call($de).replace(Ode,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Nde(n){if(!lw(n)||kde(n))return!1;var e=yde(n)?Ade:Sde;return e.test(xde(n))}function Pde(n,e){return n==null?void 0:n[e]}function pE(n,e){var t=Pde(n,e);return Nde(t)?t:void 0}function Dde(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}var Mde=800,Lde=16,Ide=Date.now;function Rde(n){var e=0,t=0;return function(){var i=Ide(),r=Lde-(i-t);if(t=i,r>0){if(++e>=Mde)return arguments[0]}else e=0;return n.apply(void 0,arguments)}}function Fde(n){return function(){return n}}var Qde=function(){try{var n=pE(Object,"defineProperty");return n({},"",{}),n}catch{}}();const cw=Qde;var Bde=cw?function(n,e){return cw(n,"toString",{configurable:!0,enumerable:!1,value:Fde(e),writable:!0})}:hde,zde=Rde(Bde);const Wde=zde;var Ude=9007199254740991,qde=/^(?:0|[1-9]\d*)$/;function GI(n,e){var t=typeof n;return e=e??Ude,!!e&&(t=="number"||t!="symbol"&&qde.test(n))&&n>-1&&n%1==0&&n<e}function Hde(n,e,t){e=="__proto__"&&cw?cw(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):n[e]=t}function XI(n,e){return n===e||n!==n&&e!==e}var jde=Object.prototype,Vde=jde.hasOwnProperty;function Zde(n,e,t){var i=n[e];(!(Vde.call(n,e)&&XI(i,t))||t===void 0&&!(e in n))&&Hde(n,e,t)}var YI=Math.max;function Gde(n,e,t){return e=YI(e===void 0?n.length-1:e,0),function(){for(var i=arguments,r=-1,o=YI(i.length-e,0),s=Array(o);++r<o;)s[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=t(s),Dde(n,this,a)}}var Xde=9007199254740991;function Yde(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Xde}var Kde="[object Arguments]";function KI(n){return dE(n)&&fE(n)==Kde}var JI=Object.prototype,Jde=JI.hasOwnProperty,ehe=JI.propertyIsEnumerable,the=KI(function(){return arguments}())?KI:function(n){return dE(n)&&Jde.call(n,"callee")&&!ehe.call(n,"callee")};const eR=the;var nhe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ihe=/^\w*$/;function rhe(n,e){if(A0(n))return!1;var t=typeof n;return t=="number"||t=="symbol"||t=="boolean"||n==null||hE(n)?!0:ihe.test(n)||!nhe.test(n)||e!=null&&n in Object(e)}var ohe=pE(Object,"create");const N0=ohe;function she(){this.__data__=N0?N0(null):{},this.size=0}function ahe(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var lhe="__lodash_hash_undefined__",che=Object.prototype,uhe=che.hasOwnProperty;function fhe(n){var e=this.__data__;if(N0){var t=e[n];return t===lhe?void 0:t}return uhe.call(e,n)?e[n]:void 0}var dhe=Object.prototype,hhe=dhe.hasOwnProperty;function ghe(n){var e=this.__data__;return N0?e[n]!==void 0:hhe.call(e,n)}var phe="__lodash_hash_undefined__";function mhe(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=N0&&e===void 0?phe:e,this}function Vd(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var i=n[e];this.set(i[0],i[1])}}Vd.prototype.clear=she,Vd.prototype.delete=ahe,Vd.prototype.get=fhe,Vd.prototype.has=ghe,Vd.prototype.set=mhe;function vhe(){this.__data__=[],this.size=0}function uw(n,e){for(var t=n.length;t--;)if(XI(n[t][0],e))return t;return-1}var yhe=Array.prototype,bhe=yhe.splice;function khe(n){var e=this.__data__,t=uw(e,n);if(t<0)return!1;var i=e.length-1;return t==i?e.pop():bhe.call(e,t,1),--this.size,!0}function whe(n){var e=this.__data__,t=uw(e,n);return t<0?void 0:e[t][1]}function _he(n){return uw(this.__data__,n)>-1}function xhe(n,e){var t=this.__data__,i=uw(t,n);return i<0?(++this.size,t.push([n,e])):t[i][1]=e,this}function rp(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var i=n[e];this.set(i[0],i[1])}}rp.prototype.clear=vhe,rp.prototype.delete=khe,rp.prototype.get=whe,rp.prototype.has=_he,rp.prototype.set=xhe;var Ohe=pE(uE,"Map");const She=Ohe;function Che(){this.size=0,this.__data__={hash:new Vd,map:new(She||rp),string:new Vd}}function Ehe(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}function fw(n,e){var t=n.__data__;return Ehe(e)?t[typeof e=="string"?"string":"hash"]:t.map}function The(n){var e=fw(this,n).delete(n);return this.size-=e?1:0,e}function $he(n){return fw(this,n).get(n)}function Ahe(n){return fw(this,n).has(n)}function Nhe(n,e){var t=fw(this,n),i=t.size;return t.set(n,e),this.size+=t.size==i?0:1,this}function Zd(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var i=n[e];this.set(i[0],i[1])}}Zd.prototype.clear=Che,Zd.prototype.delete=The,Zd.prototype.get=$he,Zd.prototype.has=Ahe,Zd.prototype.set=Nhe;var Phe="Expected a function";function mE(n,e){if(typeof n!="function"||e!=null&&typeof e!="function")throw new TypeError(Phe);var t=function(){var i=arguments,r=e?e.apply(this,i):i[0],o=t.cache;if(o.has(r))return o.get(r);var s=n.apply(this,i);return t.cache=o.set(r,s)||o,s};return t.cache=new(mE.Cache||Zd),t}mE.Cache=Zd;var Dhe=500;function Mhe(n){var e=mE(n,function(i){return t.size===Dhe&&t.clear(),i}),t=e.cache;return e}var Lhe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ihe=/\\(\\)?/g,Rhe=Mhe(function(n){var e=[];return n.charCodeAt(0)===46&&e.push(""),n.replace(Lhe,function(t,i,r,o){e.push(r?o.replace(Ihe,"$1"):i||t)}),e});const Fhe=Rhe;function vE(n){return n==null?"":VI(n)}function dw(n,e){return A0(n)?n:rhe(n,e)?[n]:Fhe(vE(n))}var Qhe=1/0;function yE(n){if(typeof n=="string"||hE(n))return n;var e=n+"";return e=="0"&&1/n==-Qhe?"-0":e}function Bhe(n,e){e=dw(e,n);for(var t=0,i=e.length;n!=null&&t<i;)n=n[yE(e[t++])];return t&&t==i?n:void 0}function zhe(n,e){for(var t=-1,i=e.length,r=n.length;++t<i;)n[r+t]=e[t];return n}var tR=rf?rf.isConcatSpreadable:void 0;function Whe(n){return A0(n)||eR(n)||!!(tR&&n&&n[tR])}function nR(n,e,t,i,r){var o=-1,s=n.length;for(t||(t=Whe),r||(r=[]);++o<s;){var a=n[o];e>0&&t(a)?e>1?nR(a,e-1,t,i,r):zhe(r,a):i||(r[r.length]=a)}return r}function Uhe(n){var e=n==null?0:n.length;return e?nR(n,1):[]}function qhe(n){return Wde(Gde(n,void 0,Uhe),n+"")}function Hhe(n,e,t,i){var r=-1,o=n==null?0:n.length;for(i&&o&&(t=n[++r]);++r<o;)t=e(t,n[r],r,n);return t}function jhe(n){return function(e){return n==null?void 0:n[e]}}var Vhe={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Zhe=jhe(Vhe);const Ghe=Zhe;var Xhe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Yhe="\\u0300-\\u036f",Khe="\\ufe20-\\ufe2f",Jhe="\\u20d0-\\u20ff",ege=Yhe+Khe+Jhe,tge="["+ege+"]",nge=RegExp(tge,"g");function ige(n){return n=vE(n),n&&n.replace(Xhe,Ghe).replace(nge,"")}var rge=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function oge(n){return n.match(rge)||[]}var sge=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function age(n){return sge.test(n)}var iR="\\ud800-\\udfff",lge="\\u0300-\\u036f",cge="\\ufe20-\\ufe2f",uge="\\u20d0-\\u20ff",fge=lge+cge+uge,rR="\\u2700-\\u27bf",oR="a-z\\xdf-\\xf6\\xf8-\\xff",dge="\\xac\\xb1\\xd7\\xf7",hge="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",gge="\\u2000-\\u206f",pge=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",sR="A-Z\\xc0-\\xd6\\xd8-\\xde",mge="\\ufe0e\\ufe0f",aR=dge+hge+gge+pge,lR="['’]",cR="["+aR+"]",vge="["+fge+"]",uR="\\d+",yge="["+rR+"]",fR="["+oR+"]",dR="[^"+iR+aR+uR+rR+oR+sR+"]",bge="\\ud83c[\\udffb-\\udfff]",kge="(?:"+vge+"|"+bge+")",wge="[^"+iR+"]",hR="(?:\\ud83c[\\udde6-\\uddff]){2}",gR="[\\ud800-\\udbff][\\udc00-\\udfff]",op="["+sR+"]",_ge="\\u200d",pR="(?:"+fR+"|"+dR+")",xge="(?:"+op+"|"+dR+")",mR="(?:"+lR+"(?:d|ll|m|re|s|t|ve))?",vR="(?:"+lR+"(?:D|LL|M|RE|S|T|VE))?",yR=kge+"?",bR="["+mge+"]?",Oge="(?:"+_ge+"(?:"+[wge,hR,gR].join("|")+")"+bR+yR+")*",Sge="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Cge="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ege=bR+yR+Oge,Tge="(?:"+[yge,hR,gR].join("|")+")"+Ege,$ge=RegExp([op+"?"+fR+"+"+mR+"(?="+[cR,op,"$"].join("|")+")",xge+"+"+vR+"(?="+[cR,op+pR,"$"].join("|")+")",op+"?"+pR+"+"+mR,op+"+"+vR,Cge,Sge,uR,Tge].join("|"),"g");function Age(n){return n.match($ge)||[]}function Nge(n,e,t){return n=vE(n),e=t?void 0:e,e===void 0?age(n)?Age(n):oge(n):n.match(e)||[]}var Pge="['’]",Dge=RegExp(Pge,"g");function Mge(n){return function(e){return Hhe(Nge(ige(e).replace(Dge,"")),n,"")}}function Lge(n,e){return n!=null&&e in Object(n)}function Ige(n,e,t){e=dw(e,n);for(var i=-1,r=e.length,o=!1;++i<r;){var s=yE(e[i]);if(!(o=n!=null&&t(n,s)))break;n=n[s]}return o||++i!=r?o:(r=n==null?0:n.length,!!r&&Yde(r)&&GI(s,r)&&(A0(n)||eR(n)))}function Rge(n,e){return n!=null&&Ige(n,e,Lge)}var Fge=Mge(function(n,e,t){return n+(t?"-":"")+e.toLowerCase()});const hw=Fge;function Qge(n,e,t,i){if(!lw(n))return n;e=dw(e,n);for(var r=-1,o=e.length,s=o-1,a=n;a!=null&&++r<o;){var l=yE(e[r]),u=t;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(r!=s){var f=a[l];u=i?i(f,l,a):void 0,u===void 0&&(u=lw(f)?f:GI(e[r+1])?[]:{})}Zde(a,l,u),a=a[l]}return n}function Bge(n,e,t){for(var i=-1,r=e.length,o={};++i<r;){var s=e[i],a=Bhe(n,s);t(a,s)&&Qge(o,dw(s,n),a)}return o}function zge(n,e){return Bge(n,e,function(t,i){return Rge(n,i)})}var Wge=qhe(function(n,e){return n==null?{}:zge(n,e)});const kR=Wge,gw="koenigDndContainer",wR=`[data-${hw(gw)}]`,bE="koenigDndDraggable",Uge=`[data-${hw(bE)}]`,kE="koenigDndDroppable",wE=`[data-${hw(kE)}]`,qge=`[data-${hw("koenigDndDisabled")}]`,_R="koenig-drag-drop-indicator",_E=1e4,Hge="koenig-drag-drop-ghost-container",jge=_E+1;function xR(n,e,t=""){return n===-1?!0:n===e||typeof e>"u"?!1:(t.match(/top/)&&(e-=1),t.match(/bottom/)&&(e+=1),e!==n)}function sp(n,e){return OE(n,e,t=>t.parentNode)}function Vge(n,e){return n=n.nextElementSibling,OE(n,e,t=>t.nextElementSibling)}function Zge(n,e){return n=n.previousElementSibling,OE(n,e,t=>t.previousElementSibling)}function Gge(n){if(!n)return xE();let e=getComputedStyle(n).getPropertyValue("position"),t=e==="absolute",i=sp(n,r=>t&&Xge(r)?!1:Yge(r));return e==="fixed"&&!i?xE():i}function xE(){var n;return((n=document.scrollingElement)==null?void 0:n.body)||document.scrollingElement||document.element}function OR(n,e){n.style.webkitUserSelect=e,n.style.mozUserSelect=e,n.style.msUserSelect=e,n.style.oUserSelect=e,n.style.userSelect=e}function OE(n,e,t){if(!n)return null;let i=e,r=e,o=typeof e=="string",s=typeof e=="function";function a(u){if(u){if(o)return u.matches(i);if(s)return r(u)}else return u}let l=n;do{if(a(l))return l;l=t(l)}while(l&&l!==document.body&&l!==document)}function Xge(n){return getComputedStyle(n).getPropertyValue("position")==="static"}function Yge(n){let e=/(auto|scroll)/,t=getComputedStyle(n,null),i=t.getPropertyValue("overflow")+t.getPropertyValue("overflow-y")+t.getPropertyValue("overflow-x");return e.test(i)}var pw={},Kge={get exports(){return pw},set exports(n){pw=n}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(l,u,f){this.fn=l,this.context=u,this.once=f||!1}function o(l,u,f,h,p){if(typeof f!="function")throw new TypeError("The listener must be a function");var v=new r(f,h||l,p),w=t?t+u:u;return l._events[w]?l._events[w].fn?l._events[w]=[l._events[w],v]:l._events[w].push(v):(l._events[w]=v,l._eventsCount++),l}function s(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],f,h;if(this._eventsCount===0)return u;for(h in f=this._events)e.call(f,h)&&u.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(f)):u},a.prototype.listeners=function(u){var f=t?t+u:u,h=this._events[f];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,v=h.length,w=new Array(v);p<v;p++)w[p]=h[p].fn;return w},a.prototype.listenerCount=function(u){var f=t?t+u:u,h=this._events[f];return h?h.fn?1:h.length:0},a.prototype.emit=function(u,f,h,p,v,w){var O=t?t+u:u;if(!this._events[O])return!1;var _=this._events[O],E=arguments.length,T,A;if(_.fn){switch(_.once&&this.removeListener(u,_.fn,void 0,!0),E){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,f),!0;case 3:return _.fn.call(_.context,f,h),!0;case 4:return _.fn.call(_.context,f,h,p),!0;case 5:return _.fn.call(_.context,f,h,p,v),!0;case 6:return _.fn.call(_.context,f,h,p,v,w),!0}for(A=1,T=new Array(E-1);A<E;A++)T[A-1]=arguments[A];_.fn.apply(_.context,T)}else{var D=_.length,M;for(A=0;A<D;A++)switch(_[A].once&&this.removeListener(u,_[A].fn,void 0,!0),E){case 1:_[A].fn.call(_[A].context);break;case 2:_[A].fn.call(_[A].context,f);break;case 3:_[A].fn.call(_[A].context,f,h);break;case 4:_[A].fn.call(_[A].context,f,h,p);break;default:if(!T)for(M=1,T=new Array(E-1);M<E;M++)T[M-1]=arguments[M];_[A].fn.apply(_[A].context,T)}}return!0},a.prototype.on=function(u,f,h){return o(this,u,f,h,!1)},a.prototype.once=function(u,f,h){return o(this,u,f,h,!0)},a.prototype.removeListener=function(u,f,h,p){var v=t?t+u:u;if(!this._events[v])return this;if(!f)return s(this,v),this;var w=this._events[v];if(w.fn)w.fn===f&&(!p||w.once)&&(!h||w.context===h)&&s(this,v);else{for(var O=0,_=[],E=w.length;O<E;O++)(w[O].fn!==f||p&&!w[O].once||h&&w[O].context!==h)&&_.push(w[O]);_.length?this._events[v]=_.length===1?_[0]:_:s(this,v)}return this},a.prototype.removeAllListeners=function(u){var f;return u?(f=t?t+u:u,this._events[f]&&s(this,f)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a})(Kge);const omt=pw;class Jge{constructor(e,t){ke(this,"element",null);ke(this,"draggables",[]);ke(this,"droppables",[]);ke(this,"isDragEnabled",!0);t.createGhostElement&&(this._createGhostElement=t.createGhostElement,delete t.createGhostElement),Object.assign(this,{element:e,draggables:[],droppables:[],isDragEnabled:!0},t),e.dataset[gw]="true",this.refresh()}getDraggableInfo(){return!1}getIndicatorPosition(){return!1}onDragStart(){}onDragEnterContainer(){}onDragEnterDroppable(){}onDragOverDroppable(){}onDragLeaveDroppable(){}onDragLeaveContainer(){}onDragEnd(){}onDrop(){}onDropEnd(){}createGhostElement(e){let t;if(typeof this._createGhostElement=="function"&&(t=this._createGhostElement(e)),!t&&(e.type==="image"||e.cardName==="image")){let i=e.element.querySelector("img");if(i){let r=i.width/i.height,o,s;i.width>i.height?(o=200,s=200/r):(o=200*r,s=200),t=document.createElement("img"),t.width=o,t.height=s,t.id="koenig-drag-drop-ghost",t.src=i.src,t.style.position="absolute",t.style.top="0",t.style.left=`-${o}px`,t.style.zIndex=jge,t.style.willChange="transform"}else{console.warn("No <img> element found in draggable");return}}if(t)return t;console.warn(`No default createGhostElement handler for type "${e.type}"`)}enableDrag(){this.isDragEnabled=!0,this.element.dataset[gw]="true",this.refresh()}disableDrag(){this.isDragEnabled=!1,delete this.element.dataset[gw],this.refresh()}refresh(){this.draggables.forEach(e=>{delete e.dataset[bE]}),this.droppables.forEach(e=>{delete e.dataset[kE]}),this.draggables=[],this.droppables=[],this.isDragEnabled&&(this.element.querySelectorAll(this.draggableSelector).forEach(e=>{e.dataset[bE]="true",this.draggables.push(e)}),this.element.querySelectorAll(this.droppableSelector).forEach(e=>{e.dataset[kE]="true",this.droppables.push(e)}))}}const epe={speed:8,sensitivity:50};class tpe{constructor(){this.options=Object.assign({},epe),this.currentMousePosition=null,this.findScrollableElementFrame=null,this.scrollableElement=null,this.scrollAnimationFrame=null,this._scroll=this._scroll.bind(this),this._isSafari=navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}dragStart(e){this.findScrollableElementFrame=requestAnimationFrame(()=>{this.scrollableElement=this.getScrollableElement(e.element)})}dragMove(e){this.findScrollableElementFrame=requestAnimationFrame(()=>{this.scrollableElement=this.getScrollableElement(e.target)}),this.scrollableElement&&(this.currentMousePosition={clientX:e.mousePosition.x,clientY:e.mousePosition.y},this.scrollAnimationFrame=requestAnimationFrame(this._scroll))}dragStop(){cancelAnimationFrame(this.scrollAnimationFrame),cancelAnimationFrame(this.findScrollableElementFrame),this.currentMousePosition=null,this.findScrollableElementFrame=null,this.scrollableElement=null,this.scrollAnimationFrame=null}getScrollableElement(e){let t=Gge(e);return t===xE()&&(t=document.querySelector(".gh-koenig-editor")),t}_scroll(){if(!this.scrollableElement||!this.currentMousePosition)return;cancelAnimationFrame(this.scrollAnimationFrame);let{speed:e,sensitivity:t}=this.options,i=this.scrollableElement.getBoundingClientRect(),r=this.scrollableElement,o=this.currentMousePosition.clientX,s=this.currentMousePosition.clientY,{offsetHeight:a,offsetWidth:l}=r,u=i.top+a-s,f=s-i.top;u<t&&!(this._isSafari&&u<0)?r.scrollTop+=e:f<t&&!(this._isSafari&&f<0)&&(r.scrollTop-=e),i.left+l-o<t?r.scrollLeft+=e:o-i.left<t&&(r.scrollLeft-=e),this.scrollAnimationFrame=requestAnimationFrame(this._scroll)}}var ap={};/**
430
+ `,w=H4(q4(v));h.innerHTML=h.innerHTML+w}return u&&h.appendChild(t.createElement("hr")),h}const jL=U.createCommand(),VL="email-cta";let Pue=class extends Xi{constructor(){let{alignment:t,buttonText:i,buttonUrl:r,html:o,segment:s,showButton:a,showDividers:l}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=arguments.length>1?arguments[1]:void 0;super(u);ke(this,"__alignment");ke(this,"__buttonText");ke(this,"__buttonUrl");ke(this,"__html");ke(this,"__segment");ke(this,"__showButton");ke(this,"__showDividers");this.__alignment=t||"left",this.__buttonText=i||"",this.__buttonUrl=r||"",this.__html=o||"",this.__segment=s||"status:free",this.__showButton=a||!1,this.__showDividers=l??!0}static getType(){return VL}static clone(t){return new this(t.getDataset(),t.__key)}static get urlTransformMap(){return{buttonUrl:"url",html:"html"}}getDataset(){const t=this.getLatest();return{alignment:t.__alignment,buttonText:t.__buttonText,buttonUrl:t.__buttonUrl,html:t.__html,segment:t.__segment,showButton:t.__showButton,showDividers:t.__showDividers}}static importJSON(t){const{alignment:i,buttonText:r,buttonUrl:o,html:s,segment:a,showButton:l,showDividers:u}=t;return new this({alignment:i,buttonText:r,buttonUrl:o,html:s,segment:a,showButton:l,showDividers:u})}exportJSON(){return{type:VL,version:1,alignment:this.getAlignment(),buttonText:this.getButtonText(),buttonUrl:this.getButtonUrl(),html:this.getHtml(),segment:this.getSegment(),showButton:this.getShowButton(),showDividers:this.getShowDividers()}}exportDOM(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{element:Nue(this,t)}}createDOM(){return document.createElement("div")}updateDOM(){return!1}isInline(){return!1}getAlignment(){return this.getLatest().__alignment}setAlignment(t){const i=this.getWritable();return i.__alignment=t}getButtonText(){return this.getLatest().__buttonText}setButtonText(t){const i=this.getWritable();return i.__buttonText=t}getButtonUrl(){return this.getLatest().__buttonUrl}setButtonUrl(t){const i=this.getWritable();return i.__buttonUrl=t}getHtml(){return this.getLatest().__html}setHtml(t){const i=this.getWritable();return i.__html=t}getSegment(){return this.getLatest().__segment}setSegment(t){const i=this.getWritable();return i.__segment=t}getShowButton(){return this.getLatest().__showButton}setShowButton(t){const i=this.getWritable();return i.__showButton=t}getShowDividers(){return this.getLatest().__showDividers}setShowDividers(t){const i=this.getWritable();return i.__showDividers=t}hasEditMode(){return!0}isEmpty(){return!this.__html&&(!this.__showButton||!this.__buttonText&&!this.__buttonUrl)}decorate(){return""}};var Xk={},ZL=B;let GL=ZL.createContext(null);Xk.LexicalComposerContext=GL,Xk.createLexicalComposerContext=function(n,e){let t=null;return n!=null&&(t=n[1]),{getTheme:function(){return e??(t!=null?t.getTheme():null)}}},Xk.useLexicalComposerContext=function(){let n=ZL.useContext(GL);if(n==null)throw Error("Minified Lexical error #8; visit https://lexical.dev/docs/error?code=8 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return n};var Ye=Xk;const Due=({text:n="Type here"})=>C("div",{className:"pointer-events-none absolute top-0 left-0 m-0 min-w-full cursor-text font-sans text-sm font-normal tracking-wide text-grey-500 dark:text-grey-800",children:n});function Mue({parentEditor:n}){const[e]=Ye.useLexicalComposerContext(),{setCaptionHasFocus:t,captionHasFocus:i,nodeKey:r,isSelected:o}=B.useContext(or),s=B.useCallback(a=>{o&&(a.target.matches("input, textarea")||!i&&a.key.length===1&&!a.ctrlKey&&!a.metaKey&&!a.altKey&&e.focus())},[e,i,o]);return B.useEffect(()=>(document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}),[s,e]),B.useEffect(()=>Ut.mergeRegister(e.registerCommand(U.FOCUS_COMMAND,()=>(t(!0),!1),U.COMMAND_PRIORITY_LOW),e.registerCommand(U.BLUR_COMMAND,()=>(t(!1),e.update(()=>{U.$setSelection(null)}),!1),U.COMMAND_PRIORITY_LOW),e.registerCommand(U.KEY_ENTER_COMMAND,()=>(n.update(()=>{const a=U.$getNodeByKey(r),l=U.$createParagraphNode();a.getTopLevelElementOrThrow().insertAfter(l),l.selectStart()}),!1),U.COMMAND_PRIORITY_LOW)),[e,t,n,r]),null}const Lue=({paragraphs:n=1,captionEditor:e,captionEditorInitialState:t,placeholderText:i,className:r="koenig-lexical-caption"})=>{const[o]=Ye.useLexicalComposerContext();return C(D9,{initialEditor:e,initialEditorState:t,initialNodes:Jn,children:fe(L_,{className:r,markdownTransformers:QT,placeholder:C(Due,{text:i}),children:[C(Mue,{parentEditor:o}),C(lO,{paragraphs:n})]})})};var Ju={},xo=U;function Z4(n,e=!0){return n?!1:(n=XL(),e&&(n=n.trim()),n==="")}function XL(){return xo.$getRoot().getTextContent()}function YL(n){if(!Z4(n,!1))return!1;n=xo.$getRoot().getChildren();let e=n.length;if(1<e)return!1;for(let i=0;i<e;i++){var t=n[i];if(xo.$isDecoratorNode(t))return!1;if(xo.$isElementNode(t)){if(!xo.$isParagraphNode(t)||t.__indent!==0)return!1;t=t.getChildren();let r=t.length;for(let o=0;o<r;o++)if(!xo.$isTextNode(t[i]))return!1}}return!0}Ju.$canShowPlaceholder=YL,Ju.$canShowPlaceholderCurry=function(n){return()=>YL(n)},Ju.$findTextIntersectionFromCharacters=function(n,e){var t=n.getFirstChild();n=0;e:for(;t!==null;){if(xo.$isElementNode(t)){var i=t.getFirstChild();if(i!==null){t=i;continue}}else if(xo.$isTextNode(t)){if(i=t.getTextContentSize(),n+i>e)return{node:t,offset:e-n};n+=i}if(i=t.getNextSibling(),i!==null)t=i;else{for(t=t.getParent();t!==null;){if(i=t.getNextSibling(),i!==null){t=i;continue e}t=t.getParent()}break}}return null},Ju.$isRootTextContentEmpty=Z4,Ju.$isRootTextContentEmptyCurry=function(n,e){return()=>Z4(n,e)},Ju.$rootTextContent=XL,Ju.registerLexicalTextEntity=function(n,e,t,i){let r=s=>{const a=xo.$createTextNode(s.getTextContent());a.setFormat(s.getFormat()),s.replace(a)},o=n.registerNodeTransform(xo.TextNode,s=>{if(s.isSimpleText()){var a=s.getPreviousSibling(),l=s.getTextContent(),u=s;if(xo.$isTextNode(a)){var f=a.getTextContent(),h=e(f+l);if(a instanceof t){if(h===null||a.getLatest().__mode!==0){r(a);return}if(h=h.end-f.length,0<h){u=l.slice(0,h),u=f+u,a.select(),a.setTextContent(u),h===l.length?s.remove():(a=l.slice(h),s.setTextContent(a));return}}else if(h===null||h.start<f.length)return}for(;;){if(s=e(l),l=h=s===null?"":l.slice(s.end),h===""){if(f=u.getNextSibling(),xo.$isTextNode(f)){if(h=u.getTextContent()+f.getTextContent(),h=e(h),h===null){f instanceof t?r(f):f.markDirty();break}else if(h.start!==0)break}}else if(f=e(h),f!==null&&f.start===0)break;if(s===null)break;if(s.start===0&&xo.$isTextNode(a)&&a.isTextEntity())continue;let p;if(s.start===0?[p,u]=u.splitText(s.end):[,p,u]=u.splitText(s.start,s.end),s=i(p),p.replace(s),u==null)break}}});return n=n.registerNodeTransform(t,s=>{var a=s.getTextContent();const l=e(a);l===null||l.start!==0?r(s):a.length>l.end?s.splitText(l.end):(a=s.getPreviousSibling(),xo.$isTextNode(a)&&a.isTextEntity()&&(r(a),r(s)),a=s.getNextSibling(),xo.$isTextNode(a)&&a.isTextEntity()&&(r(a),s instanceof t&&r(s)))}),[o,n]};var Sl=Ju;function KL({value:n}){const[e,t]=B.useState(null),[i,r]=B.useState(0),[o,s]=B.useState(0);function a(l){r(l.target.selectionStart),s(l.target.selectionEnd)}return B.useEffect(()=>{e&&(e.selectionStart=i,e.selectionEnd=o)},[e,o,i,n]),{saveSelectionRange:a,setRef:t}}function Iue({value:n,onChange:e,...t}){const{setRef:i,saveSelectionRange:r}=KL({value:n});return C("input",{ref:i,value:n,onChange:s=>{r(s),e(s.target.value)},...t})}function Rue({captionEditor:n,captionEditorInitialState:e,placeholder:t,dataTestId:i}){return C("div",{className:"m-0 w-full px-9 text-center","data-testid":i,children:C(Lue,{captionEditor:n,captionEditorInitialState:e,placeholderText:t})})}function Fue({value:n,placeholder:e,onChange:t,readOnly:i,dataTestId:r,autoFocus:o=!0}){return C(Iue,{autoFocus:o,className:"not-kg-prose w-full bg-transparent px-9 text-center font-sans text-sm font-normal leading-8 tracking-wide text-grey-900 placeholder:text-grey-800 dark:text-grey-500","data-testid":r,placeholder:e,readOnly:i,value:n,onChange:t})}function Que({isEditingAlt:n,onClick:e}){return C("button",{className:`absolute bottom-0 right-0 m-2 cursor-pointer rounded border px-1 font-sans text-[1.3rem] font-normal leading-7 tracking-wide transition-all duration-100 ${n?"border-green bg-green text-white":"border-grey text-grey"} `,name:"alt-toggle-button",type:"button",onClick:e,children:"Alt"})}function Gg({altText:n,altTextPlaceholder:e,setAltText:t,captionEditor:i,captionEditorInitialState:r,captionPlaceholder:o,isSelected:s,readOnly:a,dataTestId:l}){const[u,f]=B.useState(!1),h=v=>{v.stopPropagation(),f(!u)};B.useEffect(()=>{s||f(!1)},[s,f]);const p=i.getEditorState().read(Sl.$canShowPlaceholderCurry(!1));return(s||!p)&&fe("figcaption",{className:"flex min-h-[40px] w-full p-2",children:[u?C(Fue,{dataTestId:l,placeholder:e,readOnly:a,value:n,onChange:t}):C(Rue,{captionEditor:i,captionEditorInitialState:r,dataTestId:l,placeholder:o}),t&&C(Que,{isEditingAlt:u,onClick:h})]})}const w0=n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",strokeWidth:1.5,viewBox:"0 0 24 24",...n},re.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M.75 23.249l22.5-22.5M23.25 23.249L.75.749"}));function Bue({value:n,onEnter:e}){const[t]=Ye.useLexicalComposerContext();B.useEffect(i=>Ut.mergeRegister(t.registerCommand(U.KEY_ENTER_COMMAND,()=>(e(i),!1),U.COMMAND_PRIORITY_LOW)),[t,e,n])}function JL({dataTestId:n,value:e,placeholder:t,handleUrlChange:i,handleUrlSubmit:r,hasError:o,handlePasteAsLink:s,handleRetry:a,handleClose:l,isLoading:u}){return u?C("div",{className:"flex w-full items-center justify-center rounded border border-grey-300 p-2 font-sans text-sm font-normal leading-snug text-grey-900 focus-visible:outline-none dark:border-grey-800 dark:bg-grey-900 dark:placeholder:text-grey-800","data-testid":`${n}-loading-container`,children:C("div",{className:"-ml-1 mr-3 inline-block h-5 w-5 animate-spin rounded-full border-4 border-green/20 text-white after:mt-[11px] after:block after:h-1 after:w-1 after:rounded-full after:bg-green/70 after:content-['']","data-testid":`${n}-loading-spinner`})}):o?fe("div",{className:"min-width-[500px] flex flex-row items-center justify-between rounded-sm border border-red bg-red/5 px-3 py-2 text-sm leading-snug text-red","data-testid":`${n}-error-container`,children:[fe("div",{children:[C("span",{className:"mr-3","data-testid":`${n}-error-message`,children:"There was an error when parsing the URL."}),C("button",{className:"mr-3 cursor-pointer","data-testid":`${n}-error-retry`,type:"button",children:C("span",{className:"underline",onClick:a,children:C("strong",{children:"Retry"})})}),C("button",{className:"mr-3 cursor-pointer","data-testid":`${n}-error-pasteAsLink`,type:"button",children:C("span",{className:"underline",onClick:s,children:C("strong",{children:"Paste URL as link"})})})]}),C("button",{className:"cursor-pointer p-1","data-testid":`${n}-error-close`,type:"button",onClick:l,children:C(w0,{className:"red h-3 w-3"})})]}):fe(yt,{children:[C(Bue,{value:e,onEnter:r}),C("input",{autoFocus:!0,className:"w-full rounded border border-grey-300 p-2 font-sans text-sm font-normal leading-snug text-grey-900 focus-visible:outline-none dark:border-grey-800 dark:bg-grey-900 dark:placeholder:text-grey-800","data-testid":n,placeholder:t,value:e,onChange:i,onKeyDown:r})]})}function eI({author:n,handleClose:e,handlePasteAsLink:t,handleRetry:i,handleUrlChange:r,handleUrlSubmit:o,url:s,urlInputValue:a,urlPlaceholder:l,thumbnail:u,title:f,description:h,icon:p,publisher:v,captionEditor:w,captionEditorInitialState:O,isSelected:_,isLoading:E,urlError:T}){return s&&!T&&f?fe(yt,{children:[fe("div",{className:"flex min-h-[120px] w-full rounded border border-grey/40 bg-transparent font-sans dark:border-grey/20","data-testid":"bookmark-container",children:[fe("div",{className:"flex grow basis-full flex-col items-start justify-start p-5","data-testid":"bookmark-text-container",children:[C("div",{className:"text-[1.5rem] font-semibold leading-normal tracking-normal text-grey-900 dark:text-grey-100","data-testid":"bookmark-title",children:f}),C("div",{className:"mt-1 max-h-[44px] overflow-y-hidden text-sm font-normal leading-normal text-grey-800 line-clamp-2 dark:text-grey-600","data-testid":"bookmark-description",children:h}),fe("div",{className:"mt-[20px] flex items-center text-sm font-medium leading-9 text-grey-900",children:[p&&C(zue,{src:p}),C("span",{className:" db max-w-[240px] overflow-hidden text-ellipsis whitespace-nowrap leading-6 text-grey-900 dark:text-grey-100","data-testid":"bookmark-publisher",children:v}),n&&C("span",{className:"font-normal text-grey-800 before:mx-1.5 before:text-grey-900 before:content-['•'] dark:text-grey-600 dark:before:text-grey-100","data-testid":"bookmark-author",children:n})]})]}),u&&C("div",{className:"grow-1 relative m-0 min-w-[33%]","data-testid":"bookmark-thumbnail-container",children:C("img",{alt:"",className:"absolute inset-0 h-full w-full rounded-r-[.3rem] object-cover","data-testid":"bookmark-thumbnail",src:u})})]}),C(Gg,{captionEditor:w,captionEditorInitialState:O,captionPlaceholder:"Type caption for bookmark (optional)",dataTestId:"bookmark-caption",isSelected:_}),C("div",{className:"absolute inset-0 z-50 mt-0"})]}):C(JL,{dataTestId:"bookmark-url",handleClose:e,handlePasteAsLink:t,handleRetry:i,handleUrlChange:r,handleUrlSubmit:o,hasError:T,isLoading:E,placeholder:l,value:a})}function zue({src:n}){return C("img",{alt:"",className:"mr-2 h-5 w-5 shrink-0","data-testid":"bookmark-icon",src:n})}eI.propTypes={author:me.string,handleClose:me.func,handlePasteAsLink:me.func,handleRetry:me.func,handleUrlChange:me.func,handleUrlSubmit:me.func,url:me.string,urlInputValue:me.string,urlPlaceholder:me.string,thumbnail:me.string,title:me.string,description:me.string,icon:me.string,publisher:me.string,captionEditor:me.object,captionEditorInitialState:me.string,isSelected:me.bool,isLoading:me.bool,urlError:me.bool};var Qc={},tI=ar,G4=Ho,_0=Ut,Pt=U;function Bc(n){throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?code=${n} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function nI(n){let e=Pt.$getSelection();if(e==null)throw Error("Expected valid LexicalSelection");return Pt.$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?"":tI.$generateHtmlFromNodes(n,e)}function iI(n){let e=Pt.$getSelection();if(e==null)throw Error("Expected valid LexicalSelection");return Pt.$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(oI(n,e))}function X4(n,e,t){(Pt.DEPRECATED_$isGridSelection(t)||_0.$findMatchingParent(t.anchor.getNode(),i=>Pt.DEPRECATED_$isGridCellNode(i))!==null&&_0.$findMatchingParent(t.focus.getNode(),i=>Pt.DEPRECATED_$isGridCellNode(i))!==null)&&e.length===1&&Pt.DEPRECATED_$isGridNode(e[0])?Uue(e,t,!1,n):Wue(e,t)}function Wue(n,e){let t=[],i=null;for(let r=0;r<n.length;r++){let o=n[r],s=Pt.$isLineBreakNode(o);if(s||Pt.$isDecoratorNode(o)&&o.isInline()||Pt.$isElementNode(o)&&o.isInline()||Pt.$isTextNode(o)||o.isParentRequired()){if(i===null&&(i=o.createParentElementNode(),t.push(i),s))continue;i!==null&&i.append(o)}else t.push(o),i=null}Pt.$isRangeSelection(e)?e.insertNodes(t):Pt.DEPRECATED_$isGridSelection(e)&&(n=e.anchor.getNode(),Pt.DEPRECATED_$isGridCellNode(n)||Bc(41),n.append(...t))}function Uue(n,e,t,i){n.length===1&&Pt.DEPRECATED_$isGridNode(n[0])||Bc(42);var r=n[0];n=r.getChildren(),t=r.getFirstChildOrThrow().getChildrenSize();var o=r.getChildrenSize(),s=_0.$findMatchingParent(e.anchor.getNode(),v=>Pt.DEPRECATED_$isGridCellNode(v));e=(r=s&&_0.$findMatchingParent(s,v=>Pt.DEPRECATED_$isGridRowNode(v)))&&_0.$findMatchingParent(r,v=>Pt.DEPRECATED_$isGridNode(v)),Pt.DEPRECATED_$isGridCellNode(s)&&Pt.DEPRECATED_$isGridRowNode(r)&&Pt.DEPRECATED_$isGridNode(e)||Bc(43);var a=r.getIndexWithinParent(),l=Math.min(e.getChildrenSize()-1,a+o-1);o=s.getIndexWithinParent(),s=Math.min(r.getChildrenSize()-1,o+t-1),t=Math.min(o,s),r=Math.min(a,l),o=Math.max(o,s),a=Math.max(a,l),l=e.getChildren(),s=0;let u,f;for(let v=r;v<=a;v++){var h=l[v];Pt.DEPRECATED_$isGridRowNode(h)||Bc(24);var p=n[s];Pt.DEPRECATED_$isGridRowNode(p)||Bc(24),h=h.getChildren(),p=p.getChildren();let w=0;for(let O=t;O<=o;O++){let _=h[O];Pt.DEPRECATED_$isGridCellNode(_)||Bc(25);let E=p[w];Pt.DEPRECATED_$isGridCellNode(E)||Bc(25),v===r&&O===t?u=_.getKey():v===a&&O===o&&(f=_.getKey());let T=_.getChildren();E.getChildren().forEach(A=>{Pt.$isTextNode(A)&&Pt.$createParagraphNode().append(A),_.append(A)}),T.forEach(A=>A.remove()),w++}s++}u&&f&&(n=Pt.DEPRECATED_$createGridSelection(),n.set(e.getKey(),u,f),Pt.$setSelection(n),i.dispatchCommand(Pt.SELECTION_CHANGE_COMMAND,void 0))}function rI(n,e,t,i=[]){let r=e!=null?t.isSelected(e):!0,o=Pt.$isElementNode(t)&&t.excludeFromCopy("html");var s=t;if(e!==null){var a=G4.$cloneWithProperties(t);s=a=Pt.$isTextNode(a)&&e!=null?G4.$sliceSelectedTextNodeContent(e,a):a}let l=Pt.$isElementNode(s)?s.getChildren():[];var u=s;a=u.exportJSON(),a.type!==u.constructor.getType()&&Bc(58);var f=a.children;for(Pt.$isElementNode(u)&&(Array.isArray(f)||Bc(59)),Pt.$isTextNode(s)&&(s=s.__text,0<s.length?a.text=s:r=!1),s=0;s<l.length;s++)u=l[s],f=rI(n,e,u,a.children),!r&&Pt.$isElementNode(t)&&f&&t.extractWithChild(u,e,"clone")&&(r=!0);if(r&&!o)i.push(a);else if(Array.isArray(a.children))for(n=0;n<a.children.length;n++)i.push(a.children[n]);return r}function oI(n,e){let t=[],i=Pt.$getRoot().getChildren();for(let r=0;r<i.length;r++)rI(n,e,i[r],t);return{namespace:n._config.namespace,nodes:t}}function sI(n){let e=[];for(let t=0;t<n.length;t++){let i=Pt.$parseSerializedNode(n[t]);Pt.$isTextNode(i)&&G4.$addNodeStyle(i),e.push(i)}return e}let Xg=null;function aI(n,e){var t=window.getSelection();if(!t)return!1;var i=t.anchorNode;if(t=t.focusNode,i!==null&&t!==null&&!Pt.isSelectionWithinEditor(n,i,t)||(e.preventDefault(),e=e.clipboardData,i=Pt.$getSelection(),e===null||i===null))return!1;t=nI(n),n=iI(n);let r="";return i!==null&&(r=i.getTextContent()),t!==null&&e.setData("text/html",t),n!==null&&e.setData("application/x-lexical-editor",n),e.setData("text/plain",r),!0}Qc.$generateJSONFromSelectedNodes=oI,Qc.$generateNodesFromSerializedNodes=sI,Qc.$getHtmlContent=nI,Qc.$getLexicalContent=iI,Qc.$insertDataTransferForPlainText=function(n,e){n=n.getData("text/plain"),n!=null&&e.insertRawText(n)},Qc.$insertDataTransferForRichText=function(n,e,t){var i=n.getData("application/x-lexical-editor");if(i)try{let o=JSON.parse(i);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes)){let s=sI(o.nodes);return X4(t,s,e)}}catch{}if(i=n.getData("text/html"))try{var r=new DOMParser().parseFromString(i,"text/html");let o=tI.$generateNodesFromDOM(t,r);return X4(t,o,e)}catch{}if(n=n.getData("text/plain"),n!=null)if(Pt.$isRangeSelection(e))for(n=n.split(/\r?\n/),t=n.length,r=0;r<t;r++)e.insertText(n[r]),r<t-1&&e.insertParagraph();else e.insertRawText(n)},Qc.$insertGeneratedNodes=X4,Qc.copyToClipboard=async function(n,e){if(Xg!==null)return!1;if(e!==null)return new Promise(o=>{n.update(()=>{o(aI(n,e))})});var t=n.getRootElement();let i=document.getSelection();if(t===null||i===null)return!1;let r=document.createElement("span");return r.style.cssText="position: fixed; top: -1000px;",r.append(document.createTextNode("#")),t.append(r),t=new Range,t.setStart(r,0),t.setEnd(r,1),i.removeAllRanges(),i.addRange(t),new Promise(o=>{let s=n.registerCommand(Pt.COPY_COMMAND,a=>(a instanceof ClipboardEvent&&(s(),Xg!==null&&(window.clearTimeout(Xg),Xg=null),o(aI(n,a))),!0),Pt.COMMAND_PRIORITY_CRITICAL);Xg=window.setTimeout(()=>{s(),Xg=null,o(!1)},50),document.execCommand("copy"),r.remove()})};var x0=Qc;const que=n=>re.createElement("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},re.createElement("path",{d:"M4.47 1.867a4.525 4.525 0 015.02 1.378.4.4 0 01-.618.51 3.725 3.725 0 00-6.597 2.369v.159l.817-.817a.4.4 0 11.565.565l-1.48 1.48a.4.4 0 01-.605 0l-1.48-1.48a.4.4 0 11.565-.565l.818.817v-.16A4.526 4.526 0 014.47 1.868zm5.655 3.107a.4.4 0 01.283.117l1.5 1.5a.4.4 0 01-.566.565l-.822-.822A4.525 4.525 0 012.709 9.23a.4.4 0 01.582-.55 3.725 3.725 0 006.427-2.333l-.81.81a.4.4 0 11-.566-.565l1.5-1.5a.4.4 0 01.283-.117z"})),Hue=({snippets:n,onCreateSnippet:e,onUpdateSnippet:t,value:i,isCreateButtonActive:r,onKeyDown:o,activeMenuItem:s})=>{const a=B.useRef(null);return B.useEffect(()=>{var l,u;r?(l=a.current)==null||l.focus():(u=a.current)==null||u.blur()},[r]),fe("ul",{className:"absolute mt-[-1px] w-full max-w-[240px] rounded-b border border-grey-200 bg-white shadow dark:border-grey-900 dark:bg-grey-950",tabIndex:0,onKeyDown:o,children:[C("li",{className:"mb-0 block",children:fe("button",{ref:a,className:"flex w-full cursor-pointer items-center justify-between px-3 py-2 text-left text-sm font-medium text-green hover:bg-grey-100 focus:bg-grey-100 dark:hover:bg-black dark:focus:bg-black",type:"button",onClick:e,children:[fe("span",{children:['Create "',i,"“"]}),C(kb,{className:"h-3 w-3 stroke-green stroke-[3px]"})]})}),!!n.length&&C(jue,{activeMenuItem:s,list:n,onClick:t})]})},jue=({list:n=[],onClick:e,activeMenuItem:t})=>fe("li",{role:"separator",children:[C("span",{className:"tracking-loose block border-t border-grey-200 px-3 pt-3 pb-2 text-xs font-medium uppercase text-grey dark:border-grey-900 dark:text-grey-800",children:"Replace existing"}),C("ul",{role:"menu",children:n.map((i,r)=>C(Vue,{active:t,index:r,name:i.name,onClick:e},i.name))})]}),Vue=({onClick:n,name:e,active:t,index:i})=>{const r=B.useRef(null);return B.useEffect(()=>{var s,a;t===i?(s=r.current)==null||s.focus():(a=r.current)==null||a.blur()},[t,i]),C("li",{className:"mb-1",children:fe("button",{ref:r,className:"flex w-full cursor-pointer items-center justify-between py-2 px-3 text-left text-sm hover:bg-grey-100 focus:bg-grey-100 dark:hover:bg-black dark:focus:bg-black",type:"button",onClick:()=>n(e),children:[C("span",{children:e}),C("div",{className:"h-5 w-5 fill-grey-900",children:C(que,{className:"h-4 w-4 fill-grey-900 dark:fill-grey-600"})})]})})},Zue=({value:n,onChange:e,onClear:t,onKeyDown:i})=>fe("div",{className:"shadow-[0 18px 45px -5px rgba(0,0,0,.15)] relative m-0 flex h-[35px] min-w-[240px] items-center justify-evenly rounded bg-white py-0 font-sans text-sm font-medium before:absolute before:top-[35px] before:left-[calc(50%-8px)] before:w-0 before:border-x-[9px] before:border-t-[9px] before:border-x-transparent before:border-t-green after:absolute after:top-[35px] after:left-[calc(50%-8px)] after:ml-[1px] after:w-0 after:border-x-8 after:border-t-8 after:border-x-transparent after:border-t-white dark:after:border-t-grey-950",children:[C("input",{autoFocus:!0,className:`mb-[1px] h-auto w-full border bg-white py-1 pl-3 pr-9 font-normal leading-loose text-grey-900 selection:bg-grey/40 dark:bg-grey-950 dark:text-grey-100 dark:placeholder:text-grey-800 ${n?"rounded-t rounded-b-none border-grey-300 dark:border-grey-900":"rounded border-green"}`,"data-testid":"snippet-name",placeholder:"Snippet name",value:n,onChange:e,onKeyDown:i}),C("button",{"aria-label":"Close",className:"absolute right-3 cursor-pointer",type:"button",onClick:t,children:C(w0,{className:"h-3 w-3 stroke-2 text-grey"})})]});function lI({value:n,onChange:e,onCreateSnippet:t,onUpdateSnippet:i,onClose:r,darkMode:o,snippets:s=[]}){const a=B.useRef(null),[l,u]=B.useState(!1),[f,h]=B.useState(-1),v=(()=>s.filter(E=>E.name.toLowerCase().indexOf(n.toLowerCase())!==-1))();return B.useEffect(()=>{const E=T=>{a.current&&!a.current.contains(T.target)&&r()};return window.addEventListener("mousedown",E),()=>{window.removeEventListener("mousedown",E)}},[r]),fe("div",{ref:a,className:`${o?"dark":""}`,onClick:E=>E.stopPropagation(),children:[C("form",{onSubmit:E=>{E.preventDefault(),t()},children:C(Zue,{value:n,onChange:e,onClear:r,onKeyDown:E=>{(E.key==="Escape"||E.key==="Esc")&&(E.stopPropagation(),r()),(E.key==="ArrowDown"||E.key==="Down")&&(E.stopPropagation(),E.preventDefault(),u(!0))}})}),!!n&&C(Hue,{activeMenuItem:f,isCreateButtonActive:l,snippets:v,value:n,onCreateSnippet:t,onKeyDown:E=>{if(E.key==="ArrowDown"||E.key==="Down"){E.stopPropagation(),E.preventDefault();const T=f+1;T>v.length-1?(h(-1),u(!0)):(h(T),u(!1))}if(E.key==="ArrowUp"||E.key==="Up"){if(E.stopPropagation(),E.preventDefault(),l){h(v.length-1),u(!1);return}const T=f-1;T<0?(h(-1),u(!0)):(h(T),u(!1))}},onUpdateSnippet:i})]})}lI.propTypes={value:me.string,onChange:me.func,onCreateSnippet:me.func,onReplaceSnippet:me.func,onClose:me.func,suggestedList:me.arrayOf(me.shape({name:me.string.isRequired,value:me.string.isRequired}))};function Rr({onClose:n}){const{cardConfig:{snippets:e,createSnippet:t}}=B.useContext(bn),[i]=Ye.useLexicalComposerContext(),{selectedCardKey:r}=Nd(),[o,s]=B.useState(""),a=u=>{s(u.target.value)},l=u=>{i.update(()=>{if(r){const f=U.$createNodeSelection();f.add(r);const h=x0.$generateJSONFromSelectedNodes(i,f);t({name:u,value:JSON.stringify(h)}),i.dispatchCommand(S0,{cardKey:r})}else{const f=U.$getSelection(),h=x0.$generateJSONFromSelectedNodes(i,f);t({name:u,value:JSON.stringify(h)})}n==null||n()})};return C(lI,{snippets:e,value:o,onChange:a,onClose:n,onCreateSnippet:()=>l(o),onUpdateSnippet:u=>l(u)})}const Gue={bold:RA,italic:UA,headingOne:zA,headingTwo:WA,quote:qA,quoteOne:n=>re.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...n},re.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 8.00011H6C6.26522 8.00011 6.51957 8.10546 6.70711 8.293C6.89464 8.48054 7 8.73489 7 9.00011V13.0001C7 13.2653 6.89464 13.5197 6.70711 13.7072C6.51957 13.8947 6.26522 14.0001 6 14.0001H3C2.73478 14.0001 2.48043 13.8947 2.29289 13.7072C2.10536 13.5197 2 13.2653 2 13.0001V5.08211C2 3.90611 2.906 2.96211 4.538 2.11311C4.65448 2.05244 4.78177 2.0153 4.91261 2.00383C5.04344 1.99235 5.17525 2.00675 5.30052 2.04622C5.42579 2.08568 5.54205 2.14944 5.64268 2.23383C5.74331 2.31823 5.82633 2.42162 5.887 2.53811C5.94767 2.65459 5.9848 2.78188 5.99628 2.91271C6.00776 3.04355 5.99335 3.17536 5.95389 3.30063C5.91442 3.42589 5.85067 3.54216 5.76627 3.64279C5.68187 3.74342 5.57848 3.82644 5.462 3.88711C4.884 4.18711 4.469 4.47611 4.222 4.73411C4.054 4.90811 4 5.02011 4 5.08211V8.00011ZM13 8.00011C13.2652 8.00011 13.5196 8.10546 13.7071 8.293C13.8946 8.48054 14 8.73489 14 9.00011V9.5366C13.6143 9.60243 13.2536 9.7523 12.937 9.9445L12.9298 9.9489L12.4315 10.2608C11.9856 10.5357 11.5 11.0479 11.5 11.8252C11.5 12.5688 11.9611 13.2015 12.6323 13.4311V14.0001H10C9.73478 14.0001 9.48043 13.8947 9.29289 13.7072C9.10536 13.5197 9 13.2653 9 13.0001V5.08211C9 3.90611 9.906 2.96211 11.538 2.11311C11.6545 2.05244 11.7818 2.0153 11.9126 2.00383C12.0434 1.99235 12.1753 2.00675 12.3005 2.04622C12.4258 2.08568 12.5421 2.14944 12.6427 2.23383C12.7433 2.31823 12.8263 2.42162 12.887 2.53811C12.9477 2.65459 12.9848 2.78188 12.9963 2.91271C13.0078 3.04355 12.9934 3.17536 12.9539 3.30063C12.9144 3.42589 12.8507 3.54216 12.7663 3.64279C12.6819 3.74342 12.5785 3.82644 12.462 3.88711C11.884 4.18711 11.469 4.47611 11.222 4.73411C11.054 4.90811 11 5.02011 11 5.08211V8.00011H13ZM14.5428 15.4344C14.1182 15.4344 13.8823 15.1783 13.8823 14.7267V11.96H13.8722L13.6397 12.1082C13.4274 12.2329 13.3229 12.2734 13.1948 12.2734C12.9354 12.2734 12.75 12.0846 12.75 11.8252C12.75 11.6297 12.8646 11.4612 13.0904 11.323L13.5858 11.013C13.8688 10.8411 14.1587 10.7501 14.4249 10.7501C14.8933 10.7501 15.2 11.0635 15.2 11.5488V14.7267C15.2 15.1817 14.9641 15.4344 14.5428 15.4344Z"})),quoteTwo:n=>re.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},re.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 8.00015H6C6.26522 8.00015 6.51957 8.1055 6.70711 8.29304C6.89464 8.48058 7 8.73493 7 9.00015V13.0001C7 13.2654 6.89464 13.5197 6.70711 13.7073C6.51957 13.8948 6.26522 14.0001 6 14.0001H3C2.73478 14.0001 2.48043 13.8948 2.29289 13.7073C2.10536 13.5197 2 13.2654 2 13.0001V5.08215C2 3.90615 2.906 2.96215 4.538 2.11315C4.65448 2.05248 4.78177 2.01534 4.91261 2.00387C5.04344 1.99239 5.17525 2.00679 5.30052 2.04626C5.42579 2.08572 5.54205 2.14948 5.64268 2.23387C5.74331 2.31827 5.82633 2.42166 5.887 2.53815C5.94767 2.65463 5.9848 2.78192 5.99628 2.91275C6.00776 3.04359 5.99335 3.1754 5.95389 3.30067C5.91442 3.42593 5.85067 3.5422 5.76627 3.64283C5.68187 3.74346 5.57848 3.82648 5.462 3.88715C4.884 4.18715 4.469 4.47615 4.222 4.73415C4.054 4.90815 4 5.02015 4 5.08215V8.00015ZM13 8.00015C13.2652 8.00015 13.5196 8.1055 13.7071 8.29304C13.8946 8.48058 14 8.73493 14 9.00015V9.51812C13.4378 9.57694 12.9087 9.77735 12.4803 10.0918C11.9785 10.4601 11.5 11.0848 11.5 11.9043C11.5 12.3632 11.6772 12.8135 12.0264 13.1451C12.0604 13.1774 12.0955 13.208 12.1312 13.2369C11.9419 13.4409 11.7509 13.6922 11.6323 14.0001H10C9.73478 14.0001 9.48043 13.8948 9.29289 13.7073C9.10536 13.5197 9 13.2654 9 13.0001V5.08215C9 3.90615 9.906 2.96215 11.538 2.11315C11.6545 2.05248 11.7818 2.01534 11.9126 2.00387C12.0434 1.99239 12.1753 2.00679 12.3005 2.04626C12.4258 2.08572 12.5421 2.14948 12.6427 2.23387C12.7433 2.31827 12.8263 2.42166 12.887 2.53815C12.9477 2.65463 12.9848 2.78192 12.9963 2.91275C13.0078 3.04359 12.9934 3.1754 12.9539 3.30067C12.9144 3.42593 12.8507 3.5422 12.7663 3.64283C12.6819 3.74346 12.5785 3.82648 12.462 3.88715C11.884 4.18715 11.469 4.47615 11.222 4.73415C11.054 4.90815 11 5.02015 11 5.08215V8.00015H13ZM13.2256 15.1428C12.8903 15.1428 12.6626 14.9404 12.6626 14.6432C12.6626 14.4218 12.7891 14.2257 13.1591 13.8779L14.1616 12.907C14.4937 12.5876 14.6391 12.3789 14.6391 12.1607C14.6391 11.9045 14.4526 11.7337 14.1806 11.7337C13.9687 11.7337 13.8169 11.8255 13.6556 12.0532C13.4785 12.2872 13.3457 12.3694 13.1402 12.3694C12.8524 12.3694 12.65 12.1765 12.65 11.9045C12.65 11.2973 13.371 10.7502 14.247 10.7502C15.1546 10.7502 15.825 11.2973 15.825 12.0373C15.825 12.4959 15.5879 12.926 15.0787 13.3908L14.2881 14.1245V14.172H15.4203C15.765 14.172 15.98 14.3585 15.98 14.6621C15.98 14.9626 15.7713 15.1428 15.4203 15.1428H13.2256Z"})),link:XS,imageRegular:ZS,imageWide:GS,imageFull:jS,imageReplace:HA,add:IA,edit:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...n},re.createElement("path",{d:"M16.19 3.51a.51.51 0 0 0-.71 0L4.07 14.92a.5.5 0 0 0 0 .71l4.28 4.28a.48.48 0 0 0 .7 0L20.47 8.5a.51.51 0 0 0 0-.71ZM3 16.71a.51.51 0 0 0-.47-.13.48.48 0 0 0-.36.33L0 23.33a.49.49 0 0 0 .12.51.5.5 0 0 0 .54.16l6.42-2.14a.52.52 0 0 0 .33-.36.49.49 0 0 0-.14-.5ZM23 1a3.6 3.6 0 0 0-5 0l-.71.71a.5.5 0 0 0 0 .71l4.28 4.28a.51.51 0 0 0 .7 0L23 6a3.53 3.53 0 0 0 0-5Z"})),snippet:wb};function Fr({children:n,hide:e,...t}){return e?null:C("ul",{className:"relative m-0 flex items-center justify-evenly rounded bg-black px-1 py-0 font-sans text-md font-normal text-white after:absolute after:top-[36px] after:left-[calc(50%-8px)] after:w-0 after:border-x-8 after:border-t-8 after:border-x-transparent after:border-t-black",...t,children:n})}function qt({label:n,isActive:e,onClick:t,icon:i,dataTestId:r,hide:o,...s}){if(o)return null;const a=Gue[i];return C("li",{className:"m-0 flex p-0 first:m-0",...s,children:C("button",{"aria-label":n,className:"flex h-9 w-9 cursor-pointer items-center justify-center","data-kg-active":e,"data-testid":r,type:"button",onClick:t,children:C(a,{className:` h-4 w-4 ${e?"fill-green":"fill-white"} `})})})}function Qr({hide:n}){return n?null:C("li",{className:"m-0 mx-1 h-5 w-px bg-grey-900"})}function Xue({author:n,nodeKey:e,url:t,icon:i,title:r,description:o,publisher:s,thumbnail:a,captionEditor:l,captionEditorInitialState:u,createdWithUrl:f}){const[h]=Ye.useLexicalComposerContext(),{cardConfig:p}=B.useContext(bn),{isSelected:v}=B.useContext(or),[w,O]=B.useState(t),[_,E]=B.useState(!1),[T,A]=B.useState(!1),[D,M]=B.useState(!1),I=Z=>{O(Z.target.value)},z=async Z=>{Z.key==="Enter"&&te(Z.target.value)},V=async()=>{A(!1)},K=B.useCallback(()=>{h.update(()=>{const Z=U.$getNodeByKey(e),q=U.$createParagraphNode().append(Vs.$createLinkNode(w).append(U.$createTextNode(w)));Z.replace(q),q.selectEnd()})},[h,e,w]),X=()=>{h.update(()=>{U.$getNodeByKey(e).remove()})},te=async Z=>{E(!0);let q;try{q=await p.fetchEmbed(Z,{type:"bookmark"})}catch{E(!1),A(!0);return}h.update(()=>{const W=U.$getNodeByKey(e);W.setUrl(q.url),W.setAuthor(q.metadata.author),W.setIcon(q.metadata.icon),W.setTitle(q.metadata.title),W.setDescription(q.metadata.description),W.setPublisher(q.metadata.publisher),W.setThumbnail(q.metadata.thumbnail)}),E(!1)},se=B.useCallback(async()=>{E(!0);let Z;try{Z=await p.fetchEmbed(t,{type:"bookmark"})}catch{E(!1),A(!0);return}h.update(()=>{const q=U.$getNodeByKey(e);q.setUrl(Z.url),q.setAuthor(Z.metadata.author),q.setIcon(Z.metadata.icon),q.setTitle(Z.metadata.title),q.setDescription(Z.metadata.description),q.setPublisher(Z.metadata.publisher),q.setThumbnail(Z.metadata.thumbnail)}),E(!1)},[]);return B.useEffect(()=>{if(f){O(t);try{se(t)}catch{K(t)}}},[]),fe(yt,{children:[C(eI,{author:n,captionEditor:l,captionEditorInitialState:u,description:o,handleClose:X,handlePasteAsLink:K,handleRetry:V,handleUrlChange:I,handleUrlSubmit:z,icon:i,isLoading:_,isSelected:v,publisher:s,thumbnail:a,title:r,url:t,urlError:T,urlInputValue:w,urlPlaceholder:"Paste URL to add bookmark content..."}),C(pn,{"data-kg-card-toolbar":"bookmark",isVisible:D,children:C(Rr,{onClose:()=>M(!1)})}),C(pn,{"data-kg-card-toolbar":"bookmark",isVisible:r&&v&&!D&&p.createSnippet,children:C(Fr,{children:C(qt,{dataTestId:"create-snippet",hide:!p.createSnippet,icon:"snippet",isActive:!1,label:"Snippet",onClick:()=>M(!0)})})})]})}class Yk extends tue{constructor(t={},i){super(t,i);ke(this,"__captionEditor");ke(this,"__captionEditorInitialState");ke(this,"__createdWithUrl");if(this.__createdWithUrl=!!t.url,this.__captionEditor=t.captionEditor||U.createEditor({nodes:Jn}),this.__captionEditorInitialState=t.captionEditorInitialState,!this.__captionEditorInitialState){const r=t.caption?`<p>${t.caption}</p>`:null;this.__captionEditorInitialState=bo({editor:U.createEditor({nodes:Jn}),initialHtml:r})}}getIcon(){return LS}createDOM(){return document.createElement("div")}getDataset(){const t=super.getDataset(),i=this.getLatest();return t.captionEditor=i.__captionEditor,t.captionEditorInitialState=i.__captionEditorInitialState,t}exportJSON(){const t=super.exportJSON();return this.__captionEditor&&this.__captionEditor.getEditorState().read(()=>{const i=ar.$generateHtmlFromNodes(this.__captionEditor,null),r=so(i);t.caption=r}),t}updateDOM(){return!1}decorate(){return C(Yi,{nodeKey:this.getKey(),children:C(Xue,{author:this.__author,captionEditor:this.__captionEditor,captionEditorInitialState:this.__captionEditorInitialState,createdWithUrl:this.__createdWithUrl,description:this.__description,icon:this.__icon,nodeKey:this.getKey(),publisher:this.__publisher,thumbnail:this.__thumbnail,title:this.__title,url:this.__url})})}}ke(Yk,"kgMenu",[{label:"Bookmark",desc:"Embed a link as a visual bookmark",Icon:LS,insertCommand:DL,matches:["bookmark"],queryParams:["url"]}]);const cI=n=>new Yk(n),Gpt="";function uI({captionEditor:n,captionEditorInitialState:e,html:t,isSelected:i,urlInputValue:r,urlPlaceholder:o,urlError:s,isLoading:a,handleUrlChange:l,handleUrlSubmit:u,handleRetry:f,handlePasteAsLink:h,handleClose:p}){return t?fe(yt,{children:[C(Yue,{dataTestId:"embed-iframe",html:t}),C(Gg,{captionEditor:n,captionEditorInitialState:e,captionPlaceholder:"Type caption for embed (optional)",dataTestId:"embed-caption",isSelected:i}),C("div",{className:"absolute inset-0 z-50 mt-0"})]}):C(JL,{dataTestId:"embed-url",handleClose:p,handlePasteAsLink:h,handleRetry:f,handleUrlChange:l,handleUrlSubmit:u,hasError:s,isLoading:a,placeholder:o,value:r})}function Yue({dataTestId:n,html:e}){const t=B.useRef(null),i=()=>{const o=t.current.contentDocument.body.firstChild;if(!o)return;if(o.tagName==="IFRAME"){const a=o.getAttribute("width");if(a.indexOf("%")===-1){const u=parseInt(o.getAttribute("height"));if(a&&u){const f=a/u,h=t.current.offsetWidth/f;o.style.height=`${h}px`,t.current.style.height=`${h}px`,o.style.width="100%";return}}const l=o.getAttribute("height");if(l.indexOf("%")===-1){t.current.style.height=`${l}px`;return}}const s=t.current.contentDocument.scrollingElement.scrollHeight;t.current.style.height=`${s}px`},r=()=>{const o=t.current.contentDocument.body;o.style.display="flex",o.style.margin="0",o.style.justifyContent="center",i()};return B.useEffect(()=>{const o=new ResizeObserver(i);return o.observe(t.current),function(){o.disconnect()}},[]),C("iframe",{ref:t,className:"bn miw-100 w-full","data-testid":n,srcDoc:e,tabIndex:-1,title:"embed-card-iframe",onLoad:r})}uI.propTypes={html:me.string};function Kue({nodeKey:n,url:e,html:t,createdWithUrl:i,embedType:r,metadata:o,captionEditor:s,captionEditorInitialState:a}){const[l]=Ye.useLexicalComposerContext(),{cardConfig:u}=B.useContext(bn),{isSelected:f}=B.useContext(or),[h,p]=B.useState(""),[v,w]=B.useState(!1),[O,_]=B.useState(!1),[E,T]=B.useState(!1),A=K=>{p(K.target.value)},D=async K=>{K.key==="Enter"&&V(K.target.value)},M=async()=>{_(!1)},I=B.useCallback(()=>{l.update(()=>{const K=U.$getNodeByKey(n),X=U.$createParagraphNode().append(Vs.$createLinkNode(h).append(U.$createTextNode(h)));K.replace(X),X.selectEnd()})},[l,n,h]),z=()=>{l.update(()=>{U.$getNodeByKey(n).remove()})},V=async K=>{w(!0);let X;const te=i?"":"embed";try{if(X=await u.fetchEmbed(K,{type:te}),X.type==="bookmark"){l.update(()=>{const se=U.$getNodeByKey(n),Z=cI({url:X.url});se.replace(Z)});return}}catch{w(!1),_(!0);return}l.update(()=>{const se=U.$getNodeByKey(n);se.setUrl(X.url),se.setMetadata(X),se.setEmbedType(X.type),se.setHtml(X.html)}),w(!1)};return B.useEffect(()=>{if(i){p(e);try{V(e)}catch{I(e)}}},[]),fe(yt,{children:[C(uI,{captionEditor:s,captionEditorInitialState:a,handleClose:z,handlePasteAsLink:I,handleRetry:M,handleUrlChange:A,handleUrlSubmit:D,html:t,isLoading:v,isSelected:f,metadata:o,url:e,urlError:O,urlInputValue:h,urlPlaceholder:"Paste URL to add embedded content..."}),C(pn,{"data-kg-card-toolbar":"embed",isVisible:E,children:C(Rr,{onClose:()=>T(!1)})}),C(pn,{"data-kg-card-toolbar":"embed",isVisible:t&&f&&!E&&u.createSnippet,children:C(Fr,{children:C(qt,{dataTestId:"create-snippet",hide:!u.createSnippet,icon:"snippet",isActive:!1,label:"Snippet",onClick:()=>T(!0)})})})]})}class Kk extends _ue{constructor(t={},i){super(t,i);ke(this,"__captionEditor");ke(this,"__captionEditorInitialState");ke(this,"__createdWithUrl");if(this.__createdWithUrl=!!t.url,this.__captionEditor=t.captionEditor||U.createEditor({nodes:Jn}),this.__captionEditorInitialState=t.captionEditorInitialState,!this.__captionEditorInitialState){const r=t.caption?`<p>${t.caption}</p>`:null;this.__captionEditorInitialState=bo({editor:U.createEditor({nodes:Jn}),initialHtml:r})}}getIcon(){return KS}createDOM(){return document.createElement("div")}getDataset(){const t=super.getDataset(),i=this.getLatest();return t.captionEditor=i.__captionEditor,t.captionEditorInitialState=i.__captionEditorInitialState,t}exportJSON(){const t=super.exportJSON();return this.__captionEditor&&this.__captionEditor.getEditorState().read(()=>{const i=ar.$generateHtmlFromNodes(this.__captionEditor,null),r=so(i);t.caption=r}),t}updateDOM(){return!1}decorate(){return C(Yi,{nodeKey:this.getKey(),children:C(Kue,{captionEditor:this.__captionEditor,captionEditorInitialState:this.__captionEditorInitialState,createdWithUrl:this.__createdWithUrl,embedType:this.__embedType,html:this.__html,metadata:this.__metadata,nodeKey:this.getKey(),url:this.__url})})}}ke(Kk,"kgMenu",[{section:"Embed",label:"Other...",desc:"Embed a link as a visual embed",Icon:KS,insertCommand:Ku,matches:["embed"],queryParams:["url"]},{section:"Embed",label:"Twitter",desc:"/twitter [tweet url]",Icon:GA,insertCommand:Ku,queryParams:["url"],matches:["twitter"]},{section:"Embed",label:"YouTube",desc:"/youtube [video url]",Icon:YA,insertCommand:Ku,queryParams:["url"],matches:["youtube"]},{section:"Embed",label:"Vimeo",desc:"/vimeo [video url]",Icon:XA,insertCommand:Ku,queryParams:["url"],matches:["vimeo"]},{section:"Embed",label:"CodePen",desc:"/codepen [pen url]",Icon:FA,insertCommand:Ku,queryParams:["url"],matches:["codepen"]},{section:"Embed",label:"Spotify",desc:"/spotify [track or playlist url]",Icon:ZA,insertCommand:Ku,queryParams:["url"],matches:["spotify"]},{section:"Embed",label:"SoundCloud",desc:"/soundcloud [track or playlist url]",Icon:VA,insertCommand:Ku,queryParams:["url"],matches:["soundcloud"]}]);const fI=n=>new Kk(n),O0=({selectedNode:n,newNode:e})=>{const t=U.$isParagraphNode(n),i=n.getTextContent()==="";n.getTopLevelElementOrThrow().insertAfter(e),t&&i&&n.remove();const r=U.$createNodeSelection();if(r.add(e.getKey()),U.$setSelection(r),!e.getNextSibling()){const o=U.$createParagraphNode();e.getTopLevelElementOrThrow().insertAfter(o)}};function Y4(n){var r;let[e]=n.getNodes();U.$isTextNode(e)&&(e=e.getParent());const t=e.getIndexWithinParent(),i=(r=e.getTopLevelElement())==null?void 0:r.getIndexWithinParent();return t===0&&i===0&&n.anchor.offset===0&&n.focus.offset===0}function lo(n){const e=U.$createNodeSelection();e.add(n.getKey()),U.$setSelection(e)}var Oo={},Cn=U,Hd=Ut;function Yg(n){throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?code=${n} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function dI(n){let e=1;for(n=n.getParent();n!=null;){if(hi(n)){if(n=n.getParent(),tn(n)){e++,n=n.getParent();continue}Yg(40)}break}return e}function K4(n){n=n.getParent(),tn(n)||Yg(40);let e=n;for(;e!==null;)e=e.getParent(),tn(e)&&(n=e);return n}function hI(n){let e=[];n=n.getChildren().filter(hi);for(let t=0;t<n.length;t++){let i=n[t],r=i.getFirstChild();tn(r)?e=e.concat(hI(r)):e.push(i)}return e}function Cl(n){return hi(n)&&tn(n.getFirstChild())}function Jue(n){for(;n.getNextSibling()==null&&n.getPreviousSibling()==null;){let e=n.getParent();if(e==null||!hi(n)&&!tn(n))break;n=e}n.remove()}function gI(n){return Ks().append(n)}function pI(n,e){return hi(n)&&(e.length===0||e.length===1&&n.is(e[0])&&n.getChildrenSize()===0)}function jd(n,e){n.splice(n.getChildrenSize(),0,e)}function mI(n,e){if(tn(n))return n;let t=n.getPreviousSibling(),i=n.getNextSibling(),r=Ks();return r.setFormat(n.getFormatType()),r.setIndent(n.getIndent()),jd(r,n.getChildren()),tn(t)&&e===t.getListType()?(t.append(r),n.remove(),tn(i)&&e===i.getListType()&&(jd(t,i.getChildren()),i.remove()),t):tn(i)&&e===i.getListType()?(i.getFirstChildOrThrow().insertBefore(r),n.remove(),i):(e=Co(e),e.append(r),n.replace(e),So(e),e)}function vI(n,e){var t=n.getLastChild();let i=e.getFirstChild();t&&i&&Cl(t)&&Cl(i)&&(vI(t.getFirstChild(),i.getFirstChild()),i.remove()),t=e.getChildren(),0<t.length&&(n.append(...t),So(n)),e.remove()}function So(n,e){if(n=e||n.getChildren(),n!==void 0)for(e=0;e<n.length;e++){let o=n[e];if(hi(o)){let s=o.getValue();var t=o,i=t.getParent(),r=1;for(i!=null&&(tn(i)?r=i.getStart():Yg(44)),t=t.getPreviousSiblings(),i=0;i<t.length;i++){let a=t[i];hi(a)&&!tn(a.getFirstChild())&&r++}s!==r&&o.setValue(r)}}}function efe(n){if(!Cl(n)){var e=n.getParent(),t=e?e.getParent():void 0,i=t?t.getParent():void 0;if(tn(i)&&hi(t)&&tn(e)){var r=e?e.getFirstChild():void 0,o=e?e.getLastChild():void 0;if(n.is(r))t.insertBefore(n),e.isEmpty()&&t.remove();else if(n.is(o))t.insertAfter(n),e.isEmpty()&&t.remove();else{var s=e.getListType();r=Ks();let a=Co(s);r.append(a),n.getPreviousSiblings().forEach(l=>a.append(l)),o=Ks(),s=Co(s),o.append(s),jd(s,n.getNextSiblings()),t.insertBefore(r),t.insertAfter(o),t.replace(n)}So(e),So(i)}}}let Jk=class DA extends Cn.ElementNode{static getType(){return"listitem"}static clone(e){return new DA(e.__value,e.__checked,e.__key)}constructor(e,t,i){super(i),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){let t=document.createElement("li"),i=this.getParent();return tn(i)&&i.getListType()==="check"&&bI(t,this,null),t.value=this.__value,yI(t,e.theme,this),t}updateDOM(e,t,i){let r=this.getParent();return tn(r)&&r.getListType()==="check"&&bI(t,this,e),t.value=this.__value,yI(t,i.theme,this),!1}static transform(){return e=>{let t=e.getParent();tn(t)&&(So(t),t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0))}}static importDOM(){return{li:()=>({conversion:tfe,priority:0})}}static importJSON(e){let t=new DA(e.value,e.checked);return t.setFormat(e.format),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){let i=e[t];if(Cn.$isElementNode(i)&&this.canMergeWith(i)){let r=i.getChildren();this.append(...r),i.remove()}else super.append(i)}return this}replace(e,t){if(hi(e))return super.replace(e);this.setIndent(0);let i=this.getParentOrThrow();if(!tn(i))return e;if(i.__first===this.getKey())i.insertBefore(e);else if(i.__last===this.getKey())i.insertAfter(e);else{let r=Co(i.getListType()),o=this.getNextSibling();for(;o;){let s=o;o=o.getNextSibling(),r.append(s)}i.insertAfter(e),e.insertAfter(r)}return t&&this.getChildren().forEach(r=>{e.append(r)}),this.remove(),i.getChildrenSize()===0&&i.remove(),e}insertAfter(e,t=!0){var i=this.getParentOrThrow();tn(i)||Yg(39);var r=this.getNextSiblings();if(hi(e))return t=super.insertAfter(e,t),e=e.getParentOrThrow(),tn(e)&&So(e),t;if(tn(e)&&e.getListType()===i.getListType()){for(i=e,e=e.getChildren(),r=e.length-1;0<=r;r--)i=e[r],this.insertAfter(i,t);return i}if(i.insertAfter(e,t),r.length!==0){let o=Co(i.getListType());r.forEach(s=>o.append(s)),e.insertAfter(o,t)}return e}remove(e){let t=this.getPreviousSibling(),i=this.getNextSibling();super.remove(e),t&&i&&Cl(t)&&Cl(i)?(vI(t.getFirstChild(),i.getFirstChild()),i.remove()):i&&(e=i.getParent(),tn(e)&&So(e))}insertNewAfter(e,t=!0){return e=Ks(this.__checked==null?void 0:!1),this.insertAfter(e,t),e}collapseAtStart(e){let t=Cn.$createParagraphNode();this.getChildren().forEach(s=>t.append(s));var i=this.getParentOrThrow(),r=i.getParentOrThrow();let o=hi(r);return i.getChildrenSize()===1?o?(i.remove(),r.select()):(i.insertBefore(t),i.remove(),i=e.anchor,e=e.focus,r=t.getKey(),i.type==="element"&&i.getNode().is(this)&&i.set(r,i.offset,"element"),e.type==="element"&&e.getNode().is(this)&&e.set(r,e.offset,"element")):(i.insertBefore(t),this.remove()),!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){return this.getLatest().__checked}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){var e=this.getParent();if(e===null)return this.getLatest().__indent;e=e.getParentOrThrow();let t=0;for(;hi(e);)e=e.getParentOrThrow().getParentOrThrow(),t++;return t}setIndent(e){typeof e=="number"&&-1<e||Yg(117);let t=this.getIndent();for(;t!==e;)if(t<e){e:{var i=new Set;if(Cl(this)||i.has(this.getKey()))break e;let a=this.getParent();var r=this.getNextSibling(),o=this.getPreviousSibling();if(Cl(r)&&Cl(o)){if(o=o.getFirstChild(),tn(o)){o.append(this);var s=r.getFirstChild();tn(s)&&(s=s.getChildren(),jd(o,s),r.remove(),i.add(r.getKey())),So(o)}}else Cl(r)?(r=r.getFirstChild(),tn(r)&&(i=r.getFirstChild(),i!==null&&i.insertBefore(this),So(r))):Cl(o)?(r=o.getFirstChild(),tn(r)&&(r.append(this),So(r))):tn(a)&&(i=Ks(),s=Co(a.getListType()),i.append(s),s.append(this),o?o.insertAfter(i):r?r.insertBefore(i):a.append(i),So(s));tn(a)&&So(a)}t++}else efe(this),t--;return this}insertBefore(e){if(hi(e)){let t=this.getParentOrThrow();if(tn(t)){let i=this.getNextSiblings();So(t,i)}}return super.insertBefore(e)}canInsertAfter(e){return hi(e)}canReplaceWith(e){return hi(e)}canMergeWith(e){return Cn.$isParagraphNode(e)||hi(e)}extractWithChild(e,t){if(!Cn.$isRangeSelection(t))return!1;e=t.anchor.getNode();let i=t.focus.getNode();return this.isParentOf(e)&&this.isParentOf(i)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Co("bullet")}};function yI(n,e,t){let i=[],r=[];var o=(e=e.list)?e.listitem:void 0;if(e&&e.nested)var s=e.nested.listitem;if(o!==void 0&&(o=o.split(" "),i.push(...o)),e){o=t.getParent(),o=tn(o)&&o.getListType()==="check";let a=t.getChecked();o&&!a||r.push(e.listitemUnchecked),o&&a||r.push(e.listitemChecked),o&&i.push(a?e.listitemChecked:e.listitemUnchecked)}s!==void 0&&(s=s.split(" "),t.getChildren().some(a=>tn(a))?i.push(...s):r.push(...s)),0<r.length&&Hd.removeClassNamesFromElement(n,...r),0<i.length&&Hd.addClassNamesToElement(n,...i)}function bI(n,e,t){tn(e.getFirstChild())?(n.removeAttribute("role"),n.removeAttribute("tabIndex"),n.removeAttribute("aria-checked")):(n.setAttribute("role","checkbox"),n.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||n.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function tfe(n){return n=Hd.isHTMLElement(n)&&n.getAttribute("aria-checked")==="true",{node:Ks(n)}}function Ks(n){return Cn.$applyNodeReplacement(new Jk(void 0,n))}function hi(n){return n instanceof Jk}let J4=class yK extends Cn.ElementNode{static getType(){return"list"}static clone(e){return new yK(e.__listType||_I[e.__tag],e.__start,e.__key)}constructor(e,t,i){super(i),this.__listType=e=_I[e]||e,this.__tag=e==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e){let t=document.createElement(this.__tag);return this.__start!==1&&t.setAttribute("start",String(this.__start)),t.__lexicalListType=this.__listType,kI(t,e.theme,this),t}updateDOM(e,t,i){return e.__tag!==this.__tag?!0:(kI(t,i.theme,this),!1)}static importDOM(){return{ol:()=>({conversion:wI,priority:0}),ul:()=>({conversion:wI,priority:0})}}static importJSON(e){let t=Co(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){return{element:e}=super.exportDOM(e),e&&(this.__start!==1&&e.setAttribute("start",String(this.__start)),this.__listType==="check"&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let i=0;i<e.length;i++){var t=e[i];if(hi(t))super.append(t);else{let r=Ks();tn(t)||Cn.$isElementNode(t)&&(t=Cn.$createTextNode(t.getTextContent())),r.append(t),super.append(r)}}return So(this),this}extractWithChild(e){return hi(e)}};function kI(n,e,t){let i=[],r=[];var o=e.list;if(o!==void 0){let a=o[`${t.__tag}Depth`]||[];e=dI(t)-1;let l=e%a.length;var s=a[l];let u=o[t.__tag],f;if(o=o.nested,o!==void 0&&o.list&&(f=o.list),u!==void 0&&i.push(u),s!==void 0)for(s=s.split(" "),i.push(...s),s=0;s<a.length;s++)s!==l&&r.push(t.__tag+s);f!==void 0&&(t=f.split(" "),1<e?i.push(...t):r.push(...t))}0<r.length&&Hd.removeClassNamesFromElement(n,...r),0<i.length&&Hd.addClassNamesToElement(n,...i)}function nfe(n){let e=[];for(let i=0;i<n.length;i++){var t=n[i];hi(t)?(e.push(t),t=t.getChildren(),1<t.length&&t.forEach(r=>{tn(r)&&e.push(gI(r))})):e.push(gI(t))}return e}function wI(n){let e=n.nodeName.toLowerCase(),t=null;return e==="ol"?t=Co("number",n.start):e==="ul"&&(t=Hd.isHTMLElement(n)&&n.getAttribute("__lexicallisttype")==="check"?Co("check"):Co("bullet")),{after:nfe,node:t}}let _I={ol:"number",ul:"bullet"};function Co(n,e=1){return Cn.$applyNodeReplacement(new J4(n,e))}function tn(n){return n instanceof J4}let ife=Cn.createCommand("INSERT_UNORDERED_LIST_COMMAND"),rfe=Cn.createCommand("INSERT_ORDERED_LIST_COMMAND"),ofe=Cn.createCommand("INSERT_CHECK_LIST_COMMAND"),sfe=Cn.createCommand("REMOVE_LIST_COMMAND");Oo.$createListItemNode=Ks,Oo.$createListNode=Co,Oo.$getListDepth=dI,Oo.$handleListInsertParagraph=function(){var n=Cn.$getSelection();if(!Cn.$isRangeSelection(n)||!n.isCollapsed()||(n=n.anchor.getNode(),!hi(n)||n.getTextContent()!==""))return!1;var e=K4(n),t=n.getParent();tn(t)||Yg(40);let i=t.getParent(),r;if(Cn.$isRootOrShadowRoot(i))r=Cn.$createParagraphNode(),e.insertAfter(r);else if(hi(i))r=Ks(),i.insertAfter(r);else return!1;if(r.select(),e=n.getNextSiblings(),0<e.length){let o=Co(t.getListType());Cn.$isParagraphNode(r)?r.insertAfter(o):(t=Ks(),t.append(o),r.insertAfter(t)),e.forEach(s=>{s.remove(),o.append(s)})}return Jue(n),!0},Oo.$isListItemNode=hi,Oo.$isListNode=tn,Oo.INSERT_CHECK_LIST_COMMAND=ofe,Oo.INSERT_ORDERED_LIST_COMMAND=rfe,Oo.INSERT_UNORDERED_LIST_COMMAND=ife,Oo.ListItemNode=Jk,Oo.ListNode=J4,Oo.REMOVE_LIST_COMMAND=sfe,Oo.insertList=function(n,e){n.update(()=>{var t=Cn.$getSelection();if(Cn.$isRangeSelection(t)||Cn.DEPRECATED_$isGridSelection(t)){var i=t.getNodes();t=t.anchor.getNode();var r=t.getParent();if(pI(t,i))i=Co(e),Cn.$isRootOrShadowRoot(r)?(t.replace(i),r=Ks(),Cn.$isElementNode(t)&&(r.setFormat(t.getFormatType()),r.setIndent(t.getIndent())),i.append(r)):hi(t)&&(t=t.getParentOrThrow(),jd(i,t.getChildren()),t.replace(i));else for(t=new Set,r=0;r<i.length;r++){var o=i[r];if(Cn.$isElementNode(o)&&o.isEmpty()&&!t.has(o.getKey()))mI(o,e);else if(Cn.$isLeafNode(o))for(o=o.getParent();o!=null;){let a=o.getKey();if(tn(o)){if(!t.has(a)){var s=Co(e);jd(s,o.getChildren()),o.replace(s),So(s),t.add(a)}break}else{if(s=o.getParent(),Cn.$isRootOrShadowRoot(s)&&!t.has(a)){t.add(a),mI(o,e);break}o=s}}}}})},Oo.removeList=function(n){n.update(()=>{let e=Cn.$getSelection();if(Cn.$isRangeSelection(e)){var t=new Set,i=e.getNodes(),r=e.anchor.getNode();if(pI(r,i))t.add(K4(r));else for(r=0;r<i.length;r++){var o=i[r];Cn.$isLeafNode(o)&&(o=Hd.$getNearestNodeOfType(o,Jk),o!=null&&t.add(K4(o)))}for(let s of t){t=s,i=hI(s);for(let a of i)i=Cn.$createParagraphNode(),jd(i,a.getChildren()),t.insertAfter(i),t=i,a.__key===e.anchor.key&&e.anchor.set(i.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(i.getKey(),0,"element"),a.remove();s.remove()}}})};var jo=Oo;const Sr=U.createCommand("INSERT_CARD_COMMAND"),S0=U.createCommand("SELECT_CARD_COMMAND"),afe=U.createCommand("DESELECT_CARD_COMMAND"),El=U.createCommand("EDIT_CARD_COMMAND"),Kg=U.createCommand("DELETE_CARD_COMMAND"),xI=10;function OI(n){n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);const e="[data-lexical-editor] > *";return n.closest(e)}function eE(n,e){const t=U.$createNodeSelection();t.add(e),U.$setSelection(t),n.getRootElement().focus()}function C0(n,e){var i;const t=U.$getNodeByKey(e);(i=t==null?void 0:t.isEmpty)!=null&&i.call(t)&&lfe(n,t)}function lfe(n,e){if(U.$getRoot().getLastChild().is(e)){const t=U.$createParagraphNode();U.$getRoot().append(t),t.select()}else{const t=e.getNextSibling();U.$isDecoratorNode(t)?(lo(t),n.getRootElement().focus()):t.selectStart()}e.remove()}function cfe({editor:n,containerElem:e,cursorDidExitAtTop:t,isNested:i}){const{selectedCardKey:r,setSelectedCardKey:o,isEditingCard:s,setIsEditingCard:a}=Nd();return B.useEffect(()=>{const l=u=>{e.current&&!e.current.contains(u.target)&&n.update(()=>{const f=U.$getSelection();U.$isNodeSelection(f)&&U.$setSelection(null)},{tag:"history-merge"})};return i||window.addEventListener("mousedown",l),()=>{window.removeEventListener("mousedown",l)}},[n,e,i]),B.useEffect(()=>Ut.mergeRegister(n.registerUpdateListener(({editorState:l,tags:u})=>{if(u.has("collaboration")||u.has("card-export")||i||document.activeElement.closest("[data-lexical-decorator]"))return;const{isCardSelected:f,cardKey:h,cardNode:p}=l.read(()=>{const v=U.$getSelection();if(U.$isNodeSelection(v)&&v.getNodes().length===1&&F4(v.getNodes()[0])){const O=v.getNodes()[0];return{isCardSelected:!0,cardKey:O.getKey(),cardNode:O}}else return{isCardSelected:!1}});f&&!r?(o(h),a(!1)):f&&r!==h&&n.update(()=>{C0(n,r),o(h),a(!1)},{tag:"history-merge"}),!f&&r&&n.update(()=>{C0(n,r),o(null),a(!1)},{tag:"history-merge"}),f&&p.__openInEditMode&&(n.update(()=>{p.clearOpenInEditMode()},{tag:"history-merge"}),a(!0))}),n.registerCommand(Sr,({cardNode:l,openInEditMode:u})=>{let f;const h=U.$getSelection();if(U.$isRangeSelection(h))f=h.focus.getNode();else if(U.$isNodeSelection(h))f=h.getNodes()[0];else return!1;return f!==null&&(O0({selectedNode:f,newNode:l}),o(l.getKey()),u&&a(!0)),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(S0,({cardKey:l})=>{var u;if(r===l&&s){const f=U.$getNodeByKey(l);if((u=f.isEmpty)!=null&&u.call(f))return n.dispatchCommand(Kg,{cardKey:l}),!0}r&&r!==l&&C0(n,r),eE(n,l),o(l),a(!1)},U.COMMAND_PRIORITY_LOW),n.registerCommand(El,({cardKey:l})=>{var f;r&&r!==l&&C0(n,r),eE(n,l),o(l);const u=U.$getNodeByKey(l);(f=u.hasEditMode)!=null&&f.call(u)&&a(!0)},U.COMMAND_PRIORITY_LOW),n.registerCommand(afe,({cardKey:l})=>{C0(n,l),o(null),a(!1)},U.COMMAND_PRIORITY_LOW),n.registerCommand(Kg,({cardKey:l,direction:u="forward"})=>{const f=U.$getNodeByKey(l),h=f.getPreviousSibling(),p=f.getNextSibling();if(u==="backward"&&h)if(h.selectEnd)h.selectEnd();else if(U.$isDecoratorNode(h)){const v=U.$createNodeSelection();v.add(h.getKey()),U.$setSelection(v)}else f.selectPrevious();else if(p)if(p.selectStart)p.selectStart();else if(U.$isDecoratorNode(p)){const v=U.$createNodeSelection();v.add(p.getKey()),U.$setSelection(v)}else f.selectNext();else{const v=U.$createParagraphNode();U.$getRoot().append(v),v.select()}return f.remove(),n.getRootElement().focus(),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ENTER_COMMAND,l=>{var u,f;if(r&&(l.metaKey||l.ctrlKey)){l.preventDefault();const h=U.$getNodeByKey(r);if((u=h.hasEditMode)!=null&&u.call(h))if(s){if(n.getRootElement().focus({preventScroll:!0}),(f=h.isEmpty)!=null&&f.call(h)){if(U.$getRoot().getLastChild().is(h)){const p=U.$createParagraphNode();U.$getRoot().append(p),p.select()}else n.dispatchCommand(U.KEY_ARROW_DOWN_COMMAND);h.remove()}else eE(n,r);a(!1)}else a(!0);return!0}if(!l._fromNested&&document.activeElement!==n.getRootElement())return!1;if(!i&&r){l.preventDefault();const h=U.$getNodeByKey(r),p=U.$createParagraphNode();return h.getTopLevelElementOrThrow().insertAfter(p),p.select(),!0}},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_UP_COMMAND,l=>{if(l.shiftKey)return!1;if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(U.$isNodeSelection(u)){const h=u.getNodes()[0].getPreviousSibling();return!h&&t?(u.clear(),t(),!0):U.$isDecoratorNode(h)?(lo(h),!0):(l.preventDefault(),h.selectEnd(),!0)}if(U.$isRangeSelection(u)&&u.isCollapsed){const f=u.anchor.getNode().getTopLevelElement(),h=window.getSelection();if(t&&Y4(u))return t(),!0;const p=(f==null?void 0:f.getTextContent().trim())===""&&u.anchor.offset===0,v=u.anchor.offset===0&&u.focus.offset===0;if(p||v){const w=f.getPreviousSibling();if(U.$isDecoratorNode(w))return lo(w),!0}else{const O=h.getRangeAt(0).cloneRange().getClientRects();if(O.length>0){const _=O[1]||O[0],T=OI(h.anchorNode).getBoundingClientRect();if(Math.abs(_.top-T.top)<=xI){const D=f.getPreviousSibling();if(U.$isDecoratorNode(D))return lo(D),!0}}}}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_DOWN_COMMAND,l=>{if(l!=null&&l.shiftKey)return!1;if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(U.$isNodeSelection(u)){const f=u.getNodes()[0],h=f.getNextSibling();if(!h){const p=U.$createParagraphNode();return f.insertAfter(p),p.select(),!0}return U.$isDecoratorNode(h)?(lo(h),!0):(l==null||l.preventDefault(),h.selectStart(),!0)}if(U.$isRangeSelection(u)&&u.isCollapsed){const f=u.anchor.getNode().getTopLevelElement(),h=window.getSelection(),p=OI(h.anchorNode),v=(f==null?void 0:f.getTextContent().trim())===""&&u.anchor.offset===0,w=h.rangeCount!==0&&h.anchorNode===p&&h.anchorOffset===p.children.length-1&&h.focusOffset===p.children.length-1;if(v||w){const O=f.getNextSibling();if(U.$isDecoratorNode(O))return lo(O),!0}else{const _=h.getRangeAt(0).cloneRange().getClientRects();if(_.length>0){const E=_[0],T=p.getBoundingClientRect();if(Math.abs(E.bottom-T.bottom)<xI){const A=f.getNextSibling();if(U.$isDecoratorNode(A))return lo(A),!0}}}}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_LEFT_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(t){if(U.$isNodeSelection(u)&&!u.getNodes()[0].getPreviousSibling())return l.preventDefault(),u.clear(),t==null||t(),!0;if(u.isCollapsed&&Y4(u))return l.preventDefault(),t(),!0}if(!U.$isNodeSelection(u))return!1;const p=u.getNodes()[0].getTopLevelElement().getPreviousSibling();return U.$isDecoratorNode(p)?(l.preventDefault(),lo(p),!0):!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ARROW_RIGHT_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;const u=U.$getSelection();if(!U.$isNodeSelection(u))return!1;const f=u.getNodes(),v=f[f.length-1].getTopLevelElement().getNextSibling();return U.$isDecoratorNode(v)?(l.preventDefault(),lo(v),!0):!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_MODIFIER_COMMAND,l=>{const u=l.key==="ArrowUp"||l.keyCode===38,f=l.key==="ArrowDown"||l.keyCode===40;if(l.metaKey&&(u||f)){const h=U.$getSelection(),p=U.$isNodeSelection(h),v=U.$isDecoratorNode(U.$getRoot().getFirstChild()),w=U.$isDecoratorNode(U.$getRoot().getLastChild());if(p||v||w){if(f){l.preventDefault();const O=U.$getRoot().getLastChild();return U.$isDecoratorNode(O)?(lo(O),!0):(O.selectEnd(),!0)}if(u){l.preventDefault();const O=U.$getRoot().getFirstChild();return U.$isDecoratorNode(O)?(lo(O),!0):(O.selectStart(),!0)}}}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_BACKSPACE_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;if(!i&&r)return l.preventDefault(),n.dispatchCommand(Kg,{cardKey:r,direction:"backward"}),!0;const u=U.$getSelection();if(U.$isRangeSelection(u)&&u.isCollapsed){const h=u.anchor.getNode(),p=h.getTopLevelElement(),v=p.getPreviousSibling(),w=u.anchor.offset===0&&u.focus.offset===0;if(w&&jo.$isListItemNode(h)&&h.getIndent()===0&&h.isEmpty())return l.preventDefault(),n.dispatchCommand(U.INSERT_PARAGRAPH_COMMAND),!0;if(U.$isParagraphNode(h)&&h.isEmpty()&&U.$isDecoratorNode(v))return p.remove(),lo(v),!0;if(w&&jo.$isListItemNode(h.getParent())){const O=h.getParent();if(O.getIndent()===0){l.preventDefault();const _=U.$createParagraphNode();return _.append(...O.getChildren()),O.replace(_),!0}}if(w&&U.$isDecoratorNode(v))return l.preventDefault(),v.remove(),!0}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_DELETE_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;if(r)return l.preventDefault(),n.dispatchCommand(Kg,{cardKey:r,direction:"forward"}),!0;const u=U.$getSelection();if(U.$isRangeSelection(u)&&u.isCollapsed){const f=u.anchor,h=f.getNode(),p=h.getTopLevelElement(),v=p.getNextSibling();if((p==null?void 0:p.getTextContent().trim())===""&&u.anchor.offset===0&&U.$isDecoratorNode(v))return l.preventDefault(),p.remove(),lo(v),!0;if((f.type==="element"&&U.$isElementNode(h)&&f.offset===h.getChildrenSize()||f.type==="text"&&f.offset===h.getTextContentSize())&&U.$isDecoratorNode(v))return l.preventDefault(),v.remove(),!0}return!1},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_TAB_COMMAND,l=>{if(document.activeElement!==n.getRootElement())return!0;if(l.shiftKey&&t){const u=U.$getSelection();if(U.$isNodeSelection(u))return l.preventDefault(),u.clear(),t(),!0;let f;if(u.isCollapsed){const p=u.anchor.getNode();f=U.$isTextNode(p)?[p.getParent()]:[p]}else f=u.getNodes();return f.some(p=>p.getIndent&&p.getIndent()>0)?!1:(l.preventDefault(),t(),!0)}},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.KEY_ESCAPE_COMMAND,l=>{l.preventDefault(),r&&s&&(n._parentEditor||n).dispatchCommand(S0,{cardKey:r})},U.COMMAND_PRIORITY_LOW),n.registerCommand(U.PASTE_COMMAND,l=>{var v;if(document.activeElement!==n.getRootElement()&&!i)return!1;const u=(v=l==null?void 0:l.clipboardData)==null?void 0:v.getData("text"),f=u==null?void 0:u.match(/^(https?:\/\/[^\s]+)$/),h=U.$getSelection(),p=h.getTextContent();if(f&&p.length>0){const w=f[1];if(U.$isRangeSelection(h)){const O=h.extract()[0],_=Vs.$createLinkNode(w),E=U.$createTextNode(p);E.setFormat(O.getFormat()),_.append(E),O.replace(_)}return!0}if(f&&!p.length>0){const w=f[1],O=fI({url:w});return n.dispatchCommand(Sr,{cardNode:O,createdWithUrl:!0}),!0}},U.COMMAND_PRIORITY_LOW))),B.useEffect(()=>{if(n.hasNodes([jo.ListNode]))return Ut.mergeRegister(n.registerNodeTransform(jo.ListNode,l=>{const u=l.getNextSibling();jo.$isListNode(u)&&u.getListType()===l.getListType()&&(l.append(...u.getChildren()),u.remove())}))},[n]),null}function SI({containerElem:n=document.querySelector(".koenig-editor"),cursorDidExitAtTop:e,isNested:t}){const[i]=Ye.useLexicalComposerContext();return cfe({editor:i,containerElem:n,cursorDidExitAtTop:e,isNested:t})}const Yi=({nodeKey:n,width:e,wrapperStyle:t,IndicatorIcon:i,children:r})=>{const[o]=Ye.useLexicalComposerContext(),[s,a]=B.useState(null),[l,u]=B.useState(null),[f,h]=B.useState(e||"regular"),p=B.useRef(null),{selectedCardKey:v,isEditingCard:w,isDragging:O}=Nd(),_=v===n,E=_&&w;B.useLayoutEffect(()=>{o.getEditorState().read(()=>{const A=U.$getNodeByKey(n);a(A.getType())})},[]),B.useEffect(()=>Ut.mergeRegister(o.registerCommand(U.CLICK_COMMAND,A=>{var D;if(p.current.contains(A.target)){const M=U.$getNodeByKey(n);return M?(_&&((D=M.hasEditMode)!=null&&D.call(M))&&!E?o.dispatchCommand(El,{cardKey:n}):_||o.dispatchCommand(S0,{cardKey:n}),!0):void 0}return!1},U.COMMAND_PRIORITY_LOW)));const T=A=>{A?o.dispatchCommand(El,{cardKey:n}):_||o.dispatchCommand(S0,{cardKey:n})};return C(or.Provider,{value:{isSelected:_,captionHasFocus:l,isEditing:E,cardWidth:f,setCardWidth:h,setCaptionHasFocus:u,setEditing:T,nodeKey:n,cardContainerRef:p},children:C(jb,{ref:p,cardType:s,cardWidth:f,IndicatorIcon:i,isDragging:O,isEditing:E,isSelected:_,wrapperStyle:t,children:r})})};var Tl={},ew=x0,tw=Ho,Jg=Ut,we=U;function CI(n,e){return typeof document.caretRangeFromPoint<"u"?(n=document.caretRangeFromPoint(n,e),n===null?null:{node:n.startContainer,offset:n.startOffset}):document.caretPositionFromPoint!=="undefined"?(n=document.caretPositionFromPoint(n,e),n===null?null:{node:n.offsetNode,offset:n.offset}):null}let ep=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ufe=ep&&"documentMode"in document?document.documentMode:null,ffe=ep&&"InputEvent"in window&&!ufe?"getTargetRanges"in new window.InputEvent("input"):!1,dfe=ep&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),hfe=ep&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,gfe=ep&&/^(?=.*Chrome).*/i.test(navigator.userAgent),pfe=ep&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!gfe,tE=we.createCommand("DRAG_DROP_PASTE_FILE"),nE=class bK extends we.ElementNode{static getType(){return"quote"}static clone(e){return new bK(e.__key)}constructor(e){super(e)}createDOM(e){let t=document.createElement("blockquote");return Jg.addClassNamesToElement(t,e.theme.quote),t}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:mfe,priority:0})}}static importJSON(e){let t=iE();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){e=we.$createParagraphNode();let i=this.getDirection();return e.setDirection(i),this.insertAfter(e,t),e}collapseAtStart(){let e=we.$createParagraphNode();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}};function iE(){return we.$applyNodeReplacement(new nE)}let rE=class kK extends we.ElementNode{static getType(){return"heading"}static clone(e){return new kK(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){let t=this.__tag,i=document.createElement(t);return e=e.theme.heading,e!==void 0&&Jg.addClassNamesToElement(i,e[t]),i}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:tp,priority:0}),h2:()=>({conversion:tp,priority:0}),h3:()=>({conversion:tp,priority:0}),h4:()=>({conversion:tp,priority:0}),h5:()=>({conversion:tp,priority:0}),h6:()=>({conversion:tp,priority:0}),p:e=>(e=e.firstChild,e!==null&&EI(e)?{conversion:()=>({node:null}),priority:3}:null),span:e=>EI(e)?{conversion:()=>({node:np("h1")}),priority:3}:null}}static importJSON(e){let t=np(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){e=e?e.anchor.offset:0,e=0<e&&e<this.getTextContentSize()?np(this.getTag()):we.$createParagraphNode();let i=this.getDirection();return e.setDirection(i),this.insertAfter(e,t),e}collapseAtStart(){let e=this.isEmpty()?we.$createParagraphNode():np(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}};function EI(n){return n.nodeName.toLowerCase()==="span"?n.style.fontSize==="26pt":!1}function tp(n){n=n.nodeName.toLowerCase();let e=null;return(n==="h1"||n==="h2"||n==="h3"||n==="h4"||n==="h5"||n==="h6")&&(e=np(n)),{node:e}}function mfe(){return{node:iE()}}function np(n){return we.$applyNodeReplacement(new rE(n))}function vfe(n,e){n.preventDefault(),e.update(()=>{let t=we.$getSelection(),i=n instanceof InputEvent||n instanceof KeyboardEvent?null:n.clipboardData;i!=null&&(we.$isRangeSelection(t)||we.DEPRECATED_$isGridSelection(t))&&ew.$insertDataTransferForRichText(i,t,e)},{tag:"paste"})}async function yfe(n,e){await ew.copyToClipboard(e,n instanceof ClipboardEvent?n:null),e.update(()=>{let t=we.$getSelection();we.$isRangeSelection(t)?t.removeText():we.$isNodeSelection(t)&&t.getNodes().forEach(i=>i.remove())})}function E0(n){let e=null;if(n instanceof DragEvent?e=n.dataTransfer:n instanceof ClipboardEvent&&(e=n.clipboardData),e===null)return[!1,[],!1];var t=e.types;return n=t.includes("Files"),t=t.includes("text/html")||t.includes("text/plain"),[n,Array.from(e.files),t]}function TI(n,e){var t=we.$getSelection();if(we.$isRangeSelection(t)){var i=new Set;t=t.getNodes();for(let r=0;r<t.length;r++){let o=t[r],s=o.getKey();if(i.has(s))continue;let a=Jg.$getNearestBlockElementAncestorOrThrow(o),l=a.getKey();a.canInsertTab()?(n(o),i.add(s)):a.canIndent()&&!i.has(l)&&(i.add(l),e(a))}}}function nw(n){return n=we.$getNearestNodeFromDOMNode(n),we.$isDecoratorNode(n)}Tl.$createHeadingNode=np,Tl.$createQuoteNode=iE,Tl.$isHeadingNode=function(n){return n instanceof rE},Tl.$isQuoteNode=function(n){return n instanceof nE},Tl.DRAG_DROP_PASTE=tE,Tl.HeadingNode=rE,Tl.QuoteNode=nE,Tl.eventFiles=E0,Tl.registerRichText=function(n){return Jg.mergeRegister(n.registerCommand(we.CLICK_COMMAND,()=>{const e=we.$getSelection();return we.$isNodeSelection(e)?(e.clear(),!0):!1},0),n.registerCommand(we.DELETE_CHARACTER_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.deleteCharacter(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DELETE_WORD_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.deleteWord(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DELETE_LINE_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.deleteLine(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.CONTROLLED_TEXT_INSERTION_COMMAND,e=>{const t=we.$getSelection();if(typeof e=="string")we.$isRangeSelection(t)?t.insertText(e):we.DEPRECATED_$isGridSelection(t);else{if(!we.$isRangeSelection(t)&&!we.DEPRECATED_$isGridSelection(t))return!1;const i=e.dataTransfer;i!=null?ew.$insertDataTransferForRichText(i,t,n):we.$isRangeSelection(t)&&(e=e.data)&&t.insertText(e)}return!0},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.REMOVE_TEXT_COMMAND,()=>{const e=we.$getSelection();return we.$isRangeSelection(e)?(e.removeText(),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.FORMAT_TEXT_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.formatText(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.FORMAT_ELEMENT_COMMAND,e=>{var t=we.$getSelection();if(!we.$isRangeSelection(t)&&!we.$isNodeSelection(t))return!1;t=t.getNodes();for(const i of t)Jg.$getNearestBlockElementAncestorOrThrow(i).setFormat(e);return!0},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.INSERT_LINE_BREAK_COMMAND,e=>{const t=we.$getSelection();return we.$isRangeSelection(t)?(t.insertLineBreak(e),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.INSERT_PARAGRAPH_COMMAND,()=>{const e=we.$getSelection();return we.$isRangeSelection(e)?(e.insertParagraph(),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.INDENT_CONTENT_COMMAND,()=>(TI(()=>{n.dispatchCommand(we.CONTROLLED_TEXT_INSERTION_COMMAND," ")},e=>{const t=e.getIndent();t!==10&&e.setIndent(t+1)}),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.OUTDENT_CONTENT_COMMAND,()=>(TI(e=>{we.$isTextNode(e)&&(e=e.getTextContent(),e[e.length-1]===" "&&n.dispatchCommand(we.DELETE_CHARACTER_COMMAND,!0))},e=>{const t=e.getIndent();t!==0&&e.setIndent(t-1)}),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_UP_COMMAND,e=>{var t=we.$getSelection();if(we.$isNodeSelection(t)&&!nw(e.target)){if(e=t.getNodes(),0<e.length)return e[0].selectPrevious(),!0}else if(we.$isRangeSelection(t)){if(t=we.$getAdjacentNode(t.focus,!0),we.$isDecoratorNode(t)&&!t.isIsolated()&&!t.isInline())return t.selectPrevious(),e.preventDefault(),!0;if(we.$isElementNode(t)&&!t.isInline()&&!t.canBeEmpty())return t.select(),e.preventDefault(),!0}return!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_DOWN_COMMAND,e=>{var t=we.$getSelection();if(we.$isNodeSelection(t)){if(e=t.getNodes(),0<e.length)return e[0].selectNext(0,0),!0}else if(we.$isRangeSelection(t)){let i=t.focus;if(i.key==="root"&&i.offset===we.$getRoot().getChildrenSize())return e.preventDefault(),!0;if(t=we.$getAdjacentNode(t.focus,!1),we.$isDecoratorNode(t)&&!t.isIsolated()&&!t.isInline())return t.selectNext(),e.preventDefault(),!0}return!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_LEFT_COMMAND,e=>{const t=we.$getSelection();if(we.$isNodeSelection(t)){var i=t.getNodes();if(0<i.length)return e.preventDefault(),i[0].selectPrevious(),!0}return we.$isRangeSelection(t)&&tw.$shouldOverrideDefaultCharacterSelection(t,!0)?(i=e.shiftKey,e.preventDefault(),tw.$moveCharacter(t,i,!0),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ARROW_RIGHT_COMMAND,e=>{const t=we.$getSelection();if(we.$isNodeSelection(t)&&!nw(e.target)){var i=t.getNodes();if(0<i.length)return e.preventDefault(),i[0].selectNext(0,0),!0}return we.$isRangeSelection(t)?(i=e.shiftKey,tw.$shouldOverrideDefaultCharacterSelection(t,!1)?(e.preventDefault(),tw.$moveCharacter(t,i,!1),!0):!1):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_BACKSPACE_COMMAND,e=>{if(nw(e.target))return!1;const t=we.$getSelection();if(!we.$isRangeSelection(t))return!1;e.preventDefault(),{anchor:e}=t;const i=e.getNode();return t.isCollapsed()&&e.offset===0&&!we.$isRootNode(i)&&0<Jg.$getNearestBlockElementAncestorOrThrow(i).getIndent()?n.dispatchCommand(we.OUTDENT_CONTENT_COMMAND,void 0):n.dispatchCommand(we.DELETE_CHARACTER_COMMAND,!0)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_DELETE_COMMAND,e=>{if(nw(e.target))return!1;const t=we.$getSelection();return we.$isRangeSelection(t)?(e.preventDefault(),n.dispatchCommand(we.DELETE_CHARACTER_COMMAND,!1)):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ENTER_COMMAND,e=>{const t=we.$getSelection();if(!we.$isRangeSelection(t))return!1;if(e!==null){if((hfe||dfe||pfe)&&ffe)return!1;if(e.preventDefault(),e.shiftKey)return n.dispatchCommand(we.INSERT_LINE_BREAK_COMMAND,!1)}return n.dispatchCommand(we.INSERT_PARAGRAPH_COMMAND,void 0)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.KEY_ESCAPE_COMMAND,()=>{const e=we.$getSelection();return we.$isRangeSelection(e)?(n.blur(),!0):!1},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DROP_COMMAND,e=>{const[,t]=E0(e);if(0<t.length){var i=CI(e.clientX,e.clientY);if(i!==null){const{offset:o,node:s}=i;var r=we.$getNearestNodeFromDOMNode(s);if(r!==null){if(i=we.$createRangeSelection(),we.$isTextNode(r))i.anchor.set(r.getKey(),o,"text"),i.focus.set(r.getKey(),o,"text");else{const a=r.getParentOrThrow().getKey();r=r.getIndexWithinParent()+1,i.anchor.set(a,r,"element"),i.focus.set(a,r,"element")}i=we.$normalizeSelection__EXPERIMENTAL(i),we.$setSelection(i)}n.dispatchCommand(tE,t)}return e.preventDefault(),!0}return e=we.$getSelection(),!!we.$isRangeSelection(e)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DRAGSTART_COMMAND,e=>{[e]=E0(e);const t=we.$getSelection();return!(e&&!we.$isRangeSelection(t))},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.DRAGOVER_COMMAND,e=>{var[t]=E0(e);const i=we.$getSelection();return t&&!we.$isRangeSelection(i)?!1:(t=CI(e.clientX,e.clientY),t!==null&&(t=we.$getNearestNodeFromDOMNode(t.node),we.$isDecoratorNode(t)&&e.preventDefault()),!0)},we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.COPY_COMMAND,e=>(ew.copyToClipboard(n,e instanceof ClipboardEvent?e:null),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.CUT_COMMAND,e=>(yfe(e,n),!0),we.COMMAND_PRIORITY_EDITOR),n.registerCommand(we.PASTE_COMMAND,e=>{const[,t,i]=E0(e);if(0<t.length&&!i)return n.dispatchCommand(tE,t),!0;if(we.isSelectionCapturedInDecoratorInput(e.target))return!1;const r=we.$getSelection();return we.$isRangeSelection(r)||we.DEPRECATED_$isGridSelection(r)?(vfe(e,n),!0):!1},we.COMMAND_PRIORITY_EDITOR))};var Js=Tl;function oE(n){const e=n._nodes,t=[];for(const[i,{klass:r}]of e)r.kgMenu&&t.push([i,r]);return t}const iw=U.createCommand();function $I(n,e){const t=n.type;return Object.keys(e).find(r=>e[r].includes(t))}function bfe(n,e){const t=n[Symbol.iterator]();return new Promise((i,r)=>{const o=[],s=()=>{const{done:a,value:l}=t.next();if(a)return i({processed:o});const u=new FileReader;u.addEventListener("error",r),u.addEventListener("load",()=>{const h=u.result,p=$I(l,e);typeof h=="string"&&o.push({type:p,file:l}),s()}),$I(l,e)?u.readAsDataURL(l):(console.error("unsupported file type"),s())};s()})}async function kfe(n,e){const t=oE(n);let i={};for(const[r,o]of t)r&&o.uploadType&&(i[r]=e[o.uploadType].mimeTypes);return{acceptableMimeTypes:i}}function AI(){const[n]=Ye.useLexicalComposerContext(),{fileUploader:e}=B.useContext(bn),t=B.useCallback(async i=>{if(!e)return;const{acceptableMimeTypes:r}=await kfe(n,e.fileTypes),{processed:o}=await bfe(i,r);o.forEach(s=>{n.dispatchCommand(iw,s)})},[n,e]);return B.useEffect(()=>n.registerCommand(U.DROP_COMMAND,i=>{const r=Array.from(i.dataTransfer.files);return r.length>0?(i.preventDefault(),i.stopPropagation(),n.dispatchCommand(Js.DRAG_DROP_PASTE,r),!0):!1},U.COMMAND_PRIORITY_HIGH),[n]),B.useEffect(()=>{const i=n.getRootElement(),r=s=>{!s.dataTransfer||s.target.closest("[data-kg-card]")||(s.stopPropagation(),s.preventDefault())},o=s=>{s.preventDefault()};return i.addEventListener("dragover",r),i.addEventListener("dragleave",o),()=>{i.removeEventListener("dragover",r),i.removeEventListener("dragleave",o)}},[n]),B.useEffect(()=>n.registerCommand(Js.DRAG_DROP_PASTE,async i=>{try{return n.focus(),await t(i)}catch(r){console.error(r)}},U.COMMAND_PRIORITY_LOW),[n,t]),null}function ef({handleDrop:n,disabled:e=!1}){const[t,i]=B.useState(null),[r,o]=B.useState(!1);return B.useEffect(()=>{const s=t;if(!s||e)return;s.addEventListener("dragenter",a),s.addEventListener("dragover",l),s.addEventListener("dragleave",u),s.addEventListener("drop",f);function a(p){h(p),o(!0)}function l(p){h(p),o(!0)}function u(p){h(p),o(!1)}function f(p){h(p);const{dataTransfer:v}=p;v.files&&v.files.length>0&&n(Array.from(v.files)),o(!1)}function h(p){p.preventDefault(),p.stopPropagation()}return()=>{s.removeEventListener("dragenter",a),s.removeEventListener("dragover",l),s.removeEventListener("dragleave",u),s.removeEventListener("drop",f)}},[n,t,e]),{setRef:i,isDraggedOver:r}}function rw({onFileChange:n,fileInputRef:e,mimeTypes:t=["image/*"],multiple:i=!1,disabled:r}){const o=t.join(",");return C("form",{onChange:n,children:C("input",{ref:e,accept:o,disabled:r,hidden:!0,multiple:i,name:"image-input",type:"file"})})}const wfe=n=>re.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",...n},re.createElement("path",{d:"M11.25 17.25a6 6 0 1 0 12 0 6 6 0 1 0-12 0Zm6 3v-6m0 0L15 16.5m2.25-2.25 2.25 2.25"}),re.createElement("path",{d:"M8.25 20.25h-6a1.5 1.5 0 0 1-1.5-1.5V2.25a1.5 1.5 0 0 1 1.5-1.5h10.629a1.5 1.5 0 0 1 1.06.439l2.872 2.872a1.5 1.5 0 0 1 .439 1.06V8.25"}),re.createElement("path",{d:"M3.75 12.75a2.25 1.5 0 1 0 4.5 0 2.25 1.5 0 1 0-4.5 0Z"}),re.createElement("path",{d:"m8.25 12.75-.295-5.929 1.062-.113A2.685 2.685 0 0 1 11.6 7.99"})),NI=n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...n},re.createElement("path",{d:"M12.001 15.75v-12m4.5 4.5-4.5-4.5-4.5 4.5m15.75 7.5v1.5a3 3 0 0 1-3 3h-16.5a3 3 0 0 1-3-3v-1.5",style:{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5px"}})),_fe={image:VS,gallery:QA,video:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...n},re.createElement("g",{strokeLinecap:"round",strokeWidth:2,fill:"none",stroke:"currentColor",strokeLinejoin:"round",className:"nc-icon-wrapper"},re.createElement("rect",{x:2,y:18,width:31,height:26,rx:4}),re.createElement("circle",{cx:8.5,cy:7.5,r:5.5}),re.createElement("circle",{cx:25.5,cy:9.5,r:3.5}),re.createElement("path",{"data-cap":"butt",d:"m33 27 13-6v20l-13-6"}))),audio:wfe,file:NI,product:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...n},re.createElement("g",{strokeLinecap:"round",strokeWidth:2,fill:"none",stroke:"currentColor",strokeLinejoin:"round",className:"nc-icon-wrapper"},re.createElement("path",{d:"M4 10h40"}),re.createElement("path",{d:"M44 46H4V10l8-8h24l8 8z"}),re.createElement("path",{d:"M34 20c0 5.5-4.5 10-10 10s-10-4.5-10-10"})))},xfe=({text:n})=>C("span",{className:"font-sans text-sm font-bold text-grey-800 transition-all group-hover:text-grey-800","data-kg-card-drag-text":!0,children:n});function tf({desc:n,icon:e,filePicker:t,size:i,borderStyle:r,isDraggedOver:o,errors:s=[],placeholderRef:a,dataTestId:l="media-placeholder",errorDataTestId:u="media-placeholder-errors",multiple:f=!1,...h}){const p=_fe[e];return C("div",{ref:a,className:"h-full border border-transparent",...h,"data-testid":l,children:C("div",{className:`relative flex h-full items-center justify-center border bg-grey-50 dark:bg-grey-950 ${i==="xsmall"?"before:pb-[12.5%]":"before:pb-[62.5%]"} ${r==="dashed"?"rounded border-dashed border-grey/40":"border-grey/20 dark:border-grey/10"}`,children:o?C(xfe,{text:`Drop ${f?"'em":"it"} like it's hot 🔥`}):C(yt,{children:fe("button",{className:`group flex cursor-pointer select-none items-center justify-center ${i==="xsmall"?"p-4":"flex-col p-20"}`,name:"placeholder-button",type:"button",onClick:t,children:[i==="xsmall"&&s.length>0||fe(yt,{children:[C(p,{className:`shrink-0 opacity-80 transition-all ease-linear hover:scale-105 group-hover:opacity-100 ${i==="large"?"h-20 w-20 text-grey":i==="small"?"h-14 w-14 text-grey":i==="xsmall"?"h-6 w-6 text-grey-700":"h-16 w-16 text-grey"} ${i==="xsmall"&&n?"mr-3":""}`}),C("p",{className:`min-w-[auto] font-sans text-sm font-normal text-grey opacity-80 transition-all group-hover:opacity-100 ${i==="xsmall"?"mt-0":"mt-4"}`,children:n})]}),s.map(v=>C("span",{className:`font-sans text-sm font-semibold text-red ${i==="xsmall"||"mt-3 max-w-[65%]"}`,"data-testid":u,children:v.message},v.message))]})})})})}tf.propTypes={icon:me.string,desc:me.string,size:me.oneOf(["xsmall","small","medium","large"]),borderStyle:me.oneOf(["solid","dashed"])};function Ia({style:n,fullWidth:e,bgStyle:t}){return C("div",{className:`rounded-full bg-grey-200 dark:bg-black ${e?"w-full":"mx-auto w-3/5"} ${t==="transparent"?"bg-white/30":"bg-grey-200"}`,"data-testid":"progress-bar",children:C("div",{className:"rounded-full bg-green py-1 text-center text-xs leading-none text-white",style:n})})}Ia.propTypes={style:me.object,fullWidth:me.bool};function Br({fileInputRef:n}){n.current.click()}function Ofe({src:n,alt:e,previewSrc:t,imageUploader:i}){var s;const r={width:`${(s=i.progress)==null?void 0:s.toFixed(0)}%`},o=i.progress.toFixed(0)<100?`upload in progress, ${i.progress}`:"";return fe("div",{children:[C("img",{alt:e||o,className:`mx-auto block ${t?"opacity-40":""}`,"data-testid":i.isLoading?"image-card-loading":"image-card-populated",src:t||n}),i.isLoading?C("div",{className:"absolute inset-0 flex min-w-full items-center justify-center overflow-hidden bg-white/50","data-testid":"upload-progress",children:C(Ia,{style:r})}):C(yt,{})]})}function Sfe({onFileChange:n,setFileInputRef:e,imageDragHandler:t,errors:i}){const r=B.useRef(null),o=s=>{r.current=s,e(r)};return fe(yt,{children:[C(tf,{desc:"Click to select an image",errors:i,filePicker:()=>Br({fileInputRef:r}),icon:"image",isDraggedOver:t.isDraggedOver,placeholderRef:t.setRef}),C(rw,{fileInputRef:o,filePicker:()=>Br({fileInputRef:r}),onFileChange:n})]})}const PI=({src:n,altText:e,previewSrc:t,imageUploader:i,onFileChange:r,setFileInputRef:o,imageDragHandler:s})=>t||n?C(Ofe,{alt:e,imageUploader:i,previewSrc:t,src:n}):C(Sfe,{errors:i.errors,imageDragHandler:s,setFileInputRef:o,onFileChange:r});function DI({isSelected:n,src:e,onFileChange:t,captionEditor:i,captionEditorInitialState:r,altText:o,setAltText:s,setFigureRef:a,fileInputRef:l,cardWidth:u,previewSrc:f,imageUploader:h,imageDragHandler:p}){const v=B.useRef(null);return B.useEffect(()=>{a&&a(v)},[v,a]),C(yt,{children:fe("figure",{ref:v,"data-kg-card-width":u,children:[C(PI,{altText:o,imageDragHandler:p,imageUploader:h,previewSrc:f,setFileInputRef:O=>{l&&(l.current=O.current)},src:e,onFileChange:t}),C(Gg,{altText:o||"",altTextPlaceholder:"Type alt text for image (optional)",captionEditor:i,captionEditorInitialState:r,captionPlaceholder:"Type caption for image (optional)",dataTestId:"image-caption-editor",isSelected:n,readOnly:!n,setAltText:s})]})})}PI.propTypes={src:me.string,altText:me.string,previewSrc:me.string,imageUploader:me.object,onFileChange:me.func,setFileInputRef:me.func,imageDragHandler:me.object},DI.propTypes={isSelected:me.bool,src:me.string,onFileChange:me.func,captionEditor:me.object,captionEditorInitialState:me.string,altText:me.string,setAltText:me.func,setFigureRef:me.func,fileInputRef:me.object,cardWidth:me.string,previewSrc:me.string,imageUploader:me.object,imageDragHandler:me.object};function sE({href:n,update:e,cancel:t}){const[i,r]=B.useState(n),o=B.useRef(null),s=B.useRef(null);B.useEffect(()=>{r(n)},[n]),B.useEffect(()=>{o.current.focus()},[]);const a=B.useCallback(u=>{s.current&&!s.current.contains(u.target)&&t()},[t]);B.useEffect(()=>(window.addEventListener("mousedown",a),()=>{window.removeEventListener("mousedown",a)}),[a]);const l=B.useCallback(u=>{u.key==="Escape"&&t()},[t]);return B.useEffect(()=>(window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l)}),[l]),fe("div",{ref:s,className:"relative m-0 flex h-[36px] min-w-[240px] items-center justify-evenly rounded bg-black py-0 font-sans text-md font-medium after:absolute after:top-[36px] after:left-[calc(50%-8px)] after:w-0 after:border-x-8 after:border-t-8 after:border-x-transparent after:border-t-black",children:[C("input",{ref:o,className:"mb-[1px] h-auto w-full rounded bg-black pl-3 pr-9 leading-loose text-white selection:bg-grey/40","data-testid":"link-input",placeholder:"Enter url",value:i,onInput:u=>{r(u.target.value)},onKeyDown:u=>{if(u.key==="Enter"){u.preventDefault(),e(i);return}}}),!!i&&C("button",{"aria-label":"Close",className:"absolute right-3 cursor-pointer",type:"button",onClick:u=>{u.stopPropagation(),r(""),o.current.focus()},children:C(w0,{className:"h-3 w-3 stroke-2 text-grey"})})]})}sE.propTypes={href:me.string};async function MI(n){const e=new Image;return e.src=n,new Promise((t,i)=>{e.onload=()=>{t({width:e.naturalWidth,height:e.naturalHeight})},e.onerror=i})}const ow=async(n,e,t,i)=>{if(!n)return;let r=URL.createObjectURL(n[0]);r&&await t.update(()=>{U.$getNodeByKey(e).setPreviewSrc(r)});const{width:o,height:s}=await MI(r),a=await i(n),l=a==null?void 0:a[0].url;await t.update(()=>{const u=U.$getNodeByKey(e);u.setImgWidth(o),u.setImgHeight(s),u.setSrc(l),u.setPreviewSrc(null)})},Cfe=async(n,e)=>{if(!n)return;const t=await e(n);return{imageSrc:t==null?void 0:t[0].url}};function T0(n){return/\.(gif)$/.test(n)}function Efe({nodeKey:n,initialFile:e,src:t,altText:i,captionEditor:r,captionEditorInitialState:o,triggerFileDialog:s,previewSrc:a,href:l}){var q;const[u]=Ye.useLexicalComposerContext(),[f,h]=B.useState(!1),{fileUploader:p,cardConfig:v}=B.useContext(bn),{isSelected:w,cardWidth:O,setCardWidth:_}=B.useContext(or),E=B.useRef(),T=B.useRef(),[A,D]=B.useState(!1),M=p.useFileUpload("image"),I=ef({handleDrop:Z});B.useEffect(()=>{(async J=>{J&&!t&&await ow([J],n,u,M.upload)})(e)},[]);const z=async W=>{const J=W.target.files;return u.update(()=>{U.$getNodeByKey(n).setSrc("")}),await ow(J,n,u,M.upload)},V=W=>{u.update(()=>{U.$getNodeByKey(n).setHref(W)})},K=W=>{u.update(()=>{U.$getNodeByKey(n).setAltText(W)})};B.useEffect(()=>{if(!s)return;const W=setTimeout(()=>{Br({fileInputRef:E}),u.update(()=>{U.$getNodeByKey(n).setTriggerFileDialog(!1)})});return()=>{clearTimeout(W)}});const X=W=>{u.update(()=>{U.$getNodeByKey(n).setCardWidth(W),_(W)})},te=()=>{h(!1),se()},se=()=>{u.update(()=>{const W=U.$createNodeSelection();W.add(n),U.$setSelection(W)})};async function Z(W){await ow(W,n,u,M.upload)}return fe(yt,{children:[C(DI,{altText:i,captionEditor:r,captionEditorInitialState:o,cardWidth:O,fileInputRef:E,imageDragHandler:I,imageUploader:M,isSelected:w,previewSrc:a,setAltText:K,src:t,onFileChange:z}),C(pn,{"data-kg-card-toolbar":"image",isVisible:f,children:C(sE,{cancel:te,href:l,update:W=>{V(W),te()}})}),C(pn,{"data-kg-card-toolbar":"image",isVisible:A,children:C(Rr,{onClose:()=>D(!1)})}),fe(pn,{"data-kg-card-toolbar":"image",isVisible:t&&w&&!f&&!A,children:[C(rw,{fileInputRef:T,mimeTypes:(q=p.fileTypes.image)==null?void 0:q.mimeTypes,onFileChange:z}),fe(Fr,{children:[C(qt,{hide:T0(t),icon:"imageRegular",isActive:O==="regular",label:"Regular",onClick:()=>X("regular")}),C(qt,{hide:T0(t),icon:"imageWide",isActive:O==="wide",label:"Wide",onClick:()=>X("wide")}),C(qt,{hide:T0(t),icon:"imageFull",isActive:O==="full",label:"Full",onClick:()=>X("full")}),C(Qr,{hide:T0(t)}),C(qt,{icon:"link",isActive:l===!0||!1,label:"Link",onClick:()=>{h(!0)}}),C(qt,{hide:T0(t),icon:"imageReplace",isActive:!1,label:"Replace",onClick:()=>Br({fileInputRef:T})}),C(Qr,{hide:!v.createSnippet}),C(qt,{dataTestId:"create-snippet",hide:!v.createSnippet,icon:"snippet",isActive:!1,label:"Snippet",onClick:()=>D(!0)})]})]})]})}const Tfe="https://tenor.googleapis.com",$fe="v2",Afe=600,sw={COMMON:"common",INVALID_API_KEY:"invalid_key"};function Nfe({config:n}){const[e,t]=B.useState([]),[i,r]=B.useState(null),[o,s]=B.useState(!1),[a,l]=B.useState(!1),[u,f]=B.useState([]),h=B.useRef(null),p=B.useRef(""),v=B.useRef([]),w=B.useRef(null),O=B.useRef(""),_=B.useRef(4),E=B.useRef([]),T=B.useRef([]);function A(ce){return O.current=ce,z(),ce?M(ce):I()}const D=qd.debounce((ce="")=>A(ce),Afe);async function M(ce){p.current="search",await se(p.current,{params:{q:ce,media_filter:"minimal"}})}async function I(){p.current="featured",await se(p.current,{params:{q:"excited",media_filter:"minimal"}})}function z(){T.current=[],h.current=null,V()}function V(){let ce=[],be=[];for(let oe=0;oe<_.current;oe+=1)ce[oe]=[],be[oe]=0;E.current=ce,v.current=be,T.current.length&&K()}function K(){T.current.forEach(ce=>{X(ce)})}function X(ce){const be=Math.min(...v.current),oe=v.current.indexOf(be);v.current[oe]+=300*ce.ratio,E.current[oe].push(ce),ce.columnIndex=oe,ce.columnRowIndex=E.current[oe].length-1}function te(ce,be){const[oe,F]=ce.media_formats.tinygif.dims;ce.ratio=F/oe,T.current.push(ce),ce.index=be,X(ce)}async function se(ce,be){const oe=`${$fe}/${ce}`.replace(/\/+/,"/"),F=new URL(oe,Tfe),L=new URLSearchParams(be.params);return L.set("key",n.googleApiKey),L.set("client_key","ghost-editor"),L.set("contentfilter",ne()),F.search=L.toString(),w.current=arguments,r(null),s(!0),fetch(F).then(he=>Z(he)).then(he=>he.json()).then(he=>q(he)).then(he=>W(he)).then(()=>{t(E.current),f(T.current)}).catch(he=>{!be.ignoreErrors&&!i&&r(sw.COMMON),i&&i.startsWith("API key not valid")&&r(sw.INVALID_API_KEY),console.error(he)}).finally(()=>{s(!1),l(!1)})}async function Z(ce){if(ce.status>=200&&ce.status<300)return ce;let be;ce.headers.map["content-type"].startsWith("application/json")?be=await ce.json().then(F=>F.error.message||F.error):ce.headers.map["content-type"]==="text/xml"&&(be=await ce.text()),r(be);const oe=new Error(be);throw oe.response=ce,oe}async function q(ce){return h.current=ce.next,ce}async function W(ce){return ce.results.forEach((oe,F)=>te(oe,F)),ce}function J(){if(!o){if(!T.current.length)return I();if(h.current!==null){const ce={pos:h.current,media_filter:"minimal"};return p.current==="search"&&(ce.q=O),l(!0),se(p.current,{params:ce})}}}function ne(){return n.contentFilter||"off"}function G(ce){_.current=ce,V(),t(E.current)}return{updateSearch:D,isLoading:o,isLazyLoading:a,error:i,loadNextPage:J,columns:e,changeColumnCount:G,gifs:u}}function Pfe({error:n}){return n===sw.COMMON?C("p",{children:"Uh-oh! Trouble reaching the Tenor API, please check your connection"}):n===sw.INVALID_API_KEY?fe("p",{children:["This version of the Tenor API is no longer supported. Please update your API key by following our",C("a",{href:"https://ghost.org/docs/config/#tenor",rel:"noopener noreferrer",target:"_blank",children:" documentation here"}),"."]}):C("p",{children:n})}function Dfe({gif:n,onClick:e,highlightedGif:t={}}){const i=B.useRef(null),r=n.media_formats.tinygif;B.useEffect(()=>{var a,l;t.id===n.id?(a=i.current)==null||a.focus():(l=i.current)==null||l.blur()},[n.id,t.id]);const o=()=>{e(n)};return C("button",{ref:i,className:"cursor-pointer border-2 border-transparent focus:border-green-600","data-tenor-index":n.index,type:"button",onClick:o,children:C("img",{alt:r.content_description,height:r.dims[1],src:r.url,width:r.dims[0]})})}function Mfe({isLazyLoading:n}){return n?C("div",{className:"inset-y-0 w-full p-6 text-center",children:C("div",{className:"inline-block h-[50px] w-[50px] animate-spin rounded-full border border-black/10 before:z-10 before:mt-[7px] before:block before:h-[7px] before:w-[7px] before:rounded-full before:bg-grey-800"})}):C("div",{className:"absolute inset-y-0 left-0 flex w-full items-center justify-center overflow-hidden",children:C("div",{className:"relative inline-block h-[50px] w-[50px] animate-spin rounded-full border border-black/10 before:z-10 before:mt-[7px] before:block before:h-[7px] before:w-[7px] before:rounded-full before:bg-grey-800"})})}const LI=n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",strokeWidth:1.5,viewBox:"0 0 24 24",...n},re.createElement("title",null,"kg-search"),re.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M1.472 13.357a9.063 9.063 0 1 0 16.682-7.09 9.063 9.063 0 1 0-16.682 7.09Zm14.749 2.863 7.029 7.03"})),Lfe=540,Ife=940,Rfe=({onGifInsert:n,onClickOutside:e,updateSearch:t,columns:i,isLoading:r,isLazyLoading:o,error:s,changeColumnCount:a,loadNextPage:l,gifs:u})=>{const f=B.useRef(null),h=B.useRef(null),[p,v]=B.useState(void 0);B.useEffect(()=>{t()},[]),B.useEffect(()=>{if(!f.current)return;const G=new ResizeObserver(ce=>{const[be]=ce,F=(Array.isArray(be.contentBoxSize)?be.contentBoxSize[0]:be.contentBoxSize).inlineSize;let L=4;F<=Lfe?L=2:F<=Ife&&(L=3),a(L)});return G.observe(f.current),()=>{G==null||G.disconnect()}},[]),B.useEffect(()=>(document.addEventListener("keydown",X),()=>{document.removeEventListener("keydown",X)}),[X]),B.useEffect(()=>{const G=ce=>{f.current&&!f.current.contains(ce.target)&&e()};return window.addEventListener("mousedown",G),()=>{window.removeEventListener("mousedown",G)}},[e]);function w(G){const ce=G.media_formats.gif,be={src:ce.url,width:ce.dims[0],height:ce.dims[1]};n(be)}const O=G=>{t(G.target.value)},_=G=>{const ce=G.target;ce.scrollTop+ce.clientHeight>=ce.scrollHeight-1e3&&l()};function E(){var G;(G=h.current)==null||G.focus()}function T(){v(u[0])}function A(){p!==u[u.length-1]&&v(u[p.index+1])}function D(){p.index===0&&E(),v(u[p.index-1])}function M(){const G=i[p.columnIndex][p.columnRowIndex+1];G&&v(G)}function I(){const G=i[p.columnIndex][p.columnRowIndex-1];G?v(G):E()}function z(G){var De;const be=document.querySelector(`[data-tenor-index="${p.index}"]`).getBoundingClientRect();let oe;G==="left"?oe=be.left-be.width/2:oe=be.right+be.width/2;let F=be.top+be.height/3,L,he=0;for(;!L;){let $e=(De=document.elementFromPoint(oe,F))==null?void 0:De.closest("[data-tenor-index]");if(($e==null?void 0:$e.dataset.tenorIndex)!==void 0){L=$e;break}if(he+=1,F-=5,he>10)break}L&&v(u[L.dataset.tenorIndex])}function V(){p.columnIndex!==i.length-1&&z("right")}function K(){if(p.index===0)return E();p.columnIndex!==0&&z("left")}function X(G){switch(G.key){case"Tab":return te(G);case"ArrowLeft":return se(G);case"ArrowRight":return Z(G);case"ArrowUp":return q(G);case"ArrowDown":return W(G);case"Enter":return J(G);default:return null}}function te(G){if(G.shiftKey){if(p)return G.preventDefault(),D()}else{if((G==null?void 0:G.target.tagName)==="INPUT")return G.preventDefault(),G.target.blur(),T();if(p)return G==null||G.preventDefault(),A()}}function se(G){p&&(G.preventDefault(),K())}function Z(G){p&&(G.preventDefault(),V())}function q(G){p&&(G.preventDefault(),I())}function W(G){if(G.target.tagName==="INPUT")return G.preventDefault(),G.target.blur(),T();p&&(G.preventDefault(),M())}function J(G){if(G.preventDefault(),G.target.tagName==="INPUT")return G.target.blur(),T();if(p)return w(p)}return fe("div",{ref:f,className:"flex h-[540px] flex-col rounded border border-grey-200 bg-grey-50 dark:border-none dark:bg-grey-900","data-testid":"tenor-selector",onClick:G=>G.stopPropagation(),children:[C("header",{className:"p-6",children:fe("div",{className:"relative w-full",children:[C(LI,{className:"absolute top-1/2 left-4 h-4 w-4 -translate-y-2 text-grey-500 dark:text-grey-800"}),C("input",{ref:h,className:"h-10 w-full rounded-full border border-grey-300 pr-8 pl-10 font-sans text-md font-normal text-black focus:border-green focus:shadow-insetgreen dark:border-grey-800 dark:bg-grey-950 dark:text-white dark:placeholder:text-grey-800 dark:focus:border-green",placeholder:"Search Tenor for GIFs",autoFocus:!0,onChange:O})]})}),C("div",{className:"relative h-full overflow-hidden",children:fe("div",{className:"h-full overflow-auto px-6",onScroll:_,children:[!s&&!(r&&!o)&&C("div",{className:"flex gap-4",children:i.map((G,ce)=>C("section",{className:"flex grow basis-0 flex-col justify-start gap-4",children:G.map(be=>C(Dfe,{gif:be,highlightedGif:p,onClick:w},be.id))},ce))}),!!r&&!s&&C(Mfe,{isLazyLoading:o}),!!s&&C("div",{"data-testid":"tenor-selector-error",children:C(Pfe,{error:s})})]})})]})},Ffe=({nodeKey:n})=>{const{cardConfig:e}=B.useContext(bn),t=Nfe({config:e.tenor}),[i]=Ye.useLexicalComposerContext();return B.useEffect(()=>{const s=a=>{a.key==="Escape"&&i.dispatchCommand(Kg,{cardKey:n})};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]),C(Rfe,{onClickOutside:()=>{i.dispatchCommand(Kg,{cardKey:n})},onGifInsert:async s=>{i.dispatchCommand(zI,s)},...t})};function aw({children:n,to:e}){const t=e||document.body;if(!t)return n;function i(r){r.stopPropagation()}return Ec.createPortal(C("div",{className:"koenig-lexical",onMouseDown:i,children:n}),t)}const Qfe={heart:n=>re.createElement("svg",{viewBox:"0 0 32 32",...n},re.createElement("title",null,"unsplash-heart"),re.createElement("path",{d:"M17.4 29c-.8.8-2 .8-2.8 0L2.3 16.2C-.8 13.1-.8 8 2.3 4.8c3.1-3.1 8.2-3.1 11.3 0L16 7.6l2.3-2.8c3.1-3.1 8.2-3.1 11.3 0 3.1 3.1 3.1 8.2 0 11.4L17.4 29z"})),download:n=>re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...n},re.createElement("title",null,"download"),re.createElement("path",{d:"M20 5.5l-8 8-8-8m-3.5 13h23",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10,fill:"none"}))};function aE({icon:n,label:e,...t}){const i=Qfe[n];return fe("a",{className:"flex h-8 shrink-0 cursor-pointer items-center rounded-md bg-white py-2 px-3 font-sans text-sm font-medium leading-6 text-grey-700 opacity-90 transition-all ease-in-out first-of-type:mr-3 hover:opacity-100",type:"button",onClick:r=>r.stopPropagation(),...t,children:[n&&C(i,{className:`h-4 w-4 fill-red stroke-[3px] ${e&&"mr-1"}`}),e&&C("span",{children:e})]})}function II({payload:n,srcUrl:e,links:t,likes:i,user:r,alt:o,urls:s,height:a,width:l,zoomed:u,insertImage:f,selectImg:h}){return fe("div",{className:`relative mb-6 block bg-grey-100 ${u?"h-full w-[max-content] cursor-zoom-out":"w-full cursor-zoom-in"}`,"data-kg-unsplash-gallery-item":!0,onClick:p=>{p.stopPropagation(),h(u?null:n)},children:[C("img",{alt:o,className:`${u?"h-full w-auto object-contain":""}`,height:a,loading:"lazy",src:e,width:l,"data-kg-unsplash-gallery-img":!0}),fe("div",{className:"absolute inset-0 flex flex-col justify-between bg-gradient-to-b from-black/5 via-black/5 to-black/30 p-5 opacity-0 transition-all ease-in-out hover:opacity-100",children:[fe("div",{className:"flex items-center justify-end",children:[C(aE,{"data-kg-button":"unsplash-like",href:`${t.html}/?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit`,icon:"heart",label:i,rel:"noopener noreferrer",target:"_blank"}),C(aE,{"data-kg-button":"unsplash-download",href:`${t.download}/?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit&amp;force=true`,icon:"download"})]}),fe("div",{className:"flex items-center justify-between",children:[fe("div",{className:"flex items-center",children:[C("img",{alt:"author",className:"mr-2 h-8 w-8 rounded-full",src:r.profile_image.small}),C("div",{className:"mr-2 truncate font-sans text-sm font-medium text-white",children:r.name})]}),C(aE,{label:"Insert image","data-kg-unsplash-insert-button":!0,onClick:p=>{p.stopPropagation(),f({src:s.regular.replace(/&w=1080/,"&w=2000"),caption:`Photo by ${r.name} on Unsplash`,height:a,width:l,alt:o,links:t})}})]})]})]})}function RI({payload:n,insertImage:e,selectImg:t,zoomed:i}){return C("div",{className:"flex h-full grow basis-0 justify-center","data-kg-unsplash-zoomed":!0,onClick:()=>t(null),children:C(II,{alt:n.alt_description,height:n.height,insertImage:e,likes:n.likes,links:n.links,payload:n,selectImg:t,srcUrl:n.urls.regular,urls:n.urls,user:n.user,width:n.width,zoomed:i})})}RI.propTypes={payload:me.object,insertImage:me.func,selectImg:me.func,zoomed:me.object||me.bool,srcUrl:me.string,alt:me.string,links:me.object,likes:me.number,user:me.object,urls:me.object,height:me.number,width:me.number};function Bfe(){return C("div",{className:"absolute inset-y-0 left-0 flex w-full items-center justify-center overflow-hidden pb-[8vh]","data-kg-loader":!0,children:C("div",{className:"relative inline-block h-[50px] w-[50px] animate-spin rounded-full border border-black/10 before:z-10 before:mt-[7px] before:block before:h-[7px] before:w-[7px] before:rounded-full before:bg-grey-800"})})}function zfe(n){return C("div",{className:"mr-6 flex grow basis-0 flex-col justify-start last-of-type:mr-0",children:n.children})}function Wfe(n){return n!=null&&n.columns?n==null?void 0:n.columns.map((e,t)=>C(zfe,{children:e.map(i=>C(II,{alt:i.alt_description,height:i.height,insertImage:n==null?void 0:n.insertImage,likes:i.likes,links:i.links,payload:i,selectImg:n==null?void 0:n.selectImg,srcUrl:i.urls.regular,urls:i.urls,user:i.user,width:i.width,zoomed:n==null?void 0:n.zoomed},i.id))},t)):null}function lE(n){return C("div",{className:"relative h-full overflow-hidden","data-kg-unsplash-gallery":!0,children:fe("div",{ref:n.galleryRef,className:`flex h-full w-full justify-center overflow-auto px-20 ${n!=null&&n.zoomed?"pb-10":""}`,"data-kg-unsplash-gallery-scrollref":!0,children:[n.children,(n==null?void 0:n.isLoading)&&C(Bfe,{})]})})}function Ufe({zoomed:n,error:e,galleryRef:t,isLoading:i,dataset:r,selectImg:o,insertImage:s}){return n?C(lE,{galleryRef:t,zoomed:n,children:C(RI,{insertImage:s,payload:n,selectImg:o,zoomed:n})}):e?C(lE,{galleryRef:t,zoomed:n,children:fe("div",{className:"flex h-full flex-col items-center justify-center",children:[C("h1",{className:"mb-4 text-2xl font-bold",children:"Error"}),C("p",{className:"text-lg font-medium",children:e})]})}):C(lE,{dataset:r,galleryRef:t,isLoading:i,zoomed:n,children:C(Wfe,{columns:r,insertImage:s,selectImg:o,zoomed:n})})}function FI({closeModal:n,handleSearch:e,children:t,galleryRef:i}){return fe(yt,{children:[C("div",{className:"fixed inset-0 z-40 h-[100vh] bg-black opacity-60"}),fe("div",{ref:i,className:"not-kg-prose fixed inset-8 z-50 overflow-hidden rounded bg-white shadow-xl","data-kg-modal":"unsplash",children:[C("button",{className:"absolute top-6 right-6 cursor-pointer",type:"button",children:C(w0,{className:"h-4 w-4 stroke-2 text-grey-400","data-kg-modal-close-button":!0,onClick:()=>n()})}),fe("div",{className:"flex h-full flex-col",children:[fe("header",{className:"flex shrink-0 items-center justify-between py-10 px-20",children:[fe("h1",{className:"flex items-center gap-2 font-sans text-3xl font-bold text-black",children:[C(n3,{className:"mb-1"}),"Unsplash"]}),fe("div",{className:"relative w-full max-w-sm",children:[C(LI,{className:"absolute top-1/2 left-4 h-4 w-4 -translate-y-2 text-grey-700"}),C("input",{className:"h-10 w-full rounded-full border border-grey-300 pr-8 pl-10 font-sans text-md font-normal text-black focus:border-grey-400 focus-visible:outline-none",placeholder:"Search free high-resolution photos",autoFocus:!0,"data-kg-unsplash-search":!0,onChange:e})]})]}),t]})]})]})}FI.propTypes={closeModal:me.func,handleSearch:me.func};class qfe{constructor(e){this.columnCount=e||3,this.columns=null,this.columnHeights=null}reset(){let e=[],t=[];for(let i=0;i<this.columnCount;i+=1)e[i]=[],t[i]=0;this.columns=e,this.columnHeights=t}addColumns(){for(let e=0;e<this.columnCount;e++)this.columns.push([]),this.columnHeights.push(0)}addPhotoToColumns(e){this.columns||this.reset();let t=Math.min(...this.columnHeights),i=this.columnHeights.indexOf(t);this.columnHeights[i]+=300*e.ratio,this.columns[i].push(e)}getColumns(){return this.columns}changeColumnCount(e){e!==this.columnCount&&(this.columnCount=e,this.reset())}}const cE=new qfe(3);class Hfe{constructor({API_URL:e,HEADERS:t}){this.API_URL=e||"https://api.unsplash.com",this.HEADERS=t,this.photos=[],this._pagination=[],this.page=1,this.error=null,this.search_is_running=!1,this.request_is_running=!1,this.search_term="",this._lastRequestUrl="",this.isLoading=!1}extractPagination(e){e=e||e.results;let t={},i=new RegExp('<(.*)>; rel="(.*)"'),r=[];for(let o of e.headers.entries())o[0]==="link"&&r.push(o[1]);return r&&r.toString().split(",").forEach(o=>{if(o){let s=i.exec(o);t[s[2]]=s[1]}}),this._pagination=t,e}async checkStatus(e){if(e.status>=200&&e.status<300)return e;let t="",i;return e.headers.map["content-type"]==="application/json"?i=e.json().then(r=>r.errors[0]):e.headers.map["content-type"]==="text/xml"&&(i=e.text()),i.then(r=>{e.status===403&&e.headers.map["x-ratelimit-remaining"]==="0"&&(t="Unsplash API rate limit reached, please try again later."),t=t||r||`Error ${e.status}: Uh-oh! Trouble reaching the Unsplash API`,this.error=t;let o=new Error(t);throw o.response=e,o})}async makeRequest(e){if(this.request_is_running)return;this._lastRequestUrl=e;const t={method:"GET",headers:this.HEADERS};return this.request_is_running=!0,this.isLoading=!0,await fetch(e,t).then(i=>this.checkStatus(i)).then(i=>this.extractPagination(i)).then(i=>(this.request_is_running=!1,i.json())).catch(i=>this.error=i)}async loadNew(){this.reset();const e=`${this.API_URL}/photos?per_page=30`,t=await this.makeRequest(e);await this.addPhotosFromResponse(t)}async addPhotosFromResponse(e){(e.results||e).forEach(i=>{this.addPhoto(i)})}async addPhoto(e){e.ratio=e.width/e.height,this.photos.push(e),cE.addPhotoToColumns(e)}async loadNextPage(){if(!this.request_is_running&&!this.search_is_running&&this.photos.length!==0&&this._pagination.next){const e=`${this._pagination.next}`,t=await this.makeRequest(e);this.addPhotosFromResponse(t)}}async updateSearch(e){e!==this.search_term&&(this.request_is_running||(this.reset(),this.search_term=e,e?await this.search(e):await this.loadNew()))}async search(e){if(this.search_is_running!==!0){this.search_is_running=!0;const t=`${this.API_URL}/search/photos?query=${e}&per_page=30`,i=await this.makeRequest(t);i&&(this.addPhotosFromResponse(i),this.search_is_running=!1)}}triggerDownload(e){e.links.download_location&&this.makeRequest(e.links.download_location)}getPhotos(){return this.photos}clearPhotos(){this.photos=[]}getColumns(){return cE.getColumns()}reset(){this.clearPhotos(),cE.reset(),this.pagination=[]}setSearchTerm(e){this.search_term=e}}const jfe="https://api.unsplash.com",QI=({onClose:n,onImageInsert:e,unsplashConf:t})=>{const i=B.useMemo(()=>new Hfe({API_URL:jfe,HEADERS:t.defaultHeaders}),[t.defaultHeaders]),r=B.useRef(null),[o,s]=B.useState(0),[a,l]=B.useState(0),[u,f]=B.useState(i.search_is_running||!0),h=B.useRef(!1),[p,v]=B.useState(""),[w,O]=B.useState(null),[_,E]=B.useState(i.getColumns()||[]);B.useEffect(()=>{w===null&&a!==0&&(r.current.scrollTop=a,l(0))},[w,o,a]),B.useEffect(()=>{const V=r.current;if(!w)return V&&V.addEventListener("scroll",()=>{s(V.scrollTop)}),()=>{V&&V.removeEventListener("scroll",()=>{s(V.scrollTop)})}},[r,w]);const T=B.useCallback(async()=>{if(h.current===!1||p.length===0){E([]),await i.clearPhotos(),await i.loadNew();const V=i.getColumns();E(V),r.current.scrollTop!==0&&(r.current.scrollTop=0),f(!1)}},[i,p]),A=async V=>{const K=V.target.value;K.length>2&&(O(null),v(K)),K.length===0&&(v(""),h.current=!1,await T())},D=B.useCallback(async()=>{if(p){f(!0),i.clearPhotos(),await i.updateSearch(p);const V=i.getColumns();E(V),r.current.scrollTop!==0&&(r.current.scrollTop=0),f(!1)}},[p,i]);B.useEffect(()=>{const V=setTimeout(async()=>{p.length>2?await D():await T()},300);return()=>{h.current=!0,clearTimeout(V)}},[p,D,T]);const M=B.useCallback(async()=>{f(!0),await i.loadNextPage();const V=i.getColumns();E(V),f(!1)},[i]);B.useEffect(()=>{const V=r.current;if(V){const K=async()=>{w===null&&V.scrollTop+V.clientHeight>=V.scrollHeight-1e3&&await M()};return V.addEventListener("scroll",K),()=>{V.removeEventListener("scroll",K)}}},[r,M,w]);const I=V=>{V&&(O(V),l(o)),V===null&&(r.current.scrollTop=a,O(null))};async function z(V){V.src&&(i.triggerDownload(V),e(V))}return C(aw,{children:C(FI,{closeModal:n,handleSearch:A,children:C(Ufe,{dataset:_,error:i.error,galleryRef:r,insertImage:z,isLoading:u,selectImg:I,zoomed:w})})})},Vfe=({nodeKey:n,isModalOpen:e=!0})=>{const{cardConfig:t}=B.useContext(bn),[i]=Ye.useLexicalComposerContext(),[r,o]=B.useState(e),s=()=>{n&&i.update(()=>{U.$getNodeByKey(n).remove()})},a=async l=>{i.update(()=>{const u=U.$getNodeByKey(n);u.setSrc(l.src),u.setImgHeight(l.height),u.setImgWidth(l.width),u.setCaption(l.caption),u.setAltText(l.alt);const f=U.$createNodeSelection();f.add(u.getKey()),U.$setSelection(f)}),o(!1)};return r?C(QI,{unsplashConf:t.unsplash,onClose:s,onImageInsert:a}):null},BI=U.createCommand("OPEN_TENOR_SELECTOR_COMMAND"),zI=U.createCommand("INSERT_FROM_TENOR_COMMAND"),WI=U.createCommand("OPEN_UNSPLASH_SELECTOR_COMMAND"),Zfe=()=>{const[n]=Ye.useLexicalComposerContext();return B.useEffect(()=>{if(!n.hasNodes([nf])){console.error("ImagePlugin: ImageNode not registered");return}return Ut.mergeRegister(n.registerCommand(BI,async e=>{const t=ip({...e,selector:Ffe,isImageHidden:!0});return n.dispatchCommand(Sr,{cardNode:t}),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(zI,async e=>{const t=ip(e),r=U.$getSelection().getNodes()[0];return n.dispatchCommand(Sr,{cardNode:t}),r.remove(),!0},U.COMMAND_PRIORITY_LOW),n.registerCommand(WI,async e=>{const t=ip({...e,selector:Vfe});return n.dispatchCommand(Sr,{cardNode:t}),!0},U.COMMAND_PRIORITY_LOW))},[n]),null};class nf extends cce{constructor(t={},i){super(t,i);ke(this,"__triggerFileDialog",!1);ke(this,"__previewSrc",null);ke(this,"__captionEditor");ke(this,"__captionEditorInitialState");const{previewSrc:r,triggerFileDialog:o,initialFile:s,selector:a,isImageHidden:l,caption:u}=t;if(this.__previewSrc=r||"",this.__triggerFileDialog=!t.src&&o||!1,this.__initialFile=s||null,this.__selector=a,this.__isImageHidden=l,this.__captionEditor=t.captionEditor||U.createEditor({nodes:Jn}),this.__captionEditorInitialState=t.captionEditorInitialState,!this.__captionEditorInitialState){const f=u?`<p>${u}</p>`:null;this.__captionEditorInitialState=bo({editor:U.createEditor({nodes:Jn}),initialHtml:f})}}getIcon(){return HS}getDataset(){const t=super.getDataset();t.__previewSrc=this.__previewSrc,t.__triggerFileDialog=this.__triggerFileDialog;const i=this.getLatest();return t.captionEditor=i.__captionEditor,t.captionEditorInitialState=i.__captionEditorInitialState,t}getPreviewSrc(){return this.getLatest().__previewSrc}setPreviewSrc(t){const i=this.getWritable();return i.__previewSrc=t}setTriggerFileDialog(t){const i=this.getWritable();return i.__triggerFileDialog=t}createDOM(){return document.createElement("div")}exportJSON(){const t=super.exportJSON();return this.__captionEditor&&this.__captionEditor.getEditorState().read(()=>{const i=ar.$generateHtmlFromNodes(this.__captionEditor,null),r=so(i);t.caption=r}),t}decorate(){const t=this.__selector;return fe(Yi,{nodeKey:this.getKey(),width:this.__cardWidth,children:[this.__selector&&C(t,{nodeKey:this.getKey()}),!this.__isImageHidden&&C(Efe,{altText:this.__altText,captionEditor:this.__captionEditor,captionEditorInitialState:this.__captionEditorInitialState,href:this.__href,initialFile:this.__initialFile,nodeKey:this.getKey(),previewSrc:this.getPreviewSrc(),src:this.__src,triggerFileDialog:this.__triggerFileDialog})]})}}ke(nf,"kgMenu",[{label:"Image",desc:"Upload, or embed with /image [url]",Icon:HS,insertCommand:z4,insertParams:{triggerFileDialog:!0},matches:["image","img"],queryParams:["src"]},{section:"Embed",label:"Unsplash",desc:"/unsplash [search term or url]",Icon:n3,insertCommand:WI,insertParams:{triggerFileDialog:!1},matches:["unsplash","uns"],queryParams:["src"]},{label:"GIF",desc:"Search and embed gifs",Icon:BA,insertCommand:BI,insertParams:{triggerFileDialog:!1},matches:["gif","giphy","tenor"],queryParams:["src"],isHidden:({config:t})=>!(t!=null&&t.tenor)}]),ke(nf,"uploadType","image");const ip=n=>new nf(n);function Gfe(n){return n instanceof nf}var Xfe=typeof global=="object"&&global&&global.Object===Object&&global;const Yfe=Xfe;var Kfe=typeof self=="object"&&self&&self.Object===Object&&self,Jfe=Yfe||Kfe||Function("return this")();const uE=Jfe;var ede=uE.Symbol;const rf=ede;var UI=Object.prototype,tde=UI.hasOwnProperty,nde=UI.toString,$0=rf?rf.toStringTag:void 0;function ide(n){var e=tde.call(n,$0),t=n[$0];try{n[$0]=void 0;var i=!0}catch{}var r=nde.call(n);return i&&(e?n[$0]=t:delete n[$0]),r}var rde=Object.prototype,ode=rde.toString;function sde(n){return ode.call(n)}var ade="[object Null]",lde="[object Undefined]",qI=rf?rf.toStringTag:void 0;function fE(n){return n==null?n===void 0?lde:ade:qI&&qI in Object(n)?ide(n):sde(n)}function dE(n){return n!=null&&typeof n=="object"}var cde="[object Symbol]";function hE(n){return typeof n=="symbol"||dE(n)&&fE(n)==cde}function ude(n,e){for(var t=-1,i=n==null?0:n.length,r=Array(i);++t<i;)r[t]=e(n[t],t,n);return r}var fde=Array.isArray;const A0=fde;var dde=1/0,HI=rf?rf.prototype:void 0,jI=HI?HI.toString:void 0;function VI(n){if(typeof n=="string")return n;if(A0(n))return ude(n,VI)+"";if(hE(n))return jI?jI.call(n):"";var e=n+"";return e=="0"&&1/n==-dde?"-0":e}function lw(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}function hde(n){return n}var gde="[object AsyncFunction]",pde="[object Function]",mde="[object GeneratorFunction]",vde="[object Proxy]";function yde(n){if(!lw(n))return!1;var e=fE(n);return e==pde||e==mde||e==gde||e==vde}var bde=uE["__core-js_shared__"];const gE=bde;var ZI=function(){var n=/[^.]+$/.exec(gE&&gE.keys&&gE.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function kde(n){return!!ZI&&ZI in n}var wde=Function.prototype,_de=wde.toString;function xde(n){if(n!=null){try{return _de.call(n)}catch{}try{return n+""}catch{}}return""}var Ode=/[\\^$.*+?()[\]{}|]/g,Sde=/^\[object .+?Constructor\]$/,Cde=Function.prototype,Ede=Object.prototype,Tde=Cde.toString,$de=Ede.hasOwnProperty,Ade=RegExp("^"+Tde.call($de).replace(Ode,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Nde(n){if(!lw(n)||kde(n))return!1;var e=yde(n)?Ade:Sde;return e.test(xde(n))}function Pde(n,e){return n==null?void 0:n[e]}function pE(n,e){var t=Pde(n,e);return Nde(t)?t:void 0}function Dde(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}var Mde=800,Lde=16,Ide=Date.now;function Rde(n){var e=0,t=0;return function(){var i=Ide(),r=Lde-(i-t);if(t=i,r>0){if(++e>=Mde)return arguments[0]}else e=0;return n.apply(void 0,arguments)}}function Fde(n){return function(){return n}}var Qde=function(){try{var n=pE(Object,"defineProperty");return n({},"",{}),n}catch{}}();const cw=Qde;var Bde=cw?function(n,e){return cw(n,"toString",{configurable:!0,enumerable:!1,value:Fde(e),writable:!0})}:hde,zde=Rde(Bde);const Wde=zde;var Ude=9007199254740991,qde=/^(?:0|[1-9]\d*)$/;function GI(n,e){var t=typeof n;return e=e??Ude,!!e&&(t=="number"||t!="symbol"&&qde.test(n))&&n>-1&&n%1==0&&n<e}function Hde(n,e,t){e=="__proto__"&&cw?cw(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):n[e]=t}function XI(n,e){return n===e||n!==n&&e!==e}var jde=Object.prototype,Vde=jde.hasOwnProperty;function Zde(n,e,t){var i=n[e];(!(Vde.call(n,e)&&XI(i,t))||t===void 0&&!(e in n))&&Hde(n,e,t)}var YI=Math.max;function Gde(n,e,t){return e=YI(e===void 0?n.length-1:e,0),function(){for(var i=arguments,r=-1,o=YI(i.length-e,0),s=Array(o);++r<o;)s[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=t(s),Dde(n,this,a)}}var Xde=9007199254740991;function Yde(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Xde}var Kde="[object Arguments]";function KI(n){return dE(n)&&fE(n)==Kde}var JI=Object.prototype,Jde=JI.hasOwnProperty,ehe=JI.propertyIsEnumerable,the=KI(function(){return arguments}())?KI:function(n){return dE(n)&&Jde.call(n,"callee")&&!ehe.call(n,"callee")};const eR=the;var nhe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ihe=/^\w*$/;function rhe(n,e){if(A0(n))return!1;var t=typeof n;return t=="number"||t=="symbol"||t=="boolean"||n==null||hE(n)?!0:ihe.test(n)||!nhe.test(n)||e!=null&&n in Object(e)}var ohe=pE(Object,"create");const N0=ohe;function she(){this.__data__=N0?N0(null):{},this.size=0}function ahe(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var lhe="__lodash_hash_undefined__",che=Object.prototype,uhe=che.hasOwnProperty;function fhe(n){var e=this.__data__;if(N0){var t=e[n];return t===lhe?void 0:t}return uhe.call(e,n)?e[n]:void 0}var dhe=Object.prototype,hhe=dhe.hasOwnProperty;function ghe(n){var e=this.__data__;return N0?e[n]!==void 0:hhe.call(e,n)}var phe="__lodash_hash_undefined__";function mhe(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=N0&&e===void 0?phe:e,this}function Vd(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var i=n[e];this.set(i[0],i[1])}}Vd.prototype.clear=she,Vd.prototype.delete=ahe,Vd.prototype.get=fhe,Vd.prototype.has=ghe,Vd.prototype.set=mhe;function vhe(){this.__data__=[],this.size=0}function uw(n,e){for(var t=n.length;t--;)if(XI(n[t][0],e))return t;return-1}var yhe=Array.prototype,bhe=yhe.splice;function khe(n){var e=this.__data__,t=uw(e,n);if(t<0)return!1;var i=e.length-1;return t==i?e.pop():bhe.call(e,t,1),--this.size,!0}function whe(n){var e=this.__data__,t=uw(e,n);return t<0?void 0:e[t][1]}function _he(n){return uw(this.__data__,n)>-1}function xhe(n,e){var t=this.__data__,i=uw(t,n);return i<0?(++this.size,t.push([n,e])):t[i][1]=e,this}function rp(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var i=n[e];this.set(i[0],i[1])}}rp.prototype.clear=vhe,rp.prototype.delete=khe,rp.prototype.get=whe,rp.prototype.has=_he,rp.prototype.set=xhe;var Ohe=pE(uE,"Map");const She=Ohe;function Che(){this.size=0,this.__data__={hash:new Vd,map:new(She||rp),string:new Vd}}function Ehe(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}function fw(n,e){var t=n.__data__;return Ehe(e)?t[typeof e=="string"?"string":"hash"]:t.map}function The(n){var e=fw(this,n).delete(n);return this.size-=e?1:0,e}function $he(n){return fw(this,n).get(n)}function Ahe(n){return fw(this,n).has(n)}function Nhe(n,e){var t=fw(this,n),i=t.size;return t.set(n,e),this.size+=t.size==i?0:1,this}function Zd(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var i=n[e];this.set(i[0],i[1])}}Zd.prototype.clear=Che,Zd.prototype.delete=The,Zd.prototype.get=$he,Zd.prototype.has=Ahe,Zd.prototype.set=Nhe;var Phe="Expected a function";function mE(n,e){if(typeof n!="function"||e!=null&&typeof e!="function")throw new TypeError(Phe);var t=function(){var i=arguments,r=e?e.apply(this,i):i[0],o=t.cache;if(o.has(r))return o.get(r);var s=n.apply(this,i);return t.cache=o.set(r,s)||o,s};return t.cache=new(mE.Cache||Zd),t}mE.Cache=Zd;var Dhe=500;function Mhe(n){var e=mE(n,function(i){return t.size===Dhe&&t.clear(),i}),t=e.cache;return e}var Lhe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ihe=/\\(\\)?/g,Rhe=Mhe(function(n){var e=[];return n.charCodeAt(0)===46&&e.push(""),n.replace(Lhe,function(t,i,r,o){e.push(r?o.replace(Ihe,"$1"):i||t)}),e});const Fhe=Rhe;function vE(n){return n==null?"":VI(n)}function dw(n,e){return A0(n)?n:rhe(n,e)?[n]:Fhe(vE(n))}var Qhe=1/0;function yE(n){if(typeof n=="string"||hE(n))return n;var e=n+"";return e=="0"&&1/n==-Qhe?"-0":e}function Bhe(n,e){e=dw(e,n);for(var t=0,i=e.length;n!=null&&t<i;)n=n[yE(e[t++])];return t&&t==i?n:void 0}function zhe(n,e){for(var t=-1,i=e.length,r=n.length;++t<i;)n[r+t]=e[t];return n}var tR=rf?rf.isConcatSpreadable:void 0;function Whe(n){return A0(n)||eR(n)||!!(tR&&n&&n[tR])}function nR(n,e,t,i,r){var o=-1,s=n.length;for(t||(t=Whe),r||(r=[]);++o<s;){var a=n[o];e>0&&t(a)?e>1?nR(a,e-1,t,i,r):zhe(r,a):i||(r[r.length]=a)}return r}function Uhe(n){var e=n==null?0:n.length;return e?nR(n,1):[]}function qhe(n){return Wde(Gde(n,void 0,Uhe),n+"")}function Hhe(n,e,t,i){var r=-1,o=n==null?0:n.length;for(i&&o&&(t=n[++r]);++r<o;)t=e(t,n[r],r,n);return t}function jhe(n){return function(e){return n==null?void 0:n[e]}}var Vhe={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Zhe=jhe(Vhe);const Ghe=Zhe;var Xhe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Yhe="\\u0300-\\u036f",Khe="\\ufe20-\\ufe2f",Jhe="\\u20d0-\\u20ff",ege=Yhe+Khe+Jhe,tge="["+ege+"]",nge=RegExp(tge,"g");function ige(n){return n=vE(n),n&&n.replace(Xhe,Ghe).replace(nge,"")}var rge=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function oge(n){return n.match(rge)||[]}var sge=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function age(n){return sge.test(n)}var iR="\\ud800-\\udfff",lge="\\u0300-\\u036f",cge="\\ufe20-\\ufe2f",uge="\\u20d0-\\u20ff",fge=lge+cge+uge,rR="\\u2700-\\u27bf",oR="a-z\\xdf-\\xf6\\xf8-\\xff",dge="\\xac\\xb1\\xd7\\xf7",hge="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",gge="\\u2000-\\u206f",pge=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",sR="A-Z\\xc0-\\xd6\\xd8-\\xde",mge="\\ufe0e\\ufe0f",aR=dge+hge+gge+pge,lR="['’]",cR="["+aR+"]",vge="["+fge+"]",uR="\\d+",yge="["+rR+"]",fR="["+oR+"]",dR="[^"+iR+aR+uR+rR+oR+sR+"]",bge="\\ud83c[\\udffb-\\udfff]",kge="(?:"+vge+"|"+bge+")",wge="[^"+iR+"]",hR="(?:\\ud83c[\\udde6-\\uddff]){2}",gR="[\\ud800-\\udbff][\\udc00-\\udfff]",op="["+sR+"]",_ge="\\u200d",pR="(?:"+fR+"|"+dR+")",xge="(?:"+op+"|"+dR+")",mR="(?:"+lR+"(?:d|ll|m|re|s|t|ve))?",vR="(?:"+lR+"(?:D|LL|M|RE|S|T|VE))?",yR=kge+"?",bR="["+mge+"]?",Oge="(?:"+_ge+"(?:"+[wge,hR,gR].join("|")+")"+bR+yR+")*",Sge="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Cge="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ege=bR+yR+Oge,Tge="(?:"+[yge,hR,gR].join("|")+")"+Ege,$ge=RegExp([op+"?"+fR+"+"+mR+"(?="+[cR,op,"$"].join("|")+")",xge+"+"+vR+"(?="+[cR,op+pR,"$"].join("|")+")",op+"?"+pR+"+"+mR,op+"+"+vR,Cge,Sge,uR,Tge].join("|"),"g");function Age(n){return n.match($ge)||[]}function Nge(n,e,t){return n=vE(n),e=t?void 0:e,e===void 0?age(n)?Age(n):oge(n):n.match(e)||[]}var Pge="['’]",Dge=RegExp(Pge,"g");function Mge(n){return function(e){return Hhe(Nge(ige(e).replace(Dge,"")),n,"")}}function Lge(n,e){return n!=null&&e in Object(n)}function Ige(n,e,t){e=dw(e,n);for(var i=-1,r=e.length,o=!1;++i<r;){var s=yE(e[i]);if(!(o=n!=null&&t(n,s)))break;n=n[s]}return o||++i!=r?o:(r=n==null?0:n.length,!!r&&Yde(r)&&GI(s,r)&&(A0(n)||eR(n)))}function Rge(n,e){return n!=null&&Ige(n,e,Lge)}var Fge=Mge(function(n,e,t){return n+(t?"-":"")+e.toLowerCase()});const hw=Fge;function Qge(n,e,t,i){if(!lw(n))return n;e=dw(e,n);for(var r=-1,o=e.length,s=o-1,a=n;a!=null&&++r<o;){var l=yE(e[r]),u=t;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(r!=s){var f=a[l];u=i?i(f,l,a):void 0,u===void 0&&(u=lw(f)?f:GI(e[r+1])?[]:{})}Zde(a,l,u),a=a[l]}return n}function Bge(n,e,t){for(var i=-1,r=e.length,o={};++i<r;){var s=e[i],a=Bhe(n,s);t(a,s)&&Qge(o,dw(s,n),a)}return o}function zge(n,e){return Bge(n,e,function(t,i){return Rge(n,i)})}var Wge=qhe(function(n,e){return n==null?{}:zge(n,e)});const kR=Wge,gw="koenigDndContainer",wR=`[data-${hw(gw)}]`,bE="koenigDndDraggable",Uge=`[data-${hw(bE)}]`,kE="koenigDndDroppable",wE=`[data-${hw(kE)}]`,qge=`[data-${hw("koenigDndDisabled")}]`,_R="koenig-drag-drop-indicator",_E=1e4,Hge="koenig-drag-drop-ghost-container",jge=_E+1;function xR(n,e,t=""){return n===-1?!0:n===e||typeof e>"u"?!1:(t.match(/top/)&&(e-=1),t.match(/bottom/)&&(e+=1),e!==n)}function sp(n,e){return OE(n,e,t=>t.parentNode)}function Vge(n,e){return n=n.nextElementSibling,OE(n,e,t=>t.nextElementSibling)}function Zge(n,e){return n=n.previousElementSibling,OE(n,e,t=>t.previousElementSibling)}function Gge(n){if(!n)return xE();let e=getComputedStyle(n).getPropertyValue("position"),t=e==="absolute",i=sp(n,r=>t&&Xge(r)?!1:Yge(r));return e==="fixed"&&!i?xE():i}function xE(){var n;return((n=document.scrollingElement)==null?void 0:n.body)||document.scrollingElement||document.element}function OR(n,e){n.style.webkitUserSelect=e,n.style.mozUserSelect=e,n.style.msUserSelect=e,n.style.oUserSelect=e,n.style.userSelect=e}function OE(n,e,t){if(!n)return null;let i=e,r=e,o=typeof e=="string",s=typeof e=="function";function a(u){if(u){if(o)return u.matches(i);if(s)return r(u)}else return u}let l=n;do{if(a(l))return l;l=t(l)}while(l&&l!==document.body&&l!==document)}function Xge(n){return getComputedStyle(n).getPropertyValue("position")==="static"}function Yge(n){let e=/(auto|scroll)/,t=getComputedStyle(n,null),i=t.getPropertyValue("overflow")+t.getPropertyValue("overflow-y")+t.getPropertyValue("overflow-x");return e.test(i)}var pw={},Kge={get exports(){return pw},set exports(n){pw=n}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(l,u,f){this.fn=l,this.context=u,this.once=f||!1}function o(l,u,f,h,p){if(typeof f!="function")throw new TypeError("The listener must be a function");var v=new r(f,h||l,p),w=t?t+u:u;return l._events[w]?l._events[w].fn?l._events[w]=[l._events[w],v]:l._events[w].push(v):(l._events[w]=v,l._eventsCount++),l}function s(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],f,h;if(this._eventsCount===0)return u;for(h in f=this._events)e.call(f,h)&&u.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(f)):u},a.prototype.listeners=function(u){var f=t?t+u:u,h=this._events[f];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,v=h.length,w=new Array(v);p<v;p++)w[p]=h[p].fn;return w},a.prototype.listenerCount=function(u){var f=t?t+u:u,h=this._events[f];return h?h.fn?1:h.length:0},a.prototype.emit=function(u,f,h,p,v,w){var O=t?t+u:u;if(!this._events[O])return!1;var _=this._events[O],E=arguments.length,T,A;if(_.fn){switch(_.once&&this.removeListener(u,_.fn,void 0,!0),E){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,f),!0;case 3:return _.fn.call(_.context,f,h),!0;case 4:return _.fn.call(_.context,f,h,p),!0;case 5:return _.fn.call(_.context,f,h,p,v),!0;case 6:return _.fn.call(_.context,f,h,p,v,w),!0}for(A=1,T=new Array(E-1);A<E;A++)T[A-1]=arguments[A];_.fn.apply(_.context,T)}else{var D=_.length,M;for(A=0;A<D;A++)switch(_[A].once&&this.removeListener(u,_[A].fn,void 0,!0),E){case 1:_[A].fn.call(_[A].context);break;case 2:_[A].fn.call(_[A].context,f);break;case 3:_[A].fn.call(_[A].context,f,h);break;case 4:_[A].fn.call(_[A].context,f,h,p);break;default:if(!T)for(M=1,T=new Array(E-1);M<E;M++)T[M-1]=arguments[M];_[A].fn.apply(_[A].context,T)}}return!0},a.prototype.on=function(u,f,h){return o(this,u,f,h,!1)},a.prototype.once=function(u,f,h){return o(this,u,f,h,!0)},a.prototype.removeListener=function(u,f,h,p){var v=t?t+u:u;if(!this._events[v])return this;if(!f)return s(this,v),this;var w=this._events[v];if(w.fn)w.fn===f&&(!p||w.once)&&(!h||w.context===h)&&s(this,v);else{for(var O=0,_=[],E=w.length;O<E;O++)(w[O].fn!==f||p&&!w[O].once||h&&w[O].context!==h)&&_.push(w[O]);_.length?this._events[v]=_.length===1?_[0]:_:s(this,v)}return this},a.prototype.removeAllListeners=function(u){var f;return u?(f=t?t+u:u,this._events[f]&&s(this,f)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a})(Kge);const omt=pw;class Jge{constructor(e,t){ke(this,"element",null);ke(this,"draggables",[]);ke(this,"droppables",[]);ke(this,"isDragEnabled",!0);t.createGhostElement&&(this._createGhostElement=t.createGhostElement,delete t.createGhostElement),Object.assign(this,{element:e,draggables:[],droppables:[],isDragEnabled:!0},t),e.dataset[gw]="true",this.refresh()}getDraggableInfo(){return!1}getIndicatorPosition(){return!1}onDragStart(){}onDragEnterContainer(){}onDragEnterDroppable(){}onDragOverDroppable(){}onDragLeaveDroppable(){}onDragLeaveContainer(){}onDragEnd(){}onDrop(){}onDropEnd(){}createGhostElement(e){let t;if(typeof this._createGhostElement=="function"&&(t=this._createGhostElement(e)),!t&&(e.type==="image"||e.cardName==="image")){let i=e.element.querySelector("img");if(i){let r=i.width/i.height,o,s;i.width>i.height?(o=200,s=200/r):(o=200*r,s=200),t=document.createElement("img"),t.width=o,t.height=s,t.id="koenig-drag-drop-ghost",t.src=i.src,t.style.position="absolute",t.style.top="0",t.style.left=`-${o}px`,t.style.zIndex=jge,t.style.willChange="transform"}else{console.warn("No <img> element found in draggable");return}}if(t)return t;console.warn(`No default createGhostElement handler for type "${e.type}"`)}enableDrag(){this.isDragEnabled=!0,this.element.dataset[gw]="true",this.refresh()}disableDrag(){this.isDragEnabled=!1,delete this.element.dataset[gw],this.refresh()}refresh(){this.draggables.forEach(e=>{delete e.dataset[bE]}),this.droppables.forEach(e=>{delete e.dataset[kE]}),this.draggables=[],this.droppables=[],this.isDragEnabled&&(this.element.querySelectorAll(this.draggableSelector).forEach(e=>{e.dataset[bE]="true",this.draggables.push(e)}),this.element.querySelectorAll(this.droppableSelector).forEach(e=>{e.dataset[kE]="true",this.droppables.push(e)}))}}const epe={speed:8,sensitivity:50};class tpe{constructor(){this.options=Object.assign({},epe),this.currentMousePosition=null,this.findScrollableElementFrame=null,this.scrollableElement=null,this.scrollAnimationFrame=null,this._scroll=this._scroll.bind(this),this._isSafari=navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}dragStart(e){this.findScrollableElementFrame=requestAnimationFrame(()=>{this.scrollableElement=this.getScrollableElement(e.element)})}dragMove(e){this.findScrollableElementFrame=requestAnimationFrame(()=>{this.scrollableElement=this.getScrollableElement(e.target)}),this.scrollableElement&&(this.currentMousePosition={clientX:e.mousePosition.x,clientY:e.mousePosition.y},this.scrollAnimationFrame=requestAnimationFrame(this._scroll))}dragStop(){cancelAnimationFrame(this.scrollAnimationFrame),cancelAnimationFrame(this.findScrollableElementFrame),this.currentMousePosition=null,this.findScrollableElementFrame=null,this.scrollableElement=null,this.scrollAnimationFrame=null}getScrollableElement(e){let t=Gge(e);return t===xE()&&(t=document.querySelector(".gh-koenig-editor")),t}_scroll(){if(!this.scrollableElement||!this.currentMousePosition)return;cancelAnimationFrame(this.scrollAnimationFrame);let{speed:e,sensitivity:t}=this.options,i=this.scrollableElement.getBoundingClientRect(),r=this.scrollableElement,o=this.currentMousePosition.clientX,s=this.currentMousePosition.clientY,{offsetHeight:a,offsetWidth:l}=r,u=i.top+a-s,f=s-i.top;u<t&&!(this._isSafari&&u<0)?r.scrollTop+=e:f<t&&!(this._isSafari&&f<0)&&(r.scrollTop-=e),i.left+l-o<t?r.scrollLeft+=e:o-i.left<t&&(r.scrollLeft-=e),this.scrollAnimationFrame=requestAnimationFrame(this._scroll)}}var ap={};/**
431
431
  * @license React
432
432
  * react-dom-server-legacy.browser.production.min.js
433
433
  *