@embedreach/components 0.3.14 → 0.3.15

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.
@@ -91564,7 +91564,7 @@ const EmailPreview = ({
91564
91564
  communicationGroup?.emailPreviewText || null
91565
91565
  );
91566
91566
  const [body, setBody] = useState(
91567
- communicationGroup?.emailCompiledHtml || communicationGroup?.emailHtmlBody || null
91567
+ communicationGroup?.emailHtmlBody || null
91568
91568
  );
91569
91569
  const [showStripoEditor, setShowStripoEditor] = useState(false);
91570
91570
  const [saveClicked, setSaveClicked] = useState(false);
@@ -91672,7 +91672,6 @@ const EmailPreview = ({
91672
91672
  groupId: communicationGroup.id,
91673
91673
  params: {
91674
91674
  emailChannelSenderId: fromEmail,
91675
- emailHtmlBody: body,
91676
91675
  emailSubject: debouncedSubject,
91677
91676
  ...debouncedPreviewText && {
91678
91677
  emailPreviewText: debouncedPreviewText
package/dist/index.umd.js CHANGED
@@ -80,7 +80,7 @@ function O4(e,a){return e?function(e){return"function"==typeof e&&(()=>{const a=
80
80
  *
81
81
  * This source code is licensed under the MIT license found in the
82
82
  * LICENSE file in the root directory of this source tree.
83
- */_ge.exports="production"===process.env.NODE_ENV?function(){if(xge)return Pge;xge=1;var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},n=Sge.useSyncExternalStore,t=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;return Pge.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d=t(null);if(null===d.current){var m={hasValue:!1,value:null};d.current=m}else m=d.current;d=r((function(){function a(a){if(!i){if(i=!0,n=a,a=u(a),void 0!==c&&m.hasValue){var r=m.value;if(c(r,a))return t=r}return t=a}if(r=t,e(n,a))return r;var o=u(a);return void 0!==c&&c(r,o)?r:(n=a,t=o)}var n,t,i=!1,r=void 0===l?null:l;return[function(){return a(s())},null===r?void 0:function(){return a(r())}]}),[s,l,u,c]);var h=n(a,d[0],d[1]);return i((function(){m.hasValue=!0,m.value=h}),[h]),o(h),h},Pge}():(jge||(jge=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},n=Sge.useSyncExternalStore,t=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;Lge.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d,m=t(null);null===m.current?m.current=d={hasValue:!1,value:null}:d=m.current;var h=r((function(){var a,n,t=!1,i=function(i){if(!t){t=!0,a=i;var r=u(i);if(void 0!==c&&d.hasValue){var o=d.value;if(c(o,r))return n=o,o}return n=r,r}var s=n;if(e(a,i))return s;var l=u(i);return void 0!==c&&c(s,l)?s:(a=i,n=l,l)},r=void 0===l?null:l;return[function(){return i(s())},null===r?void 0:function(){return i(r())}]}),[s,l,u,c]),p=n(a,h[0],h[1]);return i((function(){d.hasValue=!0,d.value=p}),[p]),o(p),p},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Lge);var Bge=_ge.exports;const Rge="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;class zge{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach((e=>e()))},a=this.editor;return a.on("transaction",e),()=>{a.off("transaction",e)}}}}const Dge="production"!==process.env.NODE_ENV,Oge="undefined"==typeof window,Kge=Oge||Boolean("undefined"!=typeof window&&window.next);class Hge{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((e=>e()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return Oge||Kge?null:this.createEditor();if(this.options.current.immediatelyRender&&Oge&&Dge)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(a,...e)},onBlur:(...e)=>{var a,n;return null===(n=(a=this.options.current).onBlur)||void 0===n?void 0:n.call(a,...e)},onCreate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onCreate)||void 0===n?void 0:n.call(a,...e)},onDestroy:(...e)=>{var a,n;return null===(n=(a=this.options.current).onDestroy)||void 0===n?void 0:n.call(a,...e)},onFocus:(...e)=>{var a,n;return null===(n=(a=this.options.current).onFocus)||void 0===n?void 0:n.call(a,...e)},onSelectionUpdate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(a,...e)},onTransaction:(...e)=>{var a,n;return null===(n=(a=this.options.current).onTransaction)||void 0===n?void 0:n.call(a,...e)},onUpdate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onUpdate)||void 0===n?void 0:n.call(a,...e)},onContentError:(...e)=>{var a,n;return null===(n=(a=this.options.current).onContentError)||void 0===n?void 0:n.call(a,...e)},onDrop:(...e)=>{var a,n;return null===(n=(a=this.options.current).onDrop)||void 0===n?void 0:n.call(a,...e)},onPaste:(...e)=>{var a,n;return null===(n=(a=this.options.current).onPaste)||void 0===n?void 0:n.call(a,...e)}};return new lge(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,a){return Object.keys(e).every((n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&a.extensions?e.extensions.length===a.extensions.length&&e.extensions.every(((e,n)=>{var t;return e===(null===(t=a.extensions)||void 0===t?void 0:t[n])})):e[n]===a[n])))}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?Hge.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=e);if(this.previousDeps.length===e.length&&this.previousDeps.every(((a,n)=>a===e[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,a=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===e?a&&a.setOptions(this.options.current):a&&!a.isDestroyed&&(a.destroy(),this.instanceId===e&&this.setEditor(null))}),1)}}function Ige(e={},n=[]){const t=a.useRef(e);t.current=e;const[i]=a.useState((()=>new Hge(t))),r=Sge.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return a.useDebugValue(r),a.useEffect(i.onRender(n)),function(e){var n;const[t]=a.useState((()=>new zge(e.editor))),i=Bge.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,null!==(n=e.equalityFn)&&void 0!==n?n:Ege);Rge((()=>t.watch(e.editor)),[e.editor,t]),a.useDebugValue(i)}({editor:r,selector:({transactionNumber:a})=>!1===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===a?0:a+1}),r}a.createContext({editor:null});const Gge=a.createContext({onDragStart:void 0}),Fge=a.forwardRef(((e,n)=>{const{onDragStart:t}=a.useContext(Gge);return a.createElement(e.as||"div",{...e,ref:n,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...e.style}})}));function Vge(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function Jge(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}class Uge{constructor(e,{editor:a,props:n={},as:i="div",className:r=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=a,this.props=n,this.element=document.createElement(i),this.element.classList.add("react-renderer"),r&&this.element.classList.add(...r.split(" ")),this.editor.isInitialized?t.flushSync((()=>{this.render()})):this.render()}render(){var e;const n=this.component,t=this.props,i=this.editor,r=function(){try{if(a.version)return parseInt(a.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(Vge(e))return!0;if(Jge(e))return!0;if(function(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.memo)"!==e.$$typeof.toString()&&"react.memo"!==e.$$typeof.description)}(e)){const a=e.type;if(a)return Vge(a)||Jge(a)}return!1}(n),s={...t};!s.ref||r||o||delete s.ref,s.ref||!r&&!o||(s.ref=e=>{this.ref=e}),this.reactElement=a.createElement(n,{...s}),null===(e=null==i?void 0:i.contentComponent)||void 0===e||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const a=this.editor;null===(e=null==a?void 0:a.contentComponent)||void 0===e||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach((a=>{this.element.setAttribute(a,e[a])}))}}class Wge extends hge{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:a.createRef()};if(!this.component.displayName){this.component.displayName=(e=>e.charAt(0).toUpperCase()+e.substring(1))(this.extension.name)}const n={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&e.appendChild(this.contentDOMElement)}},t=this.component,i=a.memo((e=>a.createElement(Gge.Provider,{value:n},a.createElement(t,e))));i.displayName="ReactNodeView",this.contentDOMElement=this.node.isLeaf?null:this.options.contentDOMElementTag?document.createElement(this.options.contentDOMElementTag):document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let r=this.node.isInline?"span":"div";this.options.as&&(r=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Uge(i,{editor:this.editor,props:e,as:r,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null===(e=this.renderer.element.firstElementChild)||void 0===e?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:a}=this.editor.state.selection,n=this.getPos();if("number"==typeof n)if(e<=n&&a>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,a,n){const t=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,r=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=a,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:r,newNode:e,newDecorations:a,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>t({node:e,decorations:a,innerDecorations:n})})}return e===this.node&&this.decorations===a&&this.innerDecorations===n||(this.node=e,this.decorations=a,this.innerDecorations=n,t({node:e,decorations:a,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){const a=Xhe(this.node,this.editor.extensionManager.attributes);e=this.options.attrs({node:this.node,HTMLAttributes:a})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function qge(e,a){return n=>n.editor.contentComponent?new Wge(e,n,a):{}}const Zge=/^\s*>\s$/,$ge=mge.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return["blockquote",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[dge({find:Zge,type:this.type})]}}),Yge=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Qge=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Xge=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,efe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,afe=hpe.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[uge({find:Yge,type:this.type}),uge({find:Xge,type:this.type})]},addPasteRules(){return[pge({find:Qge,type:this.type}),pge({find:efe,type:this.type})]}}),nfe="textStyle",tfe=/^\s*([-+*])\s$/,ife=mge.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(nfe)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=dge({find:tfe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=dge({find:tfe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(nfe),editor:this.editor})),[e]}}),rfe=/(^|[^`])`([^`]+)`(?!`)/,ofe=/(^|[^`])`([^`]+)`(?!`)/g,sfe=hpe.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[uge({find:rfe,type:this.type})]},addPasteRules(){return[pge({find:ofe,type:this.type})]}}),lfe=/^```([a-z]+)?[\s\n]$/,ufe=/^~~~([a-z]+)?[\s\n]$/,cfe=mge.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var a;const{languageClassPrefix:n}=this.options,t=[...(null===(a=e.firstElementChild)||void 0===a?void 0:a.classList)||[]].filter((e=>e.startsWith(n))).map((e=>e.replace(n,"")))[0];return t||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:a}){return["pre",Qhe(this.options.HTMLAttributes,a),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:a})=>a.setNode(this.name,e),toggleCodeBlock:e=>({commands:a})=>a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:a}=this.editor.state.selection;return!(!e||a.parent.type.name!==this.name)&&(!(!(1===a.pos)&&a.parent.textContent.length)&&this.editor.commands.clearNodes())},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:a}=e,{selection:n}=a,{$from:t,empty:i}=n;if(!i||t.parent.type!==this.type)return!1;const r=t.parentOffset===t.parent.nodeSize-2,o=t.parent.textContent.endsWith("\n\n");return!(!r||!o)&&e.chain().command((({tr:e})=>(e.delete(t.pos-2,t.pos),!0))).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:a}=e,{selection:n,doc:t}=a,{$from:i,empty:r}=n;if(!r||i.parent.type!==this.type)return!1;if(!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();if(void 0===o)return!1;return t.nodeAt(o)?e.commands.command((({tr:e})=>(e.setSelection(Cue.near(t.resolve(o))),!0))):e.commands.exitCode()}}},addInputRules(){return[cge({find:lfe,type:this.type,getAttributes:e=>({language:e[1]})}),cge({find:ufe,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Vue({key:new Wue("codeBlockVSCodeHandler"),props:{handlePaste:(e,a)=>{if(!a.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=a.clipboardData.getData("text/plain"),t=a.clipboardData.getData("vscode-editor-data"),i=t?JSON.parse(t):void 0,r=null==i?void 0:i.mode;if(!n||!r)return!1;const{tr:o,schema:s}=e.state,l=s.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:r},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(Eue.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),dfe=mge.create({name:"doc",topNode:!0,content:"block+"});function mfe(e={}){return new Vue({view:a=>new hfe(a,e)})}class hfe{constructor(e,a){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=a.width)&&void 0!==n?n:1,this.color=!1===a.color?void 0:a.color||"black",this.class=a.class,this.handlers=["dragover","dragend","drop","dragleave"].map((a=>{let n=e=>{this[a](e)};return e.dom.addEventListener(a,n),{name:a,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:a})=>this.editorView.dom.removeEventListener(e,a)))}update(e,a){null!=this.cursorPos&&a.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,a=this.editorView.state.doc.resolve(this.cursorPos),n=!a.parent.inlineContent,t=this.editorView.dom,i=t.getBoundingClientRect(),r=i.width/t.offsetWidth,o=i.height/t.offsetHeight;if(n){let n=a.nodeBefore,t=a.nodeAfter;if(n||t){let a=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(a){let i=a.getBoundingClientRect(),r=n?i.bottom:i.top;n&&t&&(r=(r+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;e={left:i.left,right:i.right,top:r-s,bottom:r+s}}}}if(!e){let a=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*r;e={left:a.left-n,right:a.left+n,top:a.top,bottom:a.bottom}}let s,l,u=this.editorView.dom.offsetParent;if(this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!u||u==document.body&&"static"==getComputedStyle(u).position)s=-pageXOffset,l=-pageYOffset;else{let e=u.getBoundingClientRect();s=e.left-u.scrollLeft*(e.width/u.offsetWidth),l=e.top-u.scrollTop*(e.height/u.offsetHeight)}this.element.style.left=(e.left-s)/r+"px",this.element.style.top=(e.top-l)/o+"px",this.element.style.width=(e.right-e.left)/r+"px",this.element.style.height=(e.bottom-e.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let a=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=a&&a.inside>=0&&this.editorView.state.doc.nodeAt(a.inside),t=n&&n.type.spec.disableDropCursor,i="function"==typeof t?t(this.editorView,a,e):t;if(a&&!i){let e=a.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=uue(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=a&&(e=a)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const pfe=kpe.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[mfe(this.options)]}});class gfe extends Cue{constructor(e){super(e,e)}map(e,a){let n=e.resolve(a.map(this.head));return gfe.valid(n)?new gfe(n):Cue.near(n)}content(){return Rse.empty}eq(e){return e instanceof gfe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,a){if("number"!=typeof a.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new gfe(e.resolve(a.pos))}getBookmark(){return new ffe(this.anchor)}static valid(e){let a=e.parent;if(a.isTextblock||!function(e){for(let a=e.depth;a>=0;a--){let n=e.index(a),t=e.node(a);if(0!=n)for(let e=t.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(t.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let a=e.depth;a>=0;a--){let n=e.indexAfter(a),t=e.node(a);if(n!=t.childCount)for(let e=t.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(t.type.spec.isolating)return!0}return!0}(e))return!1;let n=a.type.spec.allowGapCursor;if(null!=n)return n;let t=a.contentMatchAt(e.index()).defaultType;return t&&t.isTextblock}static findGapCursorFrom(e,a,n=!1){e:for(;;){if(!n&&gfe.valid(e))return e;let t=e.pos,i=null;for(let n=e.depth;;n--){let r=e.node(n);if(a>0?e.indexAfter(n)<r.childCount:e.index(n)>0){i=r.child(a>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;t+=a;let o=e.doc.resolve(t);if(gfe.valid(o))return o}for(;;){let r=a>0?i.firstChild:i.lastChild;if(!r){if(i.isAtom&&!i.isText&&!Pue.isSelectable(i)){e=e.doc.resolve(t+i.nodeSize*a),n=!1;continue e}break}i=r,t+=a;let o=e.doc.resolve(t);if(gfe.valid(o))return o}return null}}}gfe.prototype.visible=!1,gfe.findFrom=gfe.findGapCursorFrom,Cue.jsonID("gapcursor",gfe);class ffe{constructor(e){this.pos=e}map(e){return new ffe(e.map(this.pos))}resolve(e){let a=e.resolve(this.pos);return gfe.valid(a)?new gfe(a):Cue.near(a)}}const vfe=bhe({ArrowLeft:yfe("horiz",-1),ArrowRight:yfe("horiz",1),ArrowUp:yfe("vert",-1),ArrowDown:yfe("vert",1)});function yfe(e,a){const n="vert"==e?a>0?"down":"up":a>0?"right":"left";return function(e,t,i){let r=e.selection,o=a>0?r.$to:r.$from,s=r.empty;if(r instanceof Eue){if(!i.endOfTextblock(n)||0==o.depth)return!1;s=!1,o=e.doc.resolve(a>0?o.after():o.before())}let l=gfe.findGapCursorFrom(o,a,s);return!!l&&(t&&t(e.tr.setSelection(new gfe(l))),!0)}}function kfe(e,a,n){if(!e||!e.editable)return!1;let t=e.state.doc.resolve(a);if(!gfe.valid(t))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Pue.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new gfe(t))),!0)}function bfe(e,a){if("insertCompositionText"!=a.inputType||!(e.state.selection instanceof gfe))return!1;let{$from:n}=e.state.selection,t=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!t)return!1;let i=Ese.empty;for(let o=t.length-1;o>=0;o--)i=Ese.from(t[o].createAndFill(null,i));let r=e.state.tr.replace(n.pos,n.pos,new Rse(i,0,0));return r.setSelection(Eue.near(r.doc.resolve(n.pos+1))),e.dispatch(r),!1}function Sfe(e){if(!(e.selection instanceof gfe))return null;let a=document.createElement("div");return a.className="ProseMirror-gapcursor",Lme.create(e.doc,[_me.widget(e.selection.head,a,{key:"gapcursor"})])}const Afe=kpe.create({name:"gapCursor",addProseMirrorPlugins:()=>[new Vue({props:{decorations:Sfe,createSelectionBetween:(e,a,n)=>a.pos==n.pos&&gfe.valid(n)?new gfe(n):null,handleClick:kfe,handleKeyDown:vfe,handleDOMEvents:{beforeinput:bfe}}})],extendNodeSchema(e){var a;return{allowGapCursor:null!==(a=ape(qhe(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==a?a:null}}}),wfe=mge.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",Qhe(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:a,state:n,editor:t})=>e.first([()=>e.exitCode(),()=>e.command((()=>{const{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:r}=this.options,{splittableMarks:o}=t.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return a().insertContent({type:this.name}).command((({tr:e,dispatch:a})=>{if(a&&s&&r){const a=s.filter((e=>o.includes(e.type.name)));e.ensureMarks(a)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Mfe=mge.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((e=>({tag:`h${e}`,attrs:{level:e}})))},renderHTML({node:e,HTMLAttributes:a}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Qhe(this.options.HTMLAttributes,a),0]},addCommands(){return{setHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.setNode(this.name,e),toggleHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce(((e,a)=>({...e,[`Mod-Alt-${a}`]:()=>this.editor.commands.toggleHeading({level:a})})),{})},addInputRules(){return this.options.levels.map((e=>cge({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}})))}});var Cfe=200,Tfe=function(){};Tfe.prototype.append=function(e){return e.length?(e=Tfe.from(e),!this.length&&e||e.length<Cfe&&this.leafAppend(e)||this.length<Cfe&&e.leafPrepend(this)||this.appendInner(e)):this},Tfe.prototype.prepend=function(e){return e.length?Tfe.from(e).append(this):this},Tfe.prototype.appendInner=function(e){return new Nfe(this,e)},Tfe.prototype.slice=function(e,a){return void 0===e&&(e=0),void 0===a&&(a=this.length),e>=a?Tfe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,a))},Tfe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Tfe.prototype.forEach=function(e,a,n){void 0===a&&(a=0),void 0===n&&(n=this.length),a<=n?this.forEachInner(e,a,n,0):this.forEachInvertedInner(e,a,n,0)},Tfe.prototype.map=function(e,a,n){void 0===a&&(a=0),void 0===n&&(n=this.length);var t=[];return this.forEach((function(a,n){return t.push(e(a,n))}),a,n),t},Tfe.from=function(e){return e instanceof Tfe?e:e&&e.length?new xfe(e):Tfe.empty};var xfe=function(e){function a(a){e.call(this),this.values=a}e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a;var n={length:{configurable:!0},depth:{configurable:!0}};return a.prototype.flatten=function(){return this.values},a.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new a(this.values.slice(e,n))},a.prototype.getInner=function(e){return this.values[e]},a.prototype.forEachInner=function(e,a,n,t){for(var i=a;i<n;i++)if(!1===e(this.values[i],t+i))return!1},a.prototype.forEachInvertedInner=function(e,a,n,t){for(var i=a-1;i>=n;i--)if(!1===e(this.values[i],t+i))return!1},a.prototype.leafAppend=function(e){if(this.length+e.length<=Cfe)return new a(this.values.concat(e.flatten()))},a.prototype.leafPrepend=function(e){if(this.length+e.length<=Cfe)return new a(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(a.prototype,n),a}(Tfe);Tfe.empty=new xfe([]);var Nfe=function(e){function a(a,n){e.call(this),this.left=a,this.right=n,this.length=a.length+n.length,this.depth=Math.max(a.depth,n.depth)+1}return e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a,a.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},a.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},a.prototype.forEachInner=function(e,a,n,t){var i=this.left.length;return!(a<i&&!1===this.left.forEachInner(e,a,Math.min(n,i),t))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(a-i,0),Math.min(this.length,n)-i,t+i))&&void 0)},a.prototype.forEachInvertedInner=function(e,a,n,t){var i=this.left.length;return!(a>i&&!1===this.right.forEachInvertedInner(e,a-i,Math.max(n,i)-i,t+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(a,i),n,t))&&void 0)},a.prototype.sliceInner=function(e,a){if(0==e&&a==this.length)return this;var n=this.left.length;return a<=n?this.left.slice(e,a):e>=n?this.right.slice(e-n,a-n):this.left.slice(e,n).append(this.right.slice(0,a-n))},a.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new a(this.left,n)},a.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new a(n,this.right)},a.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new a(this.left,new a(this.right,e)):new a(this,e)},a}(Tfe);class Efe{constructor(e,a){this.items=e,this.eventCount=a}popEvent(e,a){if(0==this.eventCount)return null;let n,t,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}a&&(n=this.remapping(i,this.items.length),t=n.maps.length);let r,o,s=e.tr,l=[],u=[];return this.items.forEach(((e,a)=>{if(!e.step)return n||(n=this.remapping(i,a+1),t=n.maps.length),t--,void u.push(e);if(n){u.push(new _fe(e.map));let a,i=e.step.map(n.slice(t));i&&s.maybeStep(i).doc&&(a=s.mapping.maps[s.mapping.maps.length-1],l.push(new _fe(a,void 0,void 0,l.length+u.length))),t--,a&&n.appendMap(a,t)}else s.maybeStep(e.step);return e.selection?(r=n?e.selection.map(n.slice(t)):e.selection,o=new Efe(this.items.slice(0,i).append(u.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:s,selection:r}}addTransform(e,a,n,t){let i=[],r=this.eventCount,o=this.items,s=!t&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let n,l=e.steps[u].invert(e.docs[u]),c=new _fe(e.mapping.maps[u],l,a);(n=s&&s.merge(c))&&(c=n,u?i.pop():o=o.slice(0,o.length-1)),i.push(c),a&&(r++,a=void 0),t||(s=c)}let l=r-n.depth;return l>jfe&&(o=function(e,a){let n;return e.forEach(((e,t)=>{if(e.selection&&0==a--)return n=t,!1})),e.slice(n)}(o,l),r-=l),new Efe(o.append(i),r)}remapping(e,a){let n=new Hle;return this.items.forEach(((a,t)=>{n.appendMap(a.map,null!=a.mirrorOffset&&t-a.mirrorOffset>=e?n.maps.length-a.mirrorOffset:void 0)}),e,a),n}addMaps(e){return 0==this.eventCount?this:new Efe(this.items.append(e.map((e=>new _fe(e)))),this.eventCount)}rebased(e,a){if(!this.eventCount)return this;let n=[],t=Math.max(0,this.items.length-a),i=e.mapping,r=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),t);let s=a;this.items.forEach((a=>{let t=i.getMirror(--s);if(null==t)return;r=Math.min(r,t);let l=i.maps[t];if(a.step){let r=e.steps[t].invert(e.docs[t]),u=a.selection&&a.selection.map(i.slice(s+1,t));u&&o++,n.push(new _fe(l,r,u))}else n.push(new _fe(l))}),t);let l=[];for(let d=a;d<r;d++)l.push(new _fe(i.maps[d]));let u=this.items.slice(0,t).append(l).append(n),c=new Efe(u,o);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach((a=>{a.step||e++})),e}compress(e=this.items.length){let a=this.remapping(0,e),n=a.maps.length,t=[],i=0;return this.items.forEach(((r,o)=>{if(o>=e)t.push(r),r.selection&&i++;else if(r.step){let e=r.step.map(a.slice(n)),o=e&&e.getMap();if(n--,o&&a.appendMap(o,n),e){let s=r.selection&&r.selection.map(a.slice(n));s&&i++;let l,u=new _fe(o.invert(),e,s),c=t.length-1;(l=t.length&&t[c].merge(u))?t[c]=l:t.push(u)}}else r.map&&n--}),this.items.length,0),new Efe(Tfe.from(t.reverse()),i)}}Efe.empty=new Efe(Tfe.empty,0);let _fe=class e{constructor(e,a,n,t){this.map=e,this.step=a,this.selection=n,this.mirrorOffset=t}merge(a){if(this.step&&a.step&&!a.selection){let n=a.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}};class Pfe{constructor(e,a,n,t,i){this.done=e,this.undone=a,this.prevRanges=n,this.prevTime=t,this.prevComposition=i}}const jfe=20;function Lfe(e){let a=[];for(let n=e.length-1;n>=0&&0==a.length;n--)e[n].forEach(((e,n,t,i)=>a.push(t,i)));return a}function Bfe(e,a){if(!e)return null;let n=[];for(let t=0;t<e.length;t+=2){let i=a.map(e[t],1),r=a.map(e[t+1],-1);i<=r&&n.push(i,r)}return n}let Rfe=!1,zfe=null;function Dfe(e){let a=e.plugins;if(zfe!=a){Rfe=!1,zfe=a;for(let e=0;e<a.length;e++)if(a[e].spec.historyPreserveItems){Rfe=!0;break}}return Rfe}const Ofe=new Wue("history"),Kfe=new Wue("closeHistory");function Hfe(e={}){return new Vue({key:Ofe,state:{init:()=>new Pfe(Efe.empty,Efe.empty,null,0,-1),apply:(a,n,t)=>function(e,a,n,t){let i,r=n.getMeta(Ofe);if(r)return r.historyState;n.getMeta(Kfe)&&(e=new Pfe(e.done,e.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(Ofe))return o.getMeta(Ofe).redo?new Pfe(e.done.addTransform(n,void 0,t,Dfe(a)),e.undone,Lfe(n.mapping.maps),e.prevTime,e.prevComposition):new Pfe(e.done,e.undone.addTransform(n,void 0,t,Dfe(a)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new Pfe(e.done.rebased(n,i),e.undone.rebased(n,i),Bfe(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Pfe(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Bfe(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let i=n.getMeta("composition"),r=0==e.prevTime||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-t.newGroupDelay||!function(e,a){if(!a)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,t)=>{for(let i=0;i<a.length;i+=2)e<=a[i+1]&&t>=a[i]&&(n=!0)})),n}(n,e.prevRanges)),s=o?Bfe(e.prevRanges,n.mapping):Lfe(n.mapping.maps);return new Pfe(e.done.addTransform(n,r?a.selection.getBookmark():void 0,t,Dfe(a)),Efe.empty,s,n.time,null==i?e.prevComposition:i)}}(n,t,a,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,a){let n=a.inputType,t="historyUndo"==n?Gfe:"historyRedo"==n?Ffe:null;return!!t&&(a.preventDefault(),t(e.state,e.dispatch))}}}})}function Ife(e,a){return(n,t)=>{let i=Ofe.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(t){let r=function(e,a,n){let t=Dfe(a),i=Ofe.get(a).spec.config,r=(n?e.undone:e.done).popEvent(a,t);if(!r)return null;let o=r.selection.resolve(r.transform.doc),s=(n?e.done:e.undone).addTransform(r.transform,a.selection.getBookmark(),i,t),l=new Pfe(n?s:r.remaining,n?r.remaining:s,null,0,-1);return r.transform.setSelection(o).setMeta(Ofe,{redo:n,historyState:l})}(i,n,e);r&&t(a?r.scrollIntoView():r)}return!0}}const Gfe=Ife(!1,!0),Ffe=Ife(!0,!0),Vfe=kpe.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:a})=>Gfe(e,a),redo:()=>({state:e,dispatch:a})=>Ffe(e,a)}),addProseMirrorPlugins(){return[Hfe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Jfe=mge.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",Qhe(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:a})=>{const{selection:n}=a,{$from:t,$to:i}=n,r=e();return 0===t.parentOffset?r.insertContentAt({from:Math.max(t.pos-1,0),to:i.pos},{type:this.name}):n instanceof Pue?r.insertContentAt(i.pos,{type:this.name}):r.insertContent({type:this.name}),r.command((({tr:e,dispatch:a})=>{var n;if(a){const{$to:a}=e.selection,t=a.end();if(a.nodeAfter)e.setSelection(a.nodeAfter.isTextblock?Eue.create(e.doc,a.pos+1):a.nodeAfter.isBlock?Pue.create(e.doc,a.pos):Eue.create(e.doc,a.pos));else{const i=null===(n=a.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();i&&(e.insert(t,i),e.setSelection(Eue.create(e.doc,t+1)))}e.scrollIntoView()}return!0})).run()}}},addInputRules(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new lpe({find:e.find,handler:({state:a,range:n,match:t})=>{const i=ape(e.getAttributes,void 0,t)||{},{tr:r}=a,o=n.from;let s=n.to;const l=e.type.create(i);if(t[1]){let e=o+t[0].lastIndexOf(t[1]);e>s?e=s:s=e+t[1].length,r.insertText(t[0][t[0].length-1],o+t[0].length-1),r.replaceWith(e,s,l)}else t[0]&&r.insert(e.type.isInline?o:o-1,e.type.create(i)).delete(r.mapping.map(o),r.mapping.map(s));r.scrollIntoView()}}))];var e}}),Ufe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Wfe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,qfe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Zfe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$fe=hpe.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[uge({find:Ufe,type:this.type}),uge({find:qfe,type:this.type})]},addPasteRules(){return[pge({find:Wfe,type:this.type}),pge({find:Zfe,type:this.type})]}}),Yfe=mge.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",Qhe(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Qfe="textStyle",Xfe=/^(\d+)\.\s$/,eve=mge.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){const{start:a,...n}=e;return 1===a?["ol",Qhe(this.options.HTMLAttributes,n),0]:["ol",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Qfe)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=dge({find:Xfe,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=dge({find:Xfe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Qfe)}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1],editor:this.editor})),[e]}}),ave=mge.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),nve=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,tve=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ive=hpe.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[uge({find:nve,type:this.type})]},addPasteRules(){return[pge({find:tve,type:this.type})]}}),rve=mge.create({name:"text",group:"inline"}),ove=kpe.create({name:"starterKit",addExtensions(){const e=[];return!1!==this.options.bold&&e.push(afe.configure(this.options.bold)),!1!==this.options.blockquote&&e.push($ge.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(ife.configure(this.options.bulletList)),!1!==this.options.code&&e.push(sfe.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(cfe.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(dfe.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(pfe.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(Afe.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(wfe.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(Mfe.configure(this.options.heading)),!1!==this.options.history&&e.push(Vfe.configure(this.options.history)),!1!==this.options.horizontalRule&&e.push(Jfe.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push($fe.configure(this.options.italic)),!1!==this.options.listItem&&e.push(Yfe.configure(this.options.listItem)),!1!==this.options.orderedList&&e.push(eve.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(ave.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(ive.configure(this.options.strike)),!1!==this.options.text&&e.push(rve.configure(this.options.text)),e}}),sve=e=>n.jsx(Fge,{as:"span",className:"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200",children:e.node.attrs.displayName}),lve=mge.create({name:"mergeField",group:"inline",inline:!0,atom:!0,addAttributes:()=>({templateName:{default:null,parseHTML:e=>e.getAttribute("data-template-name")},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name")}}),parseHTML:()=>[{tag:"span[data-merge-field]"}],renderHTML:({HTMLAttributes:e})=>["span",Qhe(e,{"data-merge-field":"true"})],renderText:({node:e})=>e.attrs.templateName,addNodeView:()=>qge(sve)}),uve=({value:e,onChange:t,className:i="",mergeFieldsResponse:r,placeholder:o="Enter text",ariaLabel:s="Insert merge field",icon:l="MergeField"})=>{const[u,c]=a.useState(!1),d=a.useRef(null),m=a.useRef(null),h=a.useMemo((()=>r?.mergeFields?.flatMap((e=>e.entries))??[]),[r]),p=a.useCallback((e=>{if(!e)return"";return e.replace(/\{\{.*?\}\}/g,(e=>{const a=h.find((a=>a.value===e));return a?`<span class="inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200" data-merge-field="true" data-template-name="${a.value}" data-display-name="${a.label}">${a.label}</span>`:e}))}),[h]),g=Ige({extensions:[ove,lve],content:"",editorProps:{attributes:{class:`min-h-[40px] px-3 py-2 border border-input bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50 rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent resize-none prose prose-sm max-w-none ${i}`,placeholder:o}},onUpdate:({editor:e})=>{const a=e.getText();t(a)}});a.useEffect((()=>{if(g&&e){if(g.getText()!==e){const a=p(e);g.commands.setContent(a,!1)}}}),[g,e,p]);const f=a.useCallback((e=>{if(g){const a=h.find((a=>a.value===e));a&&g.chain().focus().insertContent({type:"mergeField",attrs:{templateName:a.value,displayName:a.label}}).run()}c(!1)}),[g,h]);if(a.useEffect((()=>{if(u)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){const a=e.target;m.current&&!m.current.contains(a)&&d.current&&!d.current.contains(a)&&c(!1)}}),[u]),!g)return n.jsx("div",{children:"Loading editor..."});const v=b3[l]||b3.MergeField;return n.jsx("div",{className:"relative",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:"flex-1",children:n.jsx(Tge,{editor:g})}),r&&n.jsxs(n.Fragment,{children:[n.jsx(f3,{ref:d,type:"button",variant:"ghost",size:"icon",className:"ml-2 h-10 w-7 p-0 rounded-md border border-input shadow-sm hover:bg-accent/60 focus:bg-accent/80 transition-colors","aria-label":s,onClick:()=>c((e=>!e)),children:n.jsx(v,{className:"w-4 h-4"})}),u&&n.jsx("div",{ref:m,className:"absolute z-50 mt-2 right-0 w-56 bg-white border border-gray-200 rounded-lg shadow-lg p-1",style:{top:"100%"},children:0===h.length?n.jsx("div",{className:"px-4 py-2 text-muted-foreground text-sm",children:"No merge fields found"}):n.jsx("ul",{className:"py-1",children:h.map((e=>n.jsx("li",{children:n.jsx("button",{className:"w-full text-left px-4 py-2 hover:bg-accent/40 rounded text-sm transition-colors",onClick:()=>f(e.value),type:"button",children:e.label})},e.value)))})})]})]})})},cve=()=>{const[e,t]=a.useState("desktop"),i=a.useRef(null),r=a.useRef(null);return a.useEffect((()=>{const e=()=>t("desktop"),a=()=>t("mobile"),n=i.current,o=r.current;return n&&n.addEventListener("click",e),o&&o.addEventListener("click",a),()=>{n&&n.removeEventListener("click",e),o&&o.removeEventListener("click",a)}}),[]),n.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5 shadow-inner border w-fit",children:[n.jsxs(f3,{ref:i,type:"button","aria-pressed":"desktop"===e,"aria-label":"Show desktop preview",className:"desktop-view-button toggle-desktop-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("desktop"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["desktop"===e&&n.jsx(R2.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),n.jsx("span",{className:"relative z-10 flex items-center justify-center",children:n.jsx(b3.DesktopIcon,{className:"w-4 h-4"})})]}),n.jsxs(f3,{ref:r,type:"button","aria-pressed":"mobile"===e,"aria-label":"Show mobile preview",className:"mobile-view-button toggle-mobile-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("mobile"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["mobile"===e&&n.jsx(R2.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),n.jsx("span",{className:"relative z-10 flex items-center justify-center",children:n.jsx(b3.MobileIcon,{className:"w-4 h-4"})})]})]})};function dve(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function mve(e){const a=hve(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(gve);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function hve(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?function(...e){return a=>{let n=!1;const t=e.map((e=>{const t=dve(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():dve(e[a],null)}}}}(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var pve=Symbol("radix.slottable");function gve(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===pve}var fve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=mve(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),vve=r.forwardRef(((e,a)=>n.jsx(fve.label,{...e,ref:a,onMouseDown:a=>{a.target.closest("button, input, select, textarea")||(e.onMouseDown?.(a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}})));vve.displayName="Label";var yve=vve;const kve=XL("text-foreground text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),bve=r.forwardRef((({className:e,...a},t)=>n.jsx(yve,{ref:t,className:mz(kve(),e),...a})));function Sve(e,[a,n]){return Math.min(n,Math.max(a,e))}function Ave(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}function wve(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},Mve(i,...a)]}function Mve(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function Cve(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function Tve(...e){return a=>{let n=!1;const t=e.map((e=>{const t=Cve(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():Cve(e[a],null)}}}}function xve(...e){return r.useCallback(Tve(...e),e)}function Nve(e){const a=Eve(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Pve);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function Eve(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?Tve(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}bve.displayName=yve.displayName;var _ve=Symbol("radix.slottable");function Pve(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===_ve}var jve=r.createContext(void 0);var Lve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=Nve(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});function Bve(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}var Rve,zve="dismissableLayer.update",Dve="dismissableLayer.pointerDownOutside",Ove="dismissableLayer.focusOutside",Kve=r.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Hve=r.forwardRef(((e,a)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...c}=e,d=r.useContext(Kve),[m,h]=r.useState(null),p=m?.ownerDocument??globalThis?.document,[,g]=r.useState({}),f=xve(a,(e=>h(e))),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),k=v.indexOf(y),b=m?v.indexOf(m):-1,S=d.layersWithOutsidePointerEventsDisabled.size>0,A=b>=k,w=function(e,a=globalThis?.document){const n=Bve(e),t=r.useRef(!1),i=r.useRef((()=>{}));return r.useEffect((()=>{const e=e=>{if(e.target&&!t.current){let t=function(){Gve(Dve,n,r,{discrete:!0})};const r={originalEvent:e};"touch"===e.pointerType?(a.removeEventListener("click",i.current),i.current=t,a.addEventListener("click",i.current,{once:!0})):t()}else a.removeEventListener("click",i.current);t.current=!1},r=window.setTimeout((()=>{a.addEventListener("pointerdown",e)}),0);return()=>{window.clearTimeout(r),a.removeEventListener("pointerdown",e),a.removeEventListener("click",i.current)}}),[a,n]),{onPointerDownCapture:()=>t.current=!0}}((e=>{const a=e.target,n=[...d.branches].some((e=>e.contains(a)));A&&!n&&(o?.(e),l?.(e),e.defaultPrevented||u?.())}),p),M=function(e,a=globalThis?.document){const n=Bve(e),t=r.useRef(!1);return r.useEffect((()=>{const e=e=>{if(e.target&&!t.current){Gve(Ove,n,{originalEvent:e},{discrete:!1})}};return a.addEventListener("focusin",e),()=>a.removeEventListener("focusin",e)}),[a,n]),{onFocusCapture:()=>t.current=!0,onBlurCapture:()=>t.current=!1}}((e=>{const a=e.target;[...d.branches].some((e=>e.contains(a)))||(s?.(e),l?.(e),e.defaultPrevented||u?.())}),p);return function(e,a=globalThis?.document){const n=Bve(e);r.useEffect((()=>{const e=e=>{"Escape"===e.key&&n(e)};return a.addEventListener("keydown",e,{capture:!0}),()=>a.removeEventListener("keydown",e,{capture:!0})}),[n,a])}((e=>{b===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))}),p),r.useEffect((()=>{if(m)return t&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(Rve=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),Ive(),()=>{t&&1===d.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Rve)}}),[m,p,t,d]),r.useEffect((()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),Ive())}),[m,d]),r.useEffect((()=>{const e=()=>g({});return document.addEventListener(zve,e),()=>document.removeEventListener(zve,e)}),[]),n.jsx(Lve.div,{...c,ref:f,style:{pointerEvents:S?A?"auto":"none":void 0,...e.style},onFocusCapture:Ave(e.onFocusCapture,M.onFocusCapture),onBlurCapture:Ave(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:Ave(e.onPointerDownCapture,w.onPointerDownCapture)})}));Hve.displayName="DismissableLayer";function Ive(){const e=new CustomEvent(zve);document.dispatchEvent(e)}function Gve(e,a,n,{discrete:t}){const i=n.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});a&&i.addEventListener(e,a,{once:!0}),t?function(e,a){e&&o.flushSync((()=>e.dispatchEvent(a)))}(i,r):i.dispatchEvent(r)}r.forwardRef(((e,a)=>{const t=r.useContext(Kve),i=r.useRef(null),o=xve(a,i);return r.useEffect((()=>{const e=i.current;if(e)return t.branches.add(e),()=>{t.branches.delete(e)}}),[t.branches]),n.jsx(Lve.div,{...e,ref:o})})).displayName="DismissableLayerBranch";var Fve=0;function Vve(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Jve="focusScope.autoFocusOnMount",Uve="focusScope.autoFocusOnUnmount",Wve={bubbles:!1,cancelable:!0},qve=r.forwardRef(((e,a)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...l}=e,[u,c]=r.useState(null),d=Bve(o),m=Bve(s),h=r.useRef(null),p=xve(a,(e=>c(e))),g=r.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;r.useEffect((()=>{if(i){let e=function(e){if(g.paused||!u)return;const a=e.target;u.contains(a)?h.current=a:Qve(h.current,{select:!0})},a=function(e){if(g.paused||!u)return;const a=e.relatedTarget;null!==a&&(u.contains(a)||Qve(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const a of e)a.removedNodes.length>0&&Qve(u)};document.addEventListener("focusin",e),document.addEventListener("focusout",a);const t=new MutationObserver(n);return u&&t.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",a),t.disconnect()}}}),[i,u,g.paused]),r.useEffect((()=>{if(u){Xve.add(g);const a=document.activeElement;if(!u.contains(a)){const n=new CustomEvent(Jve,Wve);u.addEventListener(Jve,d),u.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:a=!1}={}){const n=document.activeElement;for(const t of e)if(Qve(t,{select:a}),document.activeElement!==n)return}((e=Zve(u),e.filter((e=>"A"!==e.tagName))),{select:!0}),document.activeElement===a&&Qve(u))}return()=>{u.removeEventListener(Jve,d),setTimeout((()=>{const e=new CustomEvent(Uve,Wve);u.addEventListener(Uve,m),u.dispatchEvent(e),e.defaultPrevented||Qve(a??document.body,{select:!0}),u.removeEventListener(Uve,m),Xve.remove(g)}),0)}}var e}),[u,d,m,g]);const f=r.useCallback((e=>{if(!t&&!i)return;if(g.paused)return;const a=document.activeElement;if("Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&a){const n=e.currentTarget,[i,r]=function(e){const a=Zve(e),n=$ve(a,e),t=$ve(a.reverse(),e);return[n,t]}(n);i&&r?e.shiftKey||a!==r?e.shiftKey&&a===i&&(e.preventDefault(),t&&Qve(r,{select:!0})):(e.preventDefault(),t&&Qve(i,{select:!0})):a===n&&e.preventDefault()}}),[t,i,g.paused]);return n.jsx(Lve.div,{tabIndex:-1,...l,ref:p,onKeyDown:f})}));function Zve(e){const a=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.disabled||e.hidden||"INPUT"===e.tagName&&"hidden"===e.type?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)a.push(n.currentNode);return a}function $ve(e,a){for(const n of e)if(!Yve(n,{upTo:a}))return n}function Yve(e,{upTo:a}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==a&&e===a)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Qve(e,{select:a=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&a&&e.select()}}qve.displayName="FocusScope";var Xve=function(){let e=[];return{add(a){const n=e[0];a!==n&&n?.pause(),e=eye(e,a),e.unshift(a)},remove(a){e=eye(e,a),e[0]?.resume()}}}();function eye(e,a){const n=[...e],t=n.indexOf(a);return-1!==t&&n.splice(t,1),n}var aye=globalThis?.document?r.useLayoutEffect:()=>{},nye=r[" useId ".trim().toString()]||(()=>{}),tye=0;function iye(e){const[a,n]=r.useState(nye());return aye((()=>{n((e=>e??String(tye++)))}),[e]),e||(a?`radix-${a}`:"")}var rye=r.forwardRef(((e,a)=>{const{children:t,width:i=10,height:r=5,...o}=e;return n.jsx(Lve.svg,{...o,ref:a,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?t:n.jsx("polygon",{points:"0,0 30,0 15,10"})})}));rye.displayName="Arrow";var oye=rye;var sye="Popper",[lye,uye]=wve(sye),[cye,dye]=lye(sye),mye=e=>{const{__scopePopper:a,children:t}=e,[i,o]=r.useState(null);return n.jsx(cye,{scope:a,anchor:i,onAnchorChange:o,children:t})};mye.displayName=sye;var hye="PopperAnchor",pye=r.forwardRef(((e,a)=>{const{__scopePopper:t,virtualRef:i,...o}=e,s=dye(hye,t),l=r.useRef(null),u=xve(a,l);return r.useEffect((()=>{s.onAnchorChange(i?.current||l.current)})),i?null:n.jsx(Lve.div,{...o,ref:u})}));pye.displayName=hye;var gye="PopperContent",[fye,vye]=lye(gye),yye=r.forwardRef(((e,a)=>{const{__scopePopper:t,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:f,...v}=e,y=dye(gye,t),[k,b]=r.useState(null),S=xve(a,(e=>b(e))),[A,w]=r.useState(null),M=function(e){const[a,n]=r.useState(void 0);return aye((()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver((a=>{if(!Array.isArray(a))return;if(!a.length)return;const t=a[0];let i,r;if("borderBoxSize"in t){const e=t.borderBoxSize,a=Array.isArray(e)?e[0]:e;i=a.inlineSize,r=a.blockSize}else i=e.offsetWidth,r=e.offsetHeight;n({width:i,height:r})}));return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}n(void 0)}),[e]),a}(A),C=M?.width??0,T=M?.height??0,x=i+("center"!==s?"-"+s:""),N="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},E=Array.isArray(d)?d:[d],_=E.length>0,P={padding:N,boundary:E.filter(Aye),altBoundary:_},{refs:j,floatingStyles:L,placement:B,isPositioned:R,middlewareData:z}=J6({strategy:"fixed",placement:x,whileElementsMounted:(...e)=>P6(...e,{animationFrame:"always"===g}),elements:{reference:y.anchor},middleware:[W6({mainAxis:o+T,alignmentAxis:l}),c&&q6({mainAxis:!0,crossAxis:!1,limiter:"partial"===h?Z6():void 0,...P}),c&&$6({...P}),Y6({...P,apply:({elements:e,rects:a,availableWidth:n,availableHeight:t})=>{const{width:i,height:r}=a.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${n}px`),o.setProperty("--radix-popper-available-height",`${t}px`),o.setProperty("--radix-popper-anchor-width",`${i}px`),o.setProperty("--radix-popper-anchor-height",`${r}px`)}}),A&&X6({element:A,padding:u}),wye({arrowWidth:C,arrowHeight:T}),p&&Q6({strategy:"referenceHidden",...P})]}),[D,O]=Mye(B),K=Bve(f);aye((()=>{R&&K?.()}),[R,K]);const H=z.arrow?.x,I=z.arrow?.y,G=0!==z.arrow?.centerOffset,[F,V]=r.useState();return aye((()=>{k&&V(window.getComputedStyle(k).zIndex)}),[k]),n.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:R?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:F,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(" "),...z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(fye,{scope:t,placedSide:D,onArrowChange:w,arrowX:H,arrowY:I,shouldHideArrow:G,children:n.jsx(Lve.div,{"data-side":D,"data-align":O,...v,ref:S,style:{...v.style,animation:R?void 0:"none"}})})})}));yye.displayName=gye;var kye="PopperArrow",bye={top:"bottom",right:"left",bottom:"top",left:"right"},Sye=r.forwardRef((function(e,a){const{__scopePopper:t,...i}=e,r=vye(kye,t),o=bye[r.placedSide];return n.jsx("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:n.jsx(oye,{...i,ref:a,style:{...i.style,display:"block"}})})}));function Aye(e){return null!==e}Sye.displayName=kye;var wye=e=>({name:"transformOrigin",options:e,fn(a){const{placement:n,rects:t,middlewareData:i}=a,r=0!==i.arrow?.centerOffset,o=r?0:e.arrowWidth,s=r?0:e.arrowHeight,[l,u]=Mye(n),c={start:"0%",center:"50%",end:"100%"}[u],d=(i.arrow?.x??0)+o/2,m=(i.arrow?.y??0)+s/2;let h="",p="";return"bottom"===l?(h=r?c:`${d}px`,p=-s+"px"):"top"===l?(h=r?c:`${d}px`,p=`${t.floating.height+s}px`):"right"===l?(h=-s+"px",p=r?c:`${m}px`):"left"===l&&(h=`${t.floating.width+s}px`,p=r?c:`${m}px`),{data:{x:h,y:p}}}});function Mye(e){const[a,n="center"]=e.split("-");return[a,n]}var Cye=mye,Tye=pye,xye=yye,Nye=Sye,Eye=r.forwardRef(((e,a)=>{const{container:i,...o}=e,[s,l]=r.useState(!1);aye((()=>l(!0)),[]);const u=i||s&&globalThis?.document?.body;return u?t.createPortal(n.jsx(Lve.div,{...o,ref:a}),u):null}));Eye.displayName="Portal";var _ye=r[" useInsertionEffect ".trim().toString()]||aye;function Pye({prop:e,defaultProp:a,onChange:n=()=>{},caller:t}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[n,t]=r.useState(e),i=r.useRef(n),o=r.useRef(a);return _ye((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==n&&(o.current?.(n),i.current=n)}),[n,i]),[n,t,o]}({defaultProp:a,onChange:n}),l=void 0!==e,u=l?e:i;{const a=r.useRef(void 0!==e);r.useEffect((()=>{const e=a.current;if(e!==l){}a.current=l}),[l,t])}const c=r.useCallback((a=>{if(l){const n=function(e){return"function"==typeof e}(a)?a(e):a;n!==e&&s.current?.(n)}else o(a)}),[l,e,o,s]);return[u,c]}var jye=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});r.forwardRef(((e,a)=>n.jsx(Lve.span,{...e,ref:a,style:{...jye,...e.style}}))).displayName="VisuallyHidden";var Lye=[" ","Enter","ArrowUp","ArrowDown"],Bye=[" ","Enter"],Rye="Select",[zye,Dye,Oye]=function(e){const t=e+"CollectionProvider",[i,r]=wve(t),[o,s]=i(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return n.jsx(o,{scope:t,itemMap:s,collectionRef:r,children:i})};l.displayName=t;const u=e+"CollectionSlot",c=Nve(u),d=a.forwardRef(((e,a)=>{const{scope:t,children:i}=e,r=xve(a,s(u,t).collectionRef);return n.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=Nve(m),g=a.forwardRef(((e,t)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=xve(t,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),n.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(n){const t=s(e+"CollectionConsumer",n);return a.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(t.itemMap.values()).sort(((e,n)=>a.indexOf(e.ref.current)-a.indexOf(n.ref.current)))}),[t.collectionRef,t.itemMap])},r]}(Rye),[Kye,Hye]=wve(Rye,[Oye,uye]),Iye=uye(),[Gye,Fye]=Kye(Rye),[Vye,Jye]=Kye(Rye),Uye=e=>{const{__scopeSelect:a,children:t,open:i,defaultOpen:o,onOpenChange:s,value:l,defaultValue:u,onValueChange:c,dir:d,name:m,autoComplete:h,disabled:p,required:g,form:f}=e,v=Iye(a),[y,k]=r.useState(null),[b,S]=r.useState(null),[A,w]=r.useState(!1),M=function(e){const a=r.useContext(jve);return e||a||"ltr"}(d),[C,T]=Pye({prop:i,defaultProp:o??!1,onChange:s,caller:Rye}),[x,N]=Pye({prop:l,defaultProp:u,onChange:c,caller:Rye}),E=r.useRef(null),_=!y||(f||!!y.closest("form")),[P,j]=r.useState(new Set),L=Array.from(P).map((e=>e.props.value)).join(";");return n.jsx(Cye,{...v,children:n.jsxs(Gye,{required:g,scope:a,trigger:y,onTriggerChange:k,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:A,onValueNodeHasChildrenChange:w,contentId:iye(),value:x,onValueChange:N,open:C,onOpenChange:T,dir:M,triggerPointerDownPosRef:E,disabled:p,children:[n.jsx(zye.Provider,{scope:a,children:n.jsx(Vye,{scope:e.__scopeSelect,onNativeOptionAdd:r.useCallback((e=>{j((a=>new Set(a).add(e)))}),[]),onNativeOptionRemove:r.useCallback((e=>{j((a=>{const n=new Set(a);return n.delete(e),n}))}),[]),children:t})}),_?n.jsxs(Lke,{"aria-hidden":!0,required:g,tabIndex:-1,name:m,autoComplete:h,value:x,onChange:e=>N(e.target.value),disabled:p,form:f,children:[void 0===x?n.jsx("option",{value:""}):null,Array.from(P)]},L):null]})})};Uye.displayName=Rye;var Wye="SelectTrigger",qye=r.forwardRef(((e,a)=>{const{__scopeSelect:t,disabled:i=!1,...o}=e,s=Iye(t),l=Fye(Wye,t),u=l.disabled||i,c=xve(a,l.onTriggerChange),d=Dye(t),m=r.useRef("touch"),[h,p,g]=Rke((e=>{const a=d().filter((e=>!e.disabled)),n=a.find((e=>e.value===l.value)),t=zke(a,e,n);void 0!==t&&l.onValueChange(t.value)})),f=e=>{u||(l.onOpenChange(!0),g()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return n.jsx(Tye,{asChild:!0,...s,children:n.jsx(Lve.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":Bke(l.value)?"":void 0,...o,ref:c,onClick:Ave(o.onClick,(e=>{e.currentTarget.focus(),"mouse"!==m.current&&f(e)})),onPointerDown:Ave(o.onPointerDown,(e=>{m.current=e.pointerType;const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(f(e),e.preventDefault())})),onKeyDown:Ave(o.onKeyDown,(e=>{const a=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),a&&" "===e.key||Lye.includes(e.key)&&(f(),e.preventDefault())}))})})}));qye.displayName=Wye;var Zye="SelectValue",$ye=r.forwardRef(((e,a)=>{const{__scopeSelect:t,className:i,style:r,children:o,placeholder:s="",...l}=e,u=Fye(Zye,t),{onValueNodeHasChildrenChange:c}=u,d=void 0!==o,m=xve(a,u.onValueNodeChange);return aye((()=>{c(d)}),[c,d]),n.jsx(Lve.span,{...l,ref:m,style:{pointerEvents:"none"},children:Bke(u.value)?n.jsx(n.Fragment,{children:s}):o})}));$ye.displayName=Zye;var Yye=r.forwardRef(((e,a)=>{const{__scopeSelect:t,children:i,...r}=e;return n.jsx(Lve.span,{"aria-hidden":!0,...r,ref:a,children:i||"▼"})}));Yye.displayName="SelectIcon";var Qye=e=>n.jsx(Eye,{asChild:!0,...e});Qye.displayName="SelectPortal";var Xye="SelectContent",eke=r.forwardRef(((e,a)=>{const t=Fye(Xye,e.__scopeSelect),[i,s]=r.useState();if(aye((()=>{s(new DocumentFragment)}),[]),!t.open){const a=i;return a?o.createPortal(n.jsx(nke,{scope:e.__scopeSelect,children:n.jsx(zye.Slot,{scope:e.__scopeSelect,children:n.jsx("div",{children:e.children})})}),a):null}return n.jsx(rke,{...e,ref:a})}));eke.displayName=Xye;var ake=10,[nke,tke]=Kye(Xye),ike=Nve("SelectContent.RemoveScroll"),rke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:l,side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y,...k}=e,b=Fye(Xye,t),[S,A]=r.useState(null),[w,M]=r.useState(null),C=xve(a,(e=>A(e))),[T,x]=r.useState(null),[N,E]=r.useState(null),_=Dye(t),[P,j]=r.useState(!1),L=r.useRef(!1);r.useEffect((()=>{if(S)return xW(S)}),[S]),r.useEffect((()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Vve()),document.body.insertAdjacentElement("beforeend",e[1]??Vve()),Fve++,()=>{1===Fve&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),Fve--}}),[]);const B=r.useCallback((e=>{const[a,...n]=_().map((e=>e.ref.current)),[t]=n.slice(-1),i=document.activeElement;for(const r of e){if(r===i)return;if(r?.scrollIntoView({block:"nearest"}),r===a&&w&&(w.scrollTop=0),r===t&&w&&(w.scrollTop=w.scrollHeight),r?.focus(),document.activeElement!==i)return}}),[_,w]),R=r.useCallback((()=>B([T,S])),[B,T,S]);r.useEffect((()=>{P&&R()}),[P,R]);const{onOpenChange:z,triggerPointerDownPosRef:D}=b;r.useEffect((()=>{if(S){let e={x:0,y:0};const a=a=>{e={x:Math.abs(Math.round(a.pageX)-(D.current?.x??0)),y:Math.abs(Math.round(a.pageY)-(D.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():S.contains(n.target)||z(!1),document.removeEventListener("pointermove",a),D.current=null};return null!==D.current&&(document.addEventListener("pointermove",a),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",n,{capture:!0})}}}),[S,z,D]),r.useEffect((()=>{const e=()=>z(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}}),[z]);const[O,K]=Rke((e=>{const a=_().filter((e=>!e.disabled)),n=a.find((e=>e.ref.current===document.activeElement)),t=zke(a,e,n);t&&setTimeout((()=>t.ref.current.focus()))})),H=r.useCallback(((e,a,n)=>{const t=!L.current&&!n;(void 0!==b.value&&b.value===a||t)&&(x(e),t&&(L.current=!0))}),[b.value]),I=r.useCallback((()=>S?.focus()),[S]),G=r.useCallback(((e,a,n)=>{(void 0!==b.value&&b.value===a||!L.current&&!n)&&E(e)}),[b.value]),F="popper"===i?ske:oke,V=F===ske?{side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y}:{};return n.jsx(nke,{scope:t,content:S,viewport:w,onViewportChange:M,itemRefCallback:H,selectedItem:T,onItemLeave:I,itemTextRefCallback:G,focusSelectedItem:R,selectedItemText:N,position:i,isPositioned:P,searchRef:O,children:n.jsx(bW,{as:ike,allowPinchZoom:!0,children:n.jsx(qve,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Ave(o,(e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()})),children:n.jsx(Hve,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:n.jsx(F,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:e=>e.preventDefault(),...k,...V,onPlaced:()=>j(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Ave(k.onKeyDown,(e=>{const a=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),a||1!==e.key.length||K(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let a=_().filter((e=>!e.disabled)).map((e=>e.ref.current));if(["ArrowUp","End"].includes(e.key)&&(a=a.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=a.indexOf(e.target);a=a.slice(n+1)}setTimeout((()=>B(a))),e.preventDefault()}}))})})})})})}));rke.displayName="SelectContentImpl";var oke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,onPlaced:i,...o}=e,s=Fye(Xye,t),l=tke(Xye,t),[u,c]=r.useState(null),[d,m]=r.useState(null),h=xve(a,(e=>m(e))),p=Dye(t),g=r.useRef(!1),f=r.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:k,focusSelectedItem:b}=l,S=r.useCallback((()=>{if(s.trigger&&s.valueNode&&u&&d&&v&&y&&k){const e=s.trigger.getBoundingClientRect(),a=d.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),t=k.getBoundingClientRect();if("rtl"!==s.dir){const i=n.left-(t.left-a.left),r=e.width+(e.left-i),o=Math.max(r,a.width),s=window.innerWidth-ake,l=Sve(i,[ake,Math.max(ake,s-o)]);u.style.minWidth=r+"px",u.style.left=l+"px"}else{const i=window.innerWidth-n.right-(a.right-t.right),r=window.innerWidth-e.right-i,o=e.width+r,s=Math.max(o,a.width),l=window.innerWidth-ake,c=Sve(i,[ake,Math.max(ake,l-s)]);u.style.minWidth=o+"px",u.style.right=c+"px"}const r=p(),o=window.innerHeight-2*ake,l=v.scrollHeight,c=window.getComputedStyle(d),m=parseInt(c.borderTopWidth,10),h=parseInt(c.paddingTop,10),f=parseInt(c.borderBottomWidth,10),b=m+h+l+parseInt(c.paddingBottom,10)+f,S=Math.min(5*y.offsetHeight,b),A=window.getComputedStyle(v),w=parseInt(A.paddingTop,10),M=parseInt(A.paddingBottom,10),C=e.top+e.height/2-ake,T=o-C,x=y.offsetHeight/2,N=m+h+(y.offsetTop+x),E=b-N;if(N<=C){const e=r.length>0&&y===r[r.length-1].ref.current;u.style.bottom="0px";const a=Math.max(T,x+(e?M:0)+(d.clientHeight-v.offsetTop-v.offsetHeight)+f);u.style.height=N+a+"px"}else{const e=r.length>0&&y===r[0].ref.current;u.style.top="0px";const a=Math.max(C,m+v.offsetTop+(e?w:0)+x);u.style.height=a+E+"px",v.scrollTop=N-C+v.offsetTop}u.style.margin=`${ake}px 0`,u.style.minHeight=S+"px",u.style.maxHeight=o+"px",i?.(),requestAnimationFrame((()=>g.current=!0))}}),[p,s.trigger,s.valueNode,u,d,v,y,k,s.dir,i]);aye((()=>S()),[S]);const[A,w]=r.useState();aye((()=>{d&&w(window.getComputedStyle(d).zIndex)}),[d]);const M=r.useCallback((e=>{e&&!0===f.current&&(S(),b?.(),f.current=!1)}),[S,b]);return n.jsx(lke,{scope:t,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:M,children:n.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:n.jsx(Lve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})}));oke.displayName="SelectItemAlignedPosition";var ske=r.forwardRef(((e,a)=>{const{__scopeSelect:t,align:i="start",collisionPadding:r=ake,...o}=e,s=Iye(t);return n.jsx(xye,{...s,...o,ref:a,align:i,collisionPadding:r,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})}));ske.displayName="SelectPopperPosition";var[lke,uke]=Kye(Xye,{}),cke="SelectViewport",dke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,nonce:i,...o}=e,s=tke(cke,t),l=uke(cke,t),u=xve(a,s.onViewportChange),c=r.useRef(0);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),n.jsx(zye.Slot,{scope:t,children:n.jsx(Lve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ave(o.onScroll,(e=>{const a=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:t}=l;if(t?.current&&n){const e=Math.abs(c.current-a.scrollTop);if(e>0){const t=window.innerHeight-2*ake,i=parseFloat(n.style.minHeight),r=parseFloat(n.style.height),o=Math.max(i,r);if(o<t){const i=o+e,r=Math.min(t,i),s=i-r;n.style.height=r+"px","0px"===n.style.bottom&&(a.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}c.current=a.scrollTop}))})})]})}));dke.displayName=cke;var mke="SelectGroup",[hke,pke]=Kye(mke),gke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e,r=iye();return n.jsx(hke,{scope:t,id:r,children:n.jsx(Lve.div,{role:"group","aria-labelledby":r,...i,ref:a})})}));gke.displayName=mke;var fke="SelectLabel",vke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e,r=pke(fke,t);return n.jsx(Lve.div,{id:r.id,...i,ref:a})}));vke.displayName=fke;var yke="SelectItem",[kke,bke]=Kye(yke),Ske=r.forwardRef(((e,a)=>{const{__scopeSelect:t,value:i,disabled:o=!1,textValue:s,...l}=e,u=Fye(yke,t),c=tke(yke,t),d=u.value===i,[m,h]=r.useState(s??""),[p,g]=r.useState(!1),f=xve(a,(e=>c.itemRefCallback?.(e,i,o))),v=iye(),y=r.useRef("touch"),k=()=>{o||(u.onValueChange(i),u.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return n.jsx(kke,{scope:t,value:i,disabled:o,textId:v,isSelected:d,onItemTextChange:r.useCallback((e=>{h((a=>a||(e?.textContent??"").trim()))}),[]),children:n.jsx(zye.ItemSlot,{scope:t,value:i,disabled:o,textValue:m,children:n.jsx(Lve.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":d&&p,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:f,onFocus:Ave(l.onFocus,(()=>g(!0))),onBlur:Ave(l.onBlur,(()=>g(!1))),onClick:Ave(l.onClick,(()=>{"mouse"!==y.current&&k()})),onPointerUp:Ave(l.onPointerUp,(()=>{"mouse"===y.current&&k()})),onPointerDown:Ave(l.onPointerDown,(e=>{y.current=e.pointerType})),onPointerMove:Ave(l.onPointerMove,(e=>{y.current=e.pointerType,o?c.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})})),onPointerLeave:Ave(l.onPointerLeave,(e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()})),onKeyDown:Ave(l.onKeyDown,(e=>{""!==c.searchRef?.current&&" "===e.key||(Bye.includes(e.key)&&k()," "===e.key&&e.preventDefault())}))})})})}));Ske.displayName=yke;var Ake="SelectItemText",wke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,className:i,style:s,...l}=e,u=Fye(Ake,t),c=tke(Ake,t),d=bke(Ake,t),m=Jye(Ake,t),[h,p]=r.useState(null),g=xve(a,(e=>p(e)),d.onItemTextChange,(e=>c.itemTextRefCallback?.(e,d.value,d.disabled))),f=h?.textContent,v=r.useMemo((()=>n.jsx("option",{value:d.value,disabled:d.disabled,children:f},d.value)),[d.disabled,d.value,f]),{onNativeOptionAdd:y,onNativeOptionRemove:k}=m;return aye((()=>(y(v),()=>k(v))),[y,k,v]),n.jsxs(n.Fragment,{children:[n.jsx(Lve.span,{id:d.textId,...l,ref:g}),d.isSelected&&u.valueNode&&!u.valueNodeHasChildren?o.createPortal(l.children,u.valueNode):null]})}));wke.displayName=Ake;var Mke="SelectItemIndicator",Cke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e;return bke(Mke,t).isSelected?n.jsx(Lve.span,{"aria-hidden":!0,...i,ref:a}):null}));Cke.displayName=Mke;var Tke="SelectScrollUpButton",xke=r.forwardRef(((e,a)=>{const t=tke(Tke,e.__scopeSelect),i=uke(Tke,e.__scopeSelect),[o,s]=r.useState(!1),l=xve(a,i.onScrollButtonChange);return aye((()=>{if(t.viewport&&t.isPositioned){let e=function(){s(a.scrollTop>0)};const a=t.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[t.viewport,t.isPositioned]),o?n.jsx(_ke,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=t;e&&a&&(e.scrollTop=e.scrollTop-a.offsetHeight)}}):null}));xke.displayName=Tke;var Nke="SelectScrollDownButton",Eke=r.forwardRef(((e,a)=>{const t=tke(Nke,e.__scopeSelect),i=uke(Nke,e.__scopeSelect),[o,s]=r.useState(!1),l=xve(a,i.onScrollButtonChange);return aye((()=>{if(t.viewport&&t.isPositioned){let e=function(){const e=a.scrollHeight-a.clientHeight,n=Math.ceil(a.scrollTop)<e;s(n)};const a=t.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[t.viewport,t.isPositioned]),o?n.jsx(_ke,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=t;e&&a&&(e.scrollTop=e.scrollTop+a.offsetHeight)}}):null}));Eke.displayName=Nke;var _ke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,onAutoScroll:i,...o}=e,s=tke("SelectScrollButton",t),l=r.useRef(null),u=Dye(t),c=r.useCallback((()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)}),[]);return r.useEffect((()=>()=>c()),[c]),aye((()=>{const e=u().find((e=>e.ref.current===document.activeElement));e?.ref.current?.scrollIntoView({block:"nearest"})}),[u]),n.jsx(Lve.div,{"aria-hidden":!0,...o,ref:a,style:{flexShrink:0,...o.style},onPointerDown:Ave(o.onPointerDown,(()=>{null===l.current&&(l.current=window.setInterval(i,50))})),onPointerMove:Ave(o.onPointerMove,(()=>{s.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))})),onPointerLeave:Ave(o.onPointerLeave,(()=>{c()}))})})),Pke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e;return n.jsx(Lve.div,{"aria-hidden":!0,...i,ref:a})}));Pke.displayName="SelectSeparator";var jke="SelectArrow";r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e,r=Iye(t),o=Fye(jke,t),s=tke(jke,t);return o.open&&"popper"===s.position?n.jsx(Nye,{...r,...i,ref:a}):null})).displayName=jke;var Lke=r.forwardRef((({__scopeSelect:e,value:a,...t},i)=>{const o=r.useRef(null),s=xve(i,o),l=function(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}(a);return r.useEffect((()=>{const e=o.current;if(!e)return;const n=window.HTMLSelectElement.prototype,t=Object.getOwnPropertyDescriptor(n,"value").set;if(l!==a&&t){const n=new Event("change",{bubbles:!0});t.call(e,a),e.dispatchEvent(n)}}),[l,a]),n.jsx(Lve.select,{...t,style:{...jye,...t.style},ref:s,defaultValue:a})}));function Bke(e){return""===e||void 0===e}function Rke(e){const a=Bve(e),n=r.useRef(""),t=r.useRef(0),i=r.useCallback((e=>{const i=n.current+e;a(i),function e(a){n.current=a,window.clearTimeout(t.current),""!==a&&(t.current=window.setTimeout((()=>e("")),1e3))}(i)}),[a]),o=r.useCallback((()=>{n.current="",window.clearTimeout(t.current)}),[]);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),[n,i,o]}function zke(e,a,n){const t=a.length>1&&Array.from(a).every((e=>e===a[0]))?a[0]:a,i=n?e.indexOf(n):-1;let r=(o=e,s=Math.max(i,0),o.map(((e,a)=>o[(s+a)%o.length])));var o,s;1===t.length&&(r=r.filter((e=>e!==n)));const l=r.find((e=>e.textValue.toLowerCase().startsWith(t.toLowerCase())));return l!==n?l:void 0}Lke.displayName="SelectBubbleInput";var Dke=qye,Oke=Yye,Kke=Qye,Hke=eke,Ike=dke,Gke=vke,Fke=Ske,Vke=wke,Jke=Cke,Uke=xke,Wke=Eke,qke=Pke;const Zke=Uye,$ke=gke,Yke=$ye,Qke=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(Dke,{ref:i,className:mz("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-border/10 px-3 py-2 text-sm shadow-sm ring-offset-background !placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...t,children:[a,n.jsx(Oke,{asChild:!0,children:n.jsx(hB,{className:"h-4 w-4 opacity-50"})})]})));Qke.displayName=Dke.displayName;const Xke=r.forwardRef((({className:e,...a},t)=>n.jsx(Uke,{ref:t,className:mz("flex cursor-default items-center justify-center py-1",e),...a,children:n.jsx(fB,{className:"h-4 w-4"})})));Xke.displayName=Uke.displayName;const ebe=r.forwardRef((({className:e,...a},t)=>n.jsx(Wke,{ref:t,className:mz("flex cursor-default items-center justify-center py-1",e),...a,children:n.jsx(hB,{className:"h-4 w-4"})})));ebe.displayName=Wke.displayName;const abe=r.forwardRef((({className:e,children:a,position:t="popper",...i},r)=>n.jsx(Kke,{children:n.jsxs(Hke,{ref:r,className:mz("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===t&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:t,...i,children:[n.jsx(Xke,{}),n.jsx(Ike,{className:mz("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),n.jsx(ebe,{})]})})));abe.displayName=Hke.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(Gke,{ref:t,className:mz("px-2 py-1.5 text-sm font-semibold text-muted-foreground",e),...a}))).displayName=Gke.displayName;const nbe=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(Fke,{ref:i,className:mz("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t,children:[n.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(Jke,{children:n.jsx(mB,{className:"h-4 w-4"})})}),n.jsx(Vke,{children:a})]})));nbe.displayName=Fke.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(qke,{ref:t,className:mz("-mx-1 my-1 h-px bg-muted",e),...a}))).displayName=qke.displayName;const tbe=(e,n)=>{const[t,i]=a.useState(e);return a.useEffect((()=>{const a=setTimeout((()=>{i(e)}),n);return()=>clearTimeout(a)}),[e,n]),t},ibe=async()=>(await Re(s)).data,rbe=async(e,a)=>(await Re(s,{method:"PATCH",body:JSON.stringify({uiDefaults:{[e]:a}})})).data,obe=["me"],sbe=()=>{const e=ce(),{toast:a}=ea(),n=ye({queryKey:obe,queryFn:ibe,...Me}),t=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({website:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Website updated 🚀"})},onError:()=>{a({title:"Failed to update website",description:"Please try again",variant:"destructive"})}}),i=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({locations:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Locations updated 🚀"})},onError:()=>{a({title:"Failed to update locations",description:"Please try again",variant:"destructive"})}}),r=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({branding:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Brand settings saved 🚀"})},onError:()=>{a({title:"Failed to save brand settings",description:"Please try again",variant:"destructive"})}}),o=ke({mutationFn:e=>(async e=>{const a=e.company.address1?.trim()||e.company.city?.trim()||e.company.stateProvince?.trim()||e.company.zipCode?.trim(),n=e.company.name?.trim();if(!a&&!n)return{success:!0,message:"No updates needed"};const t={locations:[{addressLine1:e.company.address1?.trim()||"",addressLine2:e.company.address2?.trim(),locality:e.company.city?.trim()||"",district:e.company.stateProvince?.trim()||"",postalCode:e.company.zipCode?.trim()||"",countryCode:e.company.country?.trim()||""}],...n&&{name:e.company.name?.trim()}};try{return(await Re(s,{method:"PATCH",body:JSON.stringify(t)})).data}catch(i){throw i}})(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Business settings saved 🚀"})},onError:()=>{a({title:"Failed to save business settings",description:"Please try again",variant:"destructive"})}}),l=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({uiDefaults:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Business UI defaults updated 🚀"})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),u=ke({mutationFn:e=>rbe(e.key,e.value),onSuccess:()=>{e.invalidateQueries({queryKey:obe})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),c=ke({mutationFn:e=>(async e=>rbe("emailHelpDialogShow",e))(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe})},onError:()=>{a({title:"Failed to update dialog state",description:"Please try again",variant:"destructive"})}});return{data:n.data,isLoading:n.isLoading,error:n.error,refetch:n.refetch,updateWebsite:t.mutate,updateLocations:i.mutate,updateBrandSettings:r.mutate,updateBusinessSettings:o.mutate,updateBusinessSettingsAsync:o.mutateAsync,updateBusinessUiDefaults:l.mutate,updateBusinessUiDefaultsAsync:l.mutateAsync,updateBusinessUiDefaultProperty:u.mutate,updateBusinessUiDefaultPropertyAsync:u.mutateAsync,toggleEmailHelpDialog:c.mutate,toggleEmailHelpDialogAsync:c.mutateAsync,isUpdatingWebsite:t.isPending,isUpdatingLocations:i.isPending,isUpdatingBrandSettings:r.isPending,isUpdatingBusinessSettings:o.isPending,isUpdatingBusinessUiDefaults:l.isPending,isUpdatingBusinessUiDefaultProperty:u.isPending,isTogglingEmailHelpDialog:c.isPending}};var lbe=(e=>(e.WORKFLOW="workflow",e.RECIPIENTS="recipients",e.INSIGHTS="insights",e))(lbe||{}),ube=(e=>(e.EMAIL="email",e.SMS="sms",e))(ube||{});const cbe=[0,100,500,1e3,2e3],dbe=320,mbe=({type:e})=>n.jsxs("div",{className:"w-full h-full min-h-[300px] flex flex-col items-center justify-center bg-gradient-to-b from-gray-50 to-white p-8",children:[n.jsx("div",{className:"mb-4 text-gray-300",children:n.jsx("svg",{className:"w-16 h-16",fill:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"})})}),n.jsxs("p",{className:"text-gray-400 font-medium text-lg text-center mb-2",children:["No ","email"===e?"Email":"SMS"," Preview Available"]}),n.jsxs("p",{className:"text-gray-400 text-sm text-center",children:["Edit your ","email"===e?"Email":"SMS"," template to see a preview here"]})]}),hbe=({html:e,onHeightChange:t})=>{const i=a.useRef(),[r,o]=a.useState({type:"loading"}),[s,l]=a.useState(null),u=a.useCallback((e=>{e&&l(e)}),[]),c=d3(),{getMergeFields:d,isGetting:m}=la(c?.id??void 0),h=a.useMemo((()=>d?.mergeFields?.flatMap((e=>e.entries))??[]),[d?.mergeFields]),p=a.useMemo((()=>((e,a)=>{if(!e)return"";const n=e.includes("merge-field-pill-styles")?"":'\n <style id="merge-field-pill-styles">\n .merge-field-pill {\n display: inline-block !important;\n padding: 4px 8px !important;\n border-radius: 6px !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n font-size: 0.875rem !important;\n border: 1px solid #e5e7eb !important;\n font-weight: 500 !important;\n margin: 0 2px !important;\n vertical-align: middle !important;\n line-height: 1.2 !important;\n white-space: nowrap !important;\n box-sizing: border-box !important;\n }\n </style>\n ';let t=e;return n&&e.includes("<head>")?t=e.replace("<head>",`<head>${n}`):n&&(t=`<head>${n}</head>${e}`),t.replace(/\{\{.*?\}\}/g,(e=>{const n=a?.find((a=>a.value===e));return`<span class="merge-field-pill" style="display: inline-block; padding: 4px 8px; border-radius: 6px; background: #f3f4f6; color: #6b7280; font-size: 0.875rem; border: 1px solid #e5e7eb; font-weight: 500; margin: 0 2px; vertical-align: middle; line-height: 1.2; white-space: nowrap; box-sizing: border-box;">${n?n.label:e}</span>`}))})(e,h)),[e,h]),g=a.useCallback((e=>{o((a=>"ready"===a.type||"calculating"===a.type?(t?.(e),{type:"ready",height:e}):a))}),[t]),f=a.useCallback((()=>{o({type:"error",fallbackHeight:400}),g(400)}),[g]),v=a.useCallback((e=>{try{const a=e.split("\n").length;return Math.max(200,Math.min(800,20*a))}catch(a){return 400}}),[]),y=a.useCallback((()=>{const e=v(p);o({type:"error",fallbackHeight:e}),g(e)}),[p,v,g]);if(a.useEffect((()=>{p&&(o({type:"calculating"}),i.current&&clearTimeout(i.current))}),[p]),a.useEffect((()=>{if(!p||!s)return;if("ready"===r.type)return;const e=s,a=Math.max(5e3,5e3);i.current=setTimeout((()=>{f()}),a);const n=setTimeout((()=>{"calculating"===r.type&&y()}),1e4),t=v(p),l=()=>{try{const n=e.contentDocument||e.contentWindow?.document;if(!n)return o({type:"error",fallbackHeight:t}),void g(t);const i=()=>{try{n.querySelectorAll("style[data-merge-field-pills]").forEach((e=>e.remove()));const e=n.createElement("style");e.textContent="html, body { height: auto !important; min-height: 0 !important; }",n.head.appendChild(e);const a=n.createElement("style");a.setAttribute("data-merge-field-pills","true"),a.textContent="\n .merge-field-pill {\n display: inline-block !important;\n padding: 4px 8px !important;\n border-radius: 6px !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n font-size: 0.875rem !important;\n border: 1px solid #e5e7eb !important;\n font-weight: 500 !important;\n margin: 0 2px !important;\n vertical-align: middle !important;\n line-height: 1.2 !important;\n white-space: nowrap !important;\n box-sizing: border-box !important;\n }\n \n /* Ensure pills are visible even with conflicting styles */\n span.merge-field-pill {\n display: inline-block !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n border: 1px solid #e5e7eb !important;\n }\n \n /* Force override any inherited styles */\n * .merge-field-pill {\n display: inline-block !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n border: 1px solid #e5e7eb !important;\n padding: 4px 8px !important;\n border-radius: 6px !important;\n }\n ",n.head.appendChild(a)}catch(e){}};"complete"===n.readyState||"interactive"===n.readyState?i():(n.addEventListener("DOMContentLoaded",i),n.addEventListener("load",i));try{const a=n.createElement("script");a.textContent=`\n (function() {\n let lastHeight = 0;\n let checkCount = 0;\n const MAX_CHECKS = 20; // Prevent infinite loops\n \n // Calculate max height from various measurements with better error handling\n function getContentHeight() {\n try {\n const { body, documentElement: html } = document;\n if (!body || !html) {\n return 0;\n }\n \n const measurements = [\n body.scrollHeight,\n body.offsetHeight,\n html.clientHeight,\n html.scrollHeight,\n html.offsetHeight\n ].filter(h => h > 0 && isFinite(h));\n \n if (measurements.length === 0) {\n console.warn('HeightMonitor: No valid height measurements found');\n return 0;\n }\n \n return Math.max(...measurements);\n } catch (error) {\n console.warn('HeightMonitor: Error calculating height', error);\n return 0;\n }\n }\n \n function reportHeight() {\n try {\n const height = getContentHeight();\n if (height > 0 && height !== lastHeight) {\n lastHeight = height;\n window.parent.postMessage({\n type: 'IFRAME_HEIGHT_UPDATE',\n height: height + 10\n }, '*');\n }\n } catch (error) {\n console.warn('HeightMonitor: Error reporting height', error);\n }\n }\n \n // Enhanced height monitoring with multiple strategies\n function setupHeightMonitoring() {\n try {\n // Strategy 1: ResizeObserver for real-time monitoring\n if (window.ResizeObserver) {\n const observer = new ResizeObserver(() => {\n requestAnimationFrame(() => {\n reportHeight();\n checkCount++;\n });\n });\n observer.observe(document.body);\n observer.observe(document.documentElement);\n } else {\n console.warn('HeightMonitor: ResizeObserver not available, using fallback');\n }\n \n // Strategy 2: Handle image loading with better error handling\n const images = document.querySelectorAll('img');\n images.forEach(img => {\n if (!img.complete) {\n img.addEventListener('load', () => {\n setTimeout(reportHeight, 100); // Small delay to ensure layout is complete\n });\n img.addEventListener('error', () => {\n setTimeout(reportHeight, 100);\n });\n }\n });\n \n // Strategy 3: Watch for DOM changes with throttling\n let mutationTimeout;\n new MutationObserver(() => {\n if (mutationTimeout) clearTimeout(mutationTimeout);\n mutationTimeout = setTimeout(() => {\n requestAnimationFrame(reportHeight);\n checkCount++;\n }, 100); // Throttle mutations\n }).observe(document.body, { \n childList: true, \n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class']\n });\n \n // Strategy 4: Periodic checks with exponential backoff\n let checkDelay = 100;\n const periodicCheck = () => {\n if (checkCount >= MAX_CHECKS) {\n console.warn('HeightMonitor: Max checks reached, stopping periodic checks');\n return;\n }\n \n reportHeight();\n checkCount++;\n \n // Exponential backoff for periodic checks\n checkDelay = Math.min(checkDelay * 1.5, 2000);\n setTimeout(periodicCheck, checkDelay);\n };\n \n // Start periodic checks after initial setup\n setTimeout(periodicCheck, 500);\n \n } catch (error) {\n console.warn('HeightMonitor: Error setting up monitoring', error);\n }\n }\n \n // Initial setup with multiple triggers\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', setupHeightMonitoring);\n } else {\n setupHeightMonitoring();\n }\n \n window.addEventListener('load', () => {\n setTimeout(() => {\n reportHeight();\n checkCount++;\n }, 100);\n });\n \n // Initial checks with progressive delays\n ${cbe.map((e=>`setTimeout(() => { reportHeight(); checkCount++; }, ${e});`)).join("\n ")}\n \n // Final fallback check\n setTimeout(() => {\n if (lastHeight === 0) {\n console.warn('HeightMonitor: No height reported, forcing final check');\n reportHeight();\n }\n }, 4000);\n \n })();\n `,n.body.appendChild(a),setTimeout((()=>{if("calculating"===r.type)try{const a=e.contentDocument||e.contentWindow?.document;if(a){const e=a.body?.scrollHeight||a.body?.offsetHeight;e&&e>0?g(e+10):(o({type:"error",fallbackHeight:t}),g(t))}}catch(a){o({type:"error",fallbackHeight:t}),g(t)}}),2e3)}catch(a){setTimeout((()=>{try{const a=e.contentDocument||e.contentWindow?.document;if(a){const e=a.body?.scrollHeight||a.body?.offsetHeight;e&&e>0?g(e+10):(o({type:"error",fallbackHeight:t}),g(t))}else o({type:"error",fallbackHeight:t}),g(t)}catch(a){o({type:"error",fallbackHeight:t}),g(t)}}),1e3)}}catch(n){o({type:"error",fallbackHeight:t}),g(t)}},u=a=>{if("IFRAME_HEIGHT_UPDATE"===a.data?.type&&a.source===e.contentWindow){const e=a.data.height;e>0&&(i.current&&clearTimeout(i.current),g(e))}},c=()=>{o({type:"error",fallbackHeight:t}),g(t)},d=()=>{l()};return e.addEventListener("load",d),e.addEventListener("error",c),window.addEventListener("message",u),setTimeout((()=>{if("calculating"===r.type)try{const a=e.contentDocument||e.contentWindow?.document;a&&"complete"===a.readyState?l():(o({type:"error",fallbackHeight:t}),g(t))}catch(a){o({type:"error",fallbackHeight:t}),g(t)}}),1e3),()=>{e.removeEventListener("load",d),e.removeEventListener("error",c),window.removeEventListener("message",u),i.current&&clearTimeout(i.current),clearTimeout(n)}}),[p,g,f,y,v,r.type,s]),m&&void 0===d)return n.jsx("div",{className:"flex items-center justify-center py-5",children:n.jsx(Dq,{text:"Fetching merge fields..."})});if(!e)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx(mbe,{type:"email"})});const k="ready"===r.type?r.height:"error"===r.type?r.fallbackHeight:0,b="ready"===r.type||"error"===r.type;return n.jsxs("div",{className:"w-full h-full bg-white rounded-lg border-0 overflow-visible",children:[n.jsx("iframe",{ref:u,title:"Email Preview",srcDoc:p,className:"w-full block",style:{border:"none",backgroundColor:"white",width:"100%",height:"1px",overflow:"hidden",position:"absolute",top:"-9999px",left:"-9999px",visibility:"hidden"}}),n.jsx(Yq,{mode:"wait",children:b?n.jsx(R2.div,{initial:{height:0,opacity:0},animate:{height:k,opacity:1},transition:{height:{type:"spring",stiffness:400,damping:25,duration:"error"===r.type?.3:void 0},opacity:{duration:.2}},className:"overflow-hidden",children:"error"===r.type?n.jsx("div",{className:"w-full",style:{height:`${k}px`}}):n.jsx("iframe",{title:"Email Preview",srcDoc:p,className:"w-full block",style:{border:"none",backgroundColor:"white",width:"100%",height:`${k}px`,overflow:"hidden"}})},"content"):n.jsx(R2.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex items-center justify-center py-8",children:n.jsx(Dq,{text:"Calculating email preview..."})},"loader")})]})},pbe=()=>{const e=[{id:"dynamic-content",title:"Dynamic Content",image:"https://cdn.embedreach.com/assets/engage/merge-tags-demo.gif",imageAlt:`${DD("engage:merge_field")} Demo`,imageDesc:`Demonstration: Adding ${DD("engage:merge_field").toLowerCase()} to personalize your emails`,selectorTitle:"Dynamic Content",selectorSubtitle:"Dynamic content is a way to insert dynamic content into your email like name, email, or other details.",selectorIcon:n.jsx(HB,{})},{id:"responsive-design",title:"Responsive Design",image:"https://cdn.embedreach.com/assets/engage/layout-mobile-desktop.gif",imageAlt:"Mobile Desktop Switch Demo",imageDesc:"Demonstration: Switching between mobile and desktop preview modes",selectorTitle:"Responsive Design",selectorSubtitle:"Switch between mobile and desktop preview modes to ensure your emails look great on all devices.",selectorIcon:n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(rR,{className:"w-4 h-4"}),n.jsx(FB,{className:"w-4 h-4"})]})}],{toggleEmailHelpDialog:t,data:i}=sbe(),{toast:r}=ea(),[o,s]=a.useState("dynamic-content"),l=!1!==i?.uiDefaults?.emailHelpDialogShow,u=e.find((e=>e.id===o))??e[0];return n.jsxs("div",{className:"p-6 overflow-y-auto",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"Email Editor Help Center"}),n.jsx("p",{className:"text-gray-500",children:"Learn how to use our email editor's powerful features"})]}),n.jsx("div",{className:"mb-8 flex flex-col items-center min-h-[340px]",children:n.jsx(Yq,{mode:"wait",children:n.jsxs(R2.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:-24},transition:{duration:.3},className:"w-full flex flex-col items-center",children:[n.jsx("h3",{className:"text-lg font-medium mb-2",children:u.title}),n.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-gray-50 w-full max-w-2xl",children:[n.jsx("img",{src:u.image,alt:u.imageAlt,className:"w-full shadow-lg max-w-md mx-auto"}),n.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 to-transparent p-4",children:n.jsx("p",{className:"text-white text-sm",children:u.imageDesc})})]})]},u.id)})}),n.jsx("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-6 max-w-xl mx-auto",children:e.map((e=>n.jsx("div",{className:"flex-1",children:n.jsx(k3,{onClick:()=>s(e.id),title:e.selectorTitle,subtitle:e.selectorSubtitle,icon:e.selectorIcon,selected:o===e.id})},e.id)))}),l&&n.jsx("div",{className:"flex justify-center pt-4",children:n.jsx(f3,{size:"sm",onClick:()=>{t(!1),r({title:"Email editor help dialog will not show again!"})},children:"Don't show me again"})})]})},gbe=({type:e})=>n.jsxs("div",{className:"flex items-start space-x-2 text-sm text-gray-600",children:[n.jsx("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),n.jsxs("span",{children:["Please configure at least one ",e," sender before editing the template"]})]}),fbe=({containerRef:e,stripoDialogDimensions:t,showSaving:i})=>(a.useEffect((()=>{const a=a=>{const n=e.current;if(!n)return;const t=n.querySelector("ui-editor");if(!t)return;const i=t.shadowRoot;if(!i)return;const r=i.host.getBoundingClientRect();const o=function(e){for(;e;){const a=getComputedStyle(e);if(("auto"===a.overflowY||"scroll"===a.overflowY)&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null}(i.elementFromPoint(a.clientX-r.left,a.clientY-r.top))||i.firstElementChild;o&&(o.scrollTop+=a.deltaY,o.scrollLeft+=a.deltaX,a.preventDefault())},n=e.current;return n&&n.addEventListener("wheel",a,{passive:!1}),()=>{n&&n.removeEventListener("wheel",a)}}),[e]),a.useEffect((()=>{const e="stripo-service-element-hider";let a=document.getElementById(e);return a||(a=document.createElement("style"),a.id=e,document.head.appendChild(a)),a.textContent='\n /* Hide service elements with title attributes */\n #stripoEditorContainer small.service-element[title],\n #stripoEditorContainer .service-element[title],\n #stripoEditorContainer span.service-element[title],\n #stripoEditorContainer [class*="service-element"][title] {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n \n /* Also hide elements with our custom class */\n .stripo-hidden-service-element {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n ',()=>{a&&a.parentNode&&a.parentNode.removeChild(a)}}),[]),a.useEffect((()=>{const a=e.current;if(!a)return;const n=()=>{const e=a.querySelector("ui-editor");if(!e)return null;const n=e.shadowRoot;return n||null},t=()=>{const e=n();if(!e)return;["small.service-element[title]",".service-element[title]","span.service-element[title]",'[class*="service-element"][title]'].forEach((a=>{e.querySelectorAll(a).forEach((e=>{const a=e,n=a.getAttribute("title")||"";/^\{\{.*\}\}$/.test(n.trim())&&(a.style.display="none",a.style.visibility="hidden",a.style.opacity="0",a.style.position="absolute",a.style.left="-9999px",a.style.top="-9999px",a.classList.add("stripo-hidden-service-element"),a.setAttribute("style",a.getAttribute("style")+"; display: none !important; visibility: hidden !important; opacity: 0 !important;"))}))}));e.querySelectorAll("span.service-element.caption.ng-star-inserted").forEach((e=>{const a=e;"Merge Tags"===a.textContent?.trim()&&(a.textContent=DD("engage:merge_field",{count:2}))}))};let i=null;let r=0;const o=setInterval((()=>{n()?(t(),(()=>{const e=n();e&&(i&&i.disconnect(),i=new MutationObserver((e=>{let a=!1;e.forEach(((e,n)=>{"childList"===e.type&&e.addedNodes.length>0&&(a=!0)})),a&&setTimeout((()=>{t()}),10)})),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","title"]}))})(),clearInterval(o)):(r++,r>20&&clearInterval(o))}),100),s=setInterval((()=>{t()}),2e3);return()=>{i&&i.disconnect(),clearInterval(s),clearInterval(o)}}),[e]),n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center",children:[n.jsx("div",{id:"externalSystemContainer",className:"flex items-center px-4 py-2"}),i&&n.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-black/50 flex items-center justify-center z-50",children:n.jsx(Dq,{textColor:"text-white",text:["Saving..."]})}),n.jsx("div",{id:"stripoEditorContainer",ref:e,style:{width:t.width-75,height:t.height-75},className:"z-10"})]})),vbe="UiEditorScript",ybe=e=>new Promise(((a,n)=>{const t=()=>{let n;e.forceRecreate&&(n=!0),window.UIEditor&&(window.UIEditor.initEditor(e.container,{...n&&{forceRecreate:n},metadata:{emailId:e.emailId},html:e.html,css:e.css,locale:"en",onTokenRefreshRequest:e=>{Promise.resolve().then((async()=>{try{const{token:a}=await(async()=>(await Re(`${m}/token`)).data)();e(a)}catch(a){}}))},messageSettingsEnabled:!1,conditionsEnabled:!1,syncModulesEnabled:!1,notifications:{info:console.info,error:console.error,warn:console.warn,success:console.log},mergeTags:e.mergeFields,mobileViewButtonSelector:".toggle-mobile-button",desktopViewButtonSelector:".toggle-desktop-button"}),a(void 0))};if(document.getElementById(vbe))t();else{const e=document.createElement("script");e.id=vbe,e.type="module",e.src="https://plugins.stripo.email/resources/uieditor/rev/2.21.0/UIEditor.js",e.onload=()=>{window.UIEditor?t():n(new Error("UIEditor not found after script load"))},e.onerror=e=>{n(e)},document.head.appendChild(e)}})),kbe=({automation:e,showStripoEditor:t,setShowStripoEditor:i,saveClicked:r,setSaveClicked:o,stripoDialogDimensions:s,mergeFieldsResponse:l,cancelClicked:u,setCancelClicked:c,actionId:d,onEditorReadyChange:m})=>{const[h,p]=a.useState(!1),[g,f]=a.useState(!1),[v,y]=a.useState(!1),k=a.useRef(!1),b=a.useRef(null),S=a.useRef(null),{data:A,isLoading:w,error:M}=(e=>{const{automationId:a,actionId:n}=e;return ye({queryKey:na.templateForActionId(a,n),queryFn:()=>ia({automationId:a,actionId:n}),...Ce})})({automationId:e.id,actionId:d}),{data:C,isLoading:T,error:x}=(()=>{const e=ce();return{...ye({queryKey:na.editorData(),queryFn:ta,...Me}),invalidateEditorData:()=>e.invalidateQueries({queryKey:na.editorData()})}})(),{updateCommunicationGroup:N}=sa(),E=a.useCallback((()=>{const e=!(!window.StripoEditorApi?.actionsApi||"function"!=typeof window.StripoEditorApi.actionsApi.save||"function"!=typeof window.StripoEditorApi.actionsApi.compileEmail);return e&&!v&&(y(!0),m?.(!0),S.current&&(clearInterval(S.current),S.current=null)),e}),[v,m]),_=a.useCallback((()=>{o(!1),c(!1),p(!1),f(!1),y(!1),m?.(!1),i(!1),S.current&&(clearInterval(S.current),S.current=null)}),[o,c,p,f,y,m,i]),P=a.useCallback((async()=>{if(v&&window.StripoEditorApi?.actionsApi&&A?.communicationGroupId)try{const e=()=>new Promise(((e,a)=>{window.StripoEditorApi.actionsApi.compileEmail({callback:async function(n,t){if(n)a(new Error(`Compile failed: ${n}`));else{try{await N({groupId:A.communicationGroupId,params:{emailHtmlBody:t}})}catch(KGe){a(KGe)}f(!0),e()}},minimize:!0,mergeTags:[],forceAmp:!1,resetDataSavedFlag:!1,disableLineHeightsReplace:!0}),window.StripoEditorApi.actionsApi.save((function(e){e?a(new Error(`Save failed: ${e}`)):p(!0)}))}));await e()}catch(e){}}),[A,N,v]);return a.useEffect((()=>{r&&v?P():r&&!v&&o(!1)}),[r,P,v,o]),a.useEffect((()=>{(h&&g||!1===t)&&_()}),[h,g,t,_]),a.useEffect((()=>{u&&_()}),[u,_]),a.useEffect((()=>{if(C?.businessId&&b.current&&A&&!k.current){(async()=>{try{await ybe({emailId:A.communicationGroupId,html:A.html||"<div></div>",css:A.css||"",container:b.current,businessId:C.businessId,mergeFields:l.mergeFields||[],forceRecreate:A.forceRecreate}),k.current=!0,S.current=setInterval((()=>{E()}),500)}catch(e){}})()}}),[C,l,A,E]),a.useEffect((()=>()=>{S.current&&clearInterval(S.current)}),[]),M||x?n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center",children:[n.jsx("div",{className:"text-red-500 mb-4",children:"Failed to load editor data"}),n.jsx(f3,{onClick:()=>window.location.reload(),variant:"outline",children:"Retry"})]}):n.jsx("div",w||T||!C||!A?{className:"w-full h-full flex flex-col items-center justify-center",children:n.jsx(Dq,{text:["Loading editor..."]})}:{className:"w-full h-full flex flex-col",children:n.jsx(fbe,{containerRef:b,stripoDialogDimensions:s,showSaving:r&&v})})},bbe=({mergeFieldsResponse:e,emailChannelSendersWithChannelAccounts:t})=>{const i=d3(),r=c3(),{updateCommunicationGroup:o}=sa(),{refetchAutomation:s}=ha(r?.id||""),{channelSenders:l}=pte(),{channelAccounts:u}=dte(),{state:{selectedActionId:c}}=a.useContext($2),{state:{replyToSettingsText:d,replyToSettingsLink:m,fromNameSettingsText:h,fromNameSettingsLink:p}}=a.useContext(Bq),{data:g,isLoading:f}=sbe(),[v,y]=a.useState(!1),[k,b]=a.useState(i?.emailChannelSenderId||null),[S,A]=a.useState(i?.emailSubject||null),[w,M]=a.useState(i?.emailPreviewText||null),[C,T]=a.useState(i?.emailCompiledHtml||i?.emailHtmlBody||null),[x,N]=a.useState(!1),[E,_]=a.useState(!1),[P,j]=a.useState(!1),[L,B]=a.useState(!1),[R,z]=a.useState(""),[D,O]=a.useState(""),[K,H]=a.useState(null),I=a.useRef(!0),[G,F]=a.useState(!0),[V,J]=a.useState(!1),[U,W]=a.useState({width:0,height:0});a.useEffect((()=>{g&&!1!==x&&null===K&&(g?.uiDefaults?g?.uiDefaults?.emailHelpDialogShow&&!K&&H(!0):H(!0))}),[g,g?.uiDefaults?.emailHelpDialogShow,K,x]);const q=tbe(S,500),Z=tbe(w,500),$=a.useMemo((()=>t||l?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=u?.results?.find((a=>a.id===e.channelAccountId));return a&&(a.channelAccountMetadata.type===mte.REACH_MANAGED||a.channelAccountMetadata.type===mte.REACH_MANAGED_SES)?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`}]:[]}))||[]),[t,l?.results,u?.results]),Y=a.useRef(null);return a.useEffect((()=>{const e=setTimeout((()=>{I.current=!1}),500);return()=>clearTimeout(e)}),[]),a.useEffect((()=>{i?.emailHtmlBody&&T(i.emailHtmlBody),i?.emailCompiledHtml&&T(i.emailCompiledHtml)}),[i?.emailHtmlBody,i?.emailCompiledHtml,s]),a.useEffect((()=>{if(v){const e=setTimeout((()=>{y(!1)}),2e3);return()=>clearTimeout(e)}}),[v]),a.useEffect((()=>{const e=()=>{W({width:window.innerWidth,height:window.innerHeight})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a.useEffect((()=>{if(!I.current&&k&&q&&C&&i?.id){y(!0);(async()=>{try{o({groupId:i.id,params:{emailChannelSenderId:k,emailHtmlBody:C,emailSubject:q,...Z&&{emailPreviewText:Z}}})}catch(e){}finally{y(!1)}})()}}),[k,q,Z,C,i?.id,o]),a.useEffect((()=>{if(l?.results&&k){const e=l.results.find((e=>e.id===k));e&&(V&&!G||O(e.channelSenderMetadata.emailReplyTo),G&&z(e.channelSenderMetadata.emailFromName),F(!1))}}),[l?.results,k,V,G]),a.useEffect((()=>{if(l?.results&&!k){const e=l.results.filter((e=>e.channelSenderMetadata.userPart));if(e[0]){const a=e[0];b(a.id),o({groupId:i?.id||"",params:{emailChannelSenderId:a.id}})}}}),[l?.results,k,i?.id,o]),a.useEffect((()=>{!1===x&&i?.id&&s()}),[x,i?.id,s]),u&&l&&c&&!f?n.jsxs("div",{className:"relative",children:[n.jsx(Cq,{open:K??!1,onOpenChange:H,children:n.jsxs(Eq,{className:"max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full",children:[n.jsxs(wq,{children:[n.jsx(jq,{children:"Email Preview Help"}),n.jsx(Lq,{children:"Learn more about the email preview and how to use it to create your email."})]}),n.jsx(pbe,{})]})}),n.jsx(Cq,{open:x,onOpenChange:N,children:n.jsxs(Eq,{className:"min-w-[100vw] min-h-[100vh]",hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault()},children:[n.jsxs(wq,{children:[n.jsx(jq,{children:"Email Editor"}),n.jsx(Lq,{children:"Learn more about the email editor and how to use it to create your email."})]}),n.jsxs("div",{className:"w-full h-full",children:[n.jsxs("div",{className:"flex justify-between items-center p-1 border-b",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h2",{className:"text-lg font-medium",children:"Email Editor"}),n.jsx(f3,{size:"sm",onClick:()=>H(!0),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium text-sm",children:"Help"}),n.jsx(b3.InfoIcon,{className:"w-4 h-4"})]})})]}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsx(cve,{})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(f3,{variant:"destructive",onClick:()=>{j(!0)},className:"text-sm px-3 py-1 rounded",children:"Cancel"}),n.jsx(f3,{onClick:()=>_(!0),className:"text-sm px-3 py-1 rounded",disabled:!L,children:"Save"})]})]}),r&&n.jsx(kbe,{cancelClicked:P,setCancelClicked:j,showStripoEditor:x,automation:r,setShowStripoEditor:N,saveClicked:E,setSaveClicked:_,stripoDialogDimensions:U,mergeFieldsResponse:e,actionId:c,onEditorReadyChange:B})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(bve,{className:"text-foreground",children:"From Email"}),n.jsxs(Zke,{onValueChange:e=>{b(e),F(!0),J(!1)},value:k??void 0,disabled:v,children:[n.jsx(Qke,{children:n.jsx(Yke,{placeholder:"Select email",className:"text-muted-foreground",children:k?$?.find((e=>e.channelSenderId===k))?.fullDomain:""})}),n.jsx(abe,{children:$?.map((e=>n.jsx(nbe,{value:e.channelSenderId,children:e.fullDomain},e.channelSenderId)))})]})]}),n.jsxs("div",{children:[n.jsx(bve,{children:n.jsxs("div",{className:"flex items-center gap-2 py-1",children:["From Name",n.jsx(wse,{title:h||"From name can be configured under settings in the home screen",link:p?{url:p}:void 0})]})}),n.jsx(U7,{value:R??"",className:"text-muted-foreground",disabled:!0})]}),n.jsxs("div",{children:[n.jsx(bve,{children:n.jsxs("div",{className:"flex items-center gap-2 py-1",children:["Reply To Email",n.jsx(wse,{title:d||"Reply to email can be configured under settings in the home screen",link:m?{url:m}:void 0})]})}),n.jsx(U7,{value:D??(k?$?.find((e=>e.channelSenderId===k))?.fullDomain:""),className:"text-muted-foreground",disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-0 py-1",children:[n.jsx(bve,{className:"text-foreground",children:"Subject"}),n.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),n.jsx(uve,{value:S,onChange:A,mergeFieldsResponse:e,placeholder:"Enter email subject",className:"text-muted-foreground",ariaLabel:"Insert merge field into subject"})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx(bve,{className:"text-foreground",children:"Preview Text"}),n.jsx(wse,{title:"This text will be used for the preview text of the email in the inbox"})]}),n.jsx(uve,{value:w,onChange:M,className:"text-muted-foreground",mergeFieldsResponse:e})]})]}),n.jsxs("div",{className:"rounded-none p-4 h-full flex flex-col",children:[n.jsxs("div",{className:"flex justify-between items-center mb-4",children:[n.jsx("h3",{className:"font-medium",children:"Preview"}),n.jsxs("div",{children:[n.jsx(f3,{onClick:()=>N(!0),className:"text-sm px-3 py-1 rounded",disabled:v||0===(t?.length??0),children:"Edit"}),0===(t?.length??0)&&n.jsx("div",{className:"relative inline-block",children:n.jsx("div",{className:"absolute right-0 top-full mt-2 w-64 p-3 bg-white border rounded-lg shadow-lg z-10",children:n.jsx(gbe,{type:"email"})})})]})]}),n.jsx("div",{className:"flex-1 w-full overflow-auto",ref:Y,children:n.jsx(hbe,{html:C??""})})]})]})]}):n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(Dq,{text:["Fetching Email Preview..."]})})};var Sbe=(e=>(e.CUSTOM="custom",e.MANAGED="managed",e))(Sbe||{}),Abe=(e=>(e.EditAudience="edit-audience",e.EditTime="edit-time",e))(Abe||{}),wbe=(e=>(e.EMAIL="email",e.SMS="sms",e))(wbe||{});const Mbe=({title:e,type:t})=>{const i=d3(),r=c3(),{toast:o}=ea(),[s,l]=a.useState(!1),{resetCommunicationGroupToDefault:u,isPending:c}=ca(),d=!!i&&(i.type===Sbe.MANAGED&&(t===ube.SMS?i.updatedFromDefault?.text_message_body:i.updatedFromDefault?.email_text_body||i.updatedFromDefault?.email_html_body)),m=t===ube.EMAIL?"Email":"SMS";return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h4",{className:"text-xl font-medium text-foreground",children:e}),n.jsx("div",{className:"flex items-center gap-2",children:d&&n.jsx(n.Fragment,{children:c?n.jsx(Dq,{}):n.jsx(f3,{variant:"outline",size:"sm",onClick:()=>l(!0),children:"Reset To Default"})})})]}),n.jsx(Cq,{open:s,onOpenChange:l,children:n.jsxs(Eq,{className:"sm:max-w-[425px]",children:[n.jsxs(_q,{children:[n.jsx(jq,{className:"text-xl font-semibold",children:"Reset To Default"}),n.jsxs(Lq,{className:"text-base text-muted-foreground",children:["Are you sure you want to reset this ",m.toLowerCase()," ","template to its default state? This action cannot be undone."]})]}),n.jsxs(Pq,{className:"flex flex-row justify-end gap-3 mt-6",children:[n.jsx(f3,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsx(f3,{variant:"destructive",onClick:async()=>{i&&r?u({communicationGroupId:i.id,automationId:r.id,type:t===ube.EMAIL?"email":"sms"},{onSuccess:()=>{o({title:DD("engage:success.communication_reset","Communication reset to default!")}),l(!1)},onSettled:()=>{l(!1)},onError:()=>{o({title:"Error updating",description:"No sender found",variant:"destructive"})}}):o({title:"Error updating",description:"No sender found",variant:"destructive"})},children:"Reset To Default"})]})]})})]})},Cbe=e=>{const{channelSenders:a,channelAccounts:n}=e;return a?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=n?.find((a=>a.id===e.channelAccountId));return a&&(a.channelAccountMetadata.type===mte.REACH_MANAGED||a.channelAccountMetadata.type===mte.REACH_MANAGED_SES)?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,baseDomain:e.channelSenderMetadata.baseDomain??void 0,channelSender:e}]:[]}))||[]},Tbe=()=>{const e=a.useRef(null),t=d3(),{channelSenders:i}=pte(),{channelAccounts:r}=dte(),{getMergeFields:o,isGetting:s}=la(t?.id??void 0),l=a.useMemo((()=>Cbe({channelSenders:i?.results??[],channelAccounts:r?.results??[]})),[i?.results,r?.results]);return!s&&o&&l?n.jsxs("div",{className:"bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:e,children:[n.jsx(Mbe,{title:"Email Campaign",type:ube.EMAIL}),n.jsx(bbe,{mergeFieldsResponse:o,emailChannelSendersWithChannelAccounts:l})]}):n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(Dq,{text:["Fetching Content..."]})})};var xbe=e=>"checkbox"===e.type,Nbe=e=>e instanceof Date,Ebe=e=>null==e;const _be=e=>"object"==typeof e;var Pbe=e=>!Ebe(e)&&!Array.isArray(e)&&_be(e)&&!Nbe(e),jbe=e=>Pbe(e)&&e.target?xbe(e.target)?e.target.checked:e.target.value:e,Lbe=(e,a)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(a)),Bbe="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function Rbe(e){let a;const n=Array.isArray(e),t="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)a=new Date(e);else if(e instanceof Set)a=new Set(e);else{if(Bbe&&(e instanceof Blob||t)||!n&&!Pbe(e))return e;if(a=n?[]:{},n||(e=>{const a=e.constructor&&e.constructor.prototype;return Pbe(a)&&a.hasOwnProperty("isPrototypeOf")})(e))for(const n in e)e.hasOwnProperty(n)&&(a[n]=Rbe(e[n]));else a=e}return a}var zbe=e=>Array.isArray(e)?e.filter(Boolean):[],Dbe=e=>void 0===e,Obe=(e,a,n)=>{if(!a||!Pbe(e))return n;const t=zbe(a.split(/[,[\].]+?/)).reduce(((e,a)=>Ebe(e)?e:e[a]),e);return Dbe(t)||t===e?Dbe(e[a])?n:e[a]:t},Kbe=e=>"boolean"==typeof e,Hbe=e=>/^\w*$/.test(e),Ibe=e=>zbe(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Gbe=(e,a,n)=>{let t=-1;const i=Hbe(a)?[a]:Ibe(a),r=i.length,o=r-1;for(;++t<r;){const a=i[t];let r=n;if(t!==o){const n=e[a];r=Pbe(n)||Array.isArray(n)?n:isNaN(+i[t+1])?{}:[]}if("__proto__"===a||"constructor"===a||"prototype"===a)return;e[a]=r,e=e[a]}};const Fbe="blur",Vbe="focusout",Jbe="change",Ube="onBlur",Wbe="onChange",qbe="onSubmit",Zbe="onTouched",$be="all",Ybe="max",Qbe="min",Xbe="maxLength",eSe="minLength",aSe="pattern",nSe="required",tSe="validate",iSe=a.createContext(null),rSe=()=>a.useContext(iSe);var oSe=(e,a,n,t=!0)=>{const i={defaultValues:a._defaultValues};for(const r in e)Object.defineProperty(i,r,{get:()=>{const i=r;return a._proxyFormState[i]!==$be&&(a._proxyFormState[i]=!t||$be),n&&(n[i]=!0),e[i]}});return i},sSe=e=>Ebe(e)||!_be(e);function lSe(e,a){if(sSe(e)||sSe(a))return e===a;if(Nbe(e)&&Nbe(a))return e.getTime()===a.getTime();const n=Object.keys(e),t=Object.keys(a);if(n.length!==t.length)return!1;for(const i of n){const n=e[i];if(!t.includes(i))return!1;if("ref"!==i){const e=a[i];if(Nbe(n)&&Nbe(e)||Pbe(n)&&Pbe(e)||Array.isArray(n)&&Array.isArray(e)?!lSe(n,e):n!==e)return!1}}return!0}const uSe=(e,n)=>{const t=a.useRef(n);lSe(n,t.current)||(t.current=n),a.useEffect(e,t.current)};var cSe=e=>"string"==typeof e,dSe=(e,a,n,t,i)=>cSe(e)?(t&&a.watch.add(e),Obe(n,e,i)):Array.isArray(e)?e.map((e=>(t&&a.watch.add(e),Obe(n,e)))):(t&&(a.watchAll=!0),n);function mSe(e){const n=rSe(),{name:t,disabled:i,control:r=n.control,shouldUnregister:o}=e,s=Lbe(r._names.array,t),l=function(e){const n=rSe(),{control:t=n.control,name:i,defaultValue:r,disabled:o,exact:s}=e||{},[l,u]=a.useState(t._getWatch(i,r));return uSe((()=>t._subscribe({name:i,formState:{values:!0},exact:s,callback:e=>!o&&u(dSe(i,t._names,e.values||t._formValues,!1,r))})),[i,r,o,s]),a.useEffect((()=>t._removeUnmounted())),l}({control:r,name:t,defaultValue:Obe(r._formValues,t,Obe(r._defaultValues,t,e.defaultValue)),exact:!0}),u=function(e){const n=rSe(),{control:t=n.control,disabled:i,name:r,exact:o}=e||{},[s,l]=a.useState(t._formState),u=a.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return uSe((()=>t._subscribe({name:r,formState:u.current,exact:o,callback:e=>{!i&&l({...t._formState,...e})}})),[r,i,o]),a.useEffect((()=>{u.current.isValid&&t._setValid(!0)}),[t]),a.useMemo((()=>oSe(s,t,u.current,!1)),[s,t])}({control:r,name:t,exact:!0}),c=a.useRef(e),d=a.useRef(r.register(t,{...e.rules,value:l,...Kbe(e.disabled)?{disabled:e.disabled}:{}})),m=a.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Obe(u.errors,t)},isDirty:{enumerable:!0,get:()=>!!Obe(u.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!Obe(u.touchedFields,t)},isValidating:{enumerable:!0,get:()=>!!Obe(u.validatingFields,t)},error:{enumerable:!0,get:()=>Obe(u.errors,t)}})),[u,t]),h=a.useCallback((e=>d.current.onChange({target:{value:jbe(e),name:t},type:Jbe})),[t]),p=a.useCallback((()=>d.current.onBlur({target:{value:Obe(r._formValues,t),name:t},type:Fbe})),[t,r._formValues]),g=a.useCallback((e=>{const a=Obe(r._fields,t);a&&e&&(a._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:a=>e.setCustomValidity(a),reportValidity:()=>e.reportValidity()})}),[r._fields,t]),f=a.useMemo((()=>({name:t,value:l,...Kbe(i)||u.disabled?{disabled:u.disabled||i}:{},onChange:h,onBlur:p,ref:g})),[t,i,u.disabled,h,p,g,l]);return a.useEffect((()=>{const e=r._options.shouldUnregister||o;r.register(t,{...c.current.rules,...Kbe(c.current.disabled)?{disabled:c.current.disabled}:{}});const a=(e,a)=>{const n=Obe(r._fields,e);n&&n._f&&(n._f.mount=a)};if(a(t,!0),e){const e=Rbe(Obe(r._options.defaultValues,t));Gbe(r._defaultValues,t,e),Dbe(Obe(r._formValues,t))&&Gbe(r._formValues,t,e)}return!s&&r.register(t),()=>{(s?e&&!r._state.action:e)?r.unregister(t):a(t,!1)}}),[t,r,s,o]),a.useEffect((()=>{r._setDisabledField({disabled:i,name:t})}),[i,t,r]),a.useMemo((()=>({field:f,formState:u,fieldState:m})),[f,u,m])}const hSe=e=>e.render(mSe(e));var pSe=(e,a,n,t,i)=>a?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[t]:i||!0}}:{},gSe=e=>Array.isArray(e)?e:[e],fSe=()=>{let e=[];return{get observers(){return e},next:a=>{for(const n of e)n.next&&n.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter((e=>e!==a))}}),unsubscribe:()=>{e=[]}}},vSe=e=>Pbe(e)&&!Object.keys(e).length,ySe=e=>"file"===e.type,kSe=e=>"function"==typeof e,bSe=e=>{if(!Bbe)return!1;const a=e?e.ownerDocument:0;return e instanceof(a&&a.defaultView?a.defaultView.HTMLElement:HTMLElement)},SSe=e=>"select-multiple"===e.type,ASe=e=>"radio"===e.type,wSe=e=>bSe(e)&&e.isConnected;function MSe(e,a){const n=Array.isArray(a)?a:Hbe(a)?[a]:Ibe(a),t=1===n.length?e:function(e,a){const n=a.slice(0,-1).length;let t=0;for(;t<n;)e=Dbe(e)?t++:e[a[t++]];return e}(e,n),i=n.length-1;return t&&delete t[n[i]],0!==i&&(Pbe(t)&&vSe(t)||Array.isArray(t)&&function(e){for(const a in e)if(e.hasOwnProperty(a)&&!Dbe(e[a]))return!1;return!0}(t))&&MSe(e,n.slice(0,-1)),e}var CSe=e=>{for(const a in e)if(kSe(e[a]))return!0;return!1};function TSe(e,a={}){const n=Array.isArray(e);if(Pbe(e)||n)for(const t in e)Array.isArray(e[t])||Pbe(e[t])&&!CSe(e[t])?(a[t]=Array.isArray(e[t])?[]:{},TSe(e[t],a[t])):Ebe(e[t])||(a[t]=!0);return a}function xSe(e,a,n){const t=Array.isArray(e);if(Pbe(e)||t)for(const i in e)Array.isArray(e[i])||Pbe(e[i])&&!CSe(e[i])?Dbe(a)||sSe(n[i])?n[i]=Array.isArray(e[i])?TSe(e[i],[]):{...TSe(e[i])}:xSe(e[i],Ebe(a)?{}:a[i],n[i]):n[i]=!lSe(e[i],a[i]);return n}var NSe=(e,a)=>xSe(e,a,TSe(a));const ESe={value:!1,isValid:!1},_Se={value:!0,isValid:!0};var PSe=e=>{if(Array.isArray(e)){if(e.length>1){const a=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:a,isValid:!!a.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Dbe(e[0].attributes.value)?Dbe(e[0].value)||""===e[0].value?_Se:{value:e[0].value,isValid:!0}:_Se:ESe}return ESe},jSe=(e,{valueAsNumber:a,valueAsDate:n,setValueAs:t})=>Dbe(e)?e:a?""===e?NaN:e?+e:e:n&&cSe(e)?new Date(e):t?t(e):e;const LSe={isValid:!1,value:null};var BSe=e=>Array.isArray(e)?e.reduce(((e,a)=>a&&a.checked&&!a.disabled?{isValid:!0,value:a.value}:e),LSe):LSe;function RSe(e){const a=e.ref;return ySe(a)?a.files:ASe(a)?BSe(e.refs).value:SSe(a)?[...a.selectedOptions].map((({value:e})=>e)):xbe(a)?PSe(e.refs).value:jSe(Dbe(a.value)?e.ref.value:a.value,e)}var zSe=e=>e instanceof RegExp,DSe=e=>Dbe(e)?e:zSe(e)?e.source:Pbe(e)?zSe(e.value)?e.value.source:e.value:e,OSe=e=>({isOnSubmit:!e||e===qbe,isOnBlur:e===Ube,isOnChange:e===Wbe,isOnAll:e===$be,isOnTouch:e===Zbe});const KSe="AsyncFunction";var HSe=(e,a,n)=>!n&&(a.watchAll||a.watch.has(e)||[...a.watch].some((a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length)))));const ISe=(e,a,n,t)=>{for(const i of n||Object.keys(e)){const n=Obe(e,i);if(n){const{_f:e,...r}=n;if(e){if(e.refs&&e.refs[0]&&a(e.refs[0],i)&&!t)return!0;if(e.ref&&a(e.ref,e.name)&&!t)return!0;if(ISe(r,a))break}else if(Pbe(r)&&ISe(r,a))break}}};function GSe(e,a,n){const t=Obe(e,n);if(t||Hbe(n))return{error:t,name:n};const i=n.split(".");for(;i.length;){const t=i.join("."),r=Obe(a,t),o=Obe(e,t);if(r&&!Array.isArray(r)&&n!==t)return{name:n};if(o&&o.type)return{name:t,error:o};i.pop()}return{name:n}}var FSe=(e,a,n)=>{const t=gSe(Obe(e,n));return Gbe(t,"root",a[n]),Gbe(e,n,t),e},VSe=e=>cSe(e);function JSe(e,a,n="validate"){if(VSe(e)||Array.isArray(e)&&e.every(VSe)||Kbe(e)&&!e)return{type:n,message:VSe(e)?e:"",ref:a}}var USe=e=>Pbe(e)&&!zSe(e)?e:{value:e,message:""},WSe=async(e,a,n,t,i,r)=>{const{ref:o,refs:s,required:l,maxLength:u,minLength:c,min:d,max:m,pattern:h,validate:p,name:g,valueAsNumber:f,mount:v}=e._f,y=Obe(n,g);if(!v||a.has(g))return{};const k=s?s[0]:o,b=e=>{i&&k.reportValidity&&(k.setCustomValidity(Kbe(e)?"":e||""),k.reportValidity())},S={},A=ASe(o),w=xbe(o),M=A||w,C=(f||ySe(o))&&Dbe(o.value)&&Dbe(y)||bSe(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,T=pSe.bind(null,g,t,S),x=(e,a,n,t=Xbe,i=eSe)=>{const r=e?a:n;S[g]={type:e?t:i,message:r,ref:o,...T(e?t:i,r)}};if(r?!Array.isArray(y)||!y.length:l&&(!M&&(C||Ebe(y))||Kbe(y)&&!y||w&&!PSe(s).isValid||A&&!BSe(s).isValid)){const{value:e,message:a}=VSe(l)?{value:!!l,message:l}:USe(l);if(e&&(S[g]={type:nSe,message:a,ref:k,...T(nSe,a)},!t))return b(a),S}if(!(C||Ebe(d)&&Ebe(m))){let e,a;const n=USe(m),i=USe(d);if(Ebe(y)||isNaN(y)){const t=o.valueAsDate||new Date(y),r=e=>new Date((new Date).toDateString()+" "+e),s="time"==o.type,l="week"==o.type;cSe(n.value)&&y&&(e=s?r(y)>r(n.value):l?y>n.value:t>new Date(n.value)),cSe(i.value)&&y&&(a=s?r(y)<r(i.value):l?y<i.value:t<new Date(i.value))}else{const t=o.valueAsNumber||(y?+y:y);Ebe(n.value)||(e=t>n.value),Ebe(i.value)||(a=t<i.value)}if((e||a)&&(x(!!e,n.message,i.message,Ybe,Qbe),!t))return b(S[g].message),S}if((u||c)&&!C&&(cSe(y)||r&&Array.isArray(y))){const e=USe(u),a=USe(c),n=!Ebe(e.value)&&y.length>+e.value,i=!Ebe(a.value)&&y.length<+a.value;if((n||i)&&(x(n,e.message,a.message),!t))return b(S[g].message),S}if(h&&!C&&cSe(y)){const{value:e,message:a}=USe(h);if(zSe(e)&&!y.match(e)&&(S[g]={type:aSe,message:a,ref:o,...T(aSe,a)},!t))return b(a),S}if(p)if(kSe(p)){const e=JSe(await p(y,n),k);if(e&&(S[g]={...e,...T(tSe,e.message)},!t))return b(e.message),S}else if(Pbe(p)){let e={};for(const a in p){if(!vSe(e)&&!t)break;const i=JSe(await p[a](y,n),k,a);i&&(e={...i,...T(a,i.message)},b(i.message),t&&(S[g]=e))}if(!vSe(e)&&(S[g]={ref:k,...e},!t))return S}return b(!0),S};const qSe={mode:qbe,reValidateMode:Wbe,shouldFocusError:!0};function ZSe(e={}){let a={...qSe,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:kSe(a.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:a.errors||{},disabled:a.disabled||!1};const t={};let i,r=(Pbe(a.defaultValues)||Pbe(a.values))&&Rbe(a.values||a.defaultValues)||{},o=a.shouldUnregister?{}:Rbe(r),s={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0;const c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...c};const m={array:fSe(),state:fSe()},h=OSe(a.mode),p=OSe(a.reValidateMode),g=a.criteriaMode===$be,f=async e=>{if(!a.disabled&&(c.isValid||d.isValid||e)){const e=a.resolver?vSe((await S()).errors):await A(t,!0);e!==n.isValid&&m.state.next({isValid:e})}},v=(e,t)=>{!a.disabled&&(c.isValidating||c.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(l.mount)).forEach((e=>{e&&(t?Gbe(n.validatingFields,e,t):MSe(n.validatingFields,e))})),m.state.next({validatingFields:n.validatingFields,isValidating:!vSe(n.validatingFields)}))},y=(e,a,n,i)=>{const l=Obe(t,e);if(l){const t=Obe(o,e,Dbe(n)?Obe(r,e):n);Dbe(t)||i&&i.defaultChecked||a?Gbe(o,e,a?t:RSe(l._f)):C(e,t),s.mount&&f()}},k=(e,t,i,o,s)=>{let l=!1,u=!1;const h={name:e};if(!a.disabled){if(!i||o){(c.isDirty||d.isDirty)&&(u=n.isDirty,n.isDirty=h.isDirty=w(),l=u!==h.isDirty);const a=lSe(Obe(r,e),t);u=!!Obe(n.dirtyFields,e),a?MSe(n.dirtyFields,e):Gbe(n.dirtyFields,e,!0),h.dirtyFields=n.dirtyFields,l=l||(c.dirtyFields||d.dirtyFields)&&u!==!a}if(i){const a=Obe(n.touchedFields,e);a||(Gbe(n.touchedFields,e,i),h.touchedFields=n.touchedFields,l=l||(c.touchedFields||d.touchedFields)&&a!==i)}l&&s&&m.state.next(h)}return l?h:{}},b=(e,t,r,o)=>{const s=Obe(n.errors,e),l=(c.isValid||d.isValid)&&Kbe(t)&&n.isValid!==t;if(a.delayError&&r?(i=(e=>a=>{clearTimeout(u),u=setTimeout(e,a)})((()=>((e,a)=>{Gbe(n.errors,e,a),m.state.next({errors:n.errors})})(e,r))),i(a.delayError)):(clearTimeout(u),i=null,r?Gbe(n.errors,e,r):MSe(n.errors,e)),(r?!lSe(s,r):s)||!vSe(o)||l){const a={...o,...l&&Kbe(t)?{isValid:t}:{},errors:n.errors,name:e};n={...n,...a},m.state.next(a)}},S=async e=>{v(e,!0);const n=await a.resolver(o,a.context,((e,a,n,t)=>{const i={};for(const r of e){const e=Obe(a,r);e&&Gbe(i,r,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:t}})(e||l.mount,t,a.criteriaMode,a.shouldUseNativeValidation));return v(e),n},A=async(e,t,i={valid:!0})=>{for(const s in e){const u=e[s];if(u){const{_f:e,...d}=u;if(e){const d=l.array.has(e.name),m=u._f&&(!!(r=u._f)&&!!r.validate&&!!(kSe(r.validate)&&r.validate.constructor.name===KSe||Pbe(r.validate)&&Object.values(r.validate).find((e=>e.constructor.name===KSe))));m&&c.validatingFields&&v([s],!0);const h=await WSe(u,l.disabled,o,g,a.shouldUseNativeValidation&&!t,d);if(m&&c.validatingFields&&v([s]),h[e.name]&&(i.valid=!1,t))break;!t&&(Obe(h,e.name)?d?FSe(n.errors,h,e.name):Gbe(n.errors,e.name,h[e.name]):MSe(n.errors,e.name))}!vSe(d)&&await A(d,t,i)}}var r;return i.valid},w=(e,n)=>!a.disabled&&(e&&n&&Gbe(o,e,n),!lSe(P(),r)),M=(e,a,n)=>dSe(e,l,{...s.mount?o:Dbe(a)?r:cSe(e)?{[e]:a}:a},n,a),C=(e,a,n={})=>{const i=Obe(t,e);let r=a;if(i){const n=i._f;n&&(!n.disabled&&Gbe(o,e,jSe(a,n)),r=bSe(n.ref)&&Ebe(a)?"":a,SSe(n.ref)?[...n.ref.options].forEach((e=>e.selected=r.includes(e.value))):n.refs?xbe(n.ref)?n.refs.length>1?n.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(r)?!!r.find((a=>a===e.value)):r===e.value))):n.refs[0]&&(n.refs[0].checked=!!r):n.refs.forEach((e=>e.checked=e.value===r)):ySe(n.ref)?n.ref.value="":(n.ref.value=r,n.ref.type||m.state.next({name:e,values:Rbe(o)})))}(n.shouldDirty||n.shouldTouch)&&k(e,r,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&_(e)},T=(e,a,n)=>{for(const i in a){const r=a[i],o=`${e}.${i}`,s=Obe(t,o);(l.array.has(e)||Pbe(r)||s&&!s._f)&&!Nbe(r)?T(o,r,n):C(o,r,n)}},x=(e,a,i={})=>{const u=Obe(t,e),h=l.array.has(e),p=Rbe(a);Gbe(o,e,p),h?(m.array.next({name:e,values:Rbe(o)}),(c.isDirty||c.dirtyFields||d.isDirty||d.dirtyFields)&&i.shouldDirty&&m.state.next({name:e,dirtyFields:NSe(r,o),isDirty:w(e,p)})):!u||u._f||Ebe(p)?C(e,p,i):T(e,p,i),HSe(e,l)&&m.state.next({...n}),m.state.next({name:s.mount?e:void 0,values:Rbe(o)})},N=async e=>{s.mount=!0;const r=e.target;let u=r.name,y=!0;const w=Obe(t,u),M=e=>{y=Number.isNaN(e)||Nbe(e)&&isNaN(e.getTime())||lSe(e,Obe(o,u,e))};if(w){let s,T;const x=r.type?RSe(w._f):jbe(e),N=e.type===Fbe||e.type===Vbe,E=!((C=w._f).mount&&(C.required||C.min||C.max||C.maxLength||C.minLength||C.pattern||C.validate)||a.resolver||Obe(n.errors,u)||w._f.deps)||((e,a,n,t,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(a||e):(n?t.isOnBlur:i.isOnBlur)?!e:!(n?t.isOnChange:i.isOnChange)||e))(N,Obe(n.touchedFields,u),n.isSubmitted,p,h),P=HSe(u,l,N);Gbe(o,u,x),N?(w._f.onBlur&&w._f.onBlur(e),i&&i(0)):w._f.onChange&&w._f.onChange(e);const j=k(u,x,N),L=!vSe(j)||P;if(!N&&m.state.next({name:u,type:e.type,values:Rbe(o)}),E)return(c.isValid||d.isValid)&&("onBlur"===a.mode?N&&f():N||f()),L&&m.state.next({name:u,...P?{}:j});if(!N&&P&&m.state.next({...n}),a.resolver){const{errors:e}=await S([u]);if(M(x),y){const a=GSe(n.errors,t,u),i=GSe(e,t,a.name||u);s=i.error,u=i.name,T=vSe(e)}}else v([u],!0),s=(await WSe(w,l.disabled,o,g,a.shouldUseNativeValidation))[u],v([u]),M(x),y&&(s?T=!1:(c.isValid||d.isValid)&&(T=await A(t,!0)));y&&(w._f.deps&&_(w._f.deps),b(u,T,s,j))}var C},E=(e,a)=>{if(Obe(n.errors,a)&&e.focus)return e.focus(),1},_=async(e,i={})=>{let r,o;const s=gSe(e);if(a.resolver){const a=await(async e=>{const{errors:a}=await S(e);if(e)for(const t of e){const e=Obe(a,t);e?Gbe(n.errors,t,e):MSe(n.errors,t)}else n.errors=a;return a})(Dbe(e)?e:s);r=vSe(a),o=e?!s.some((e=>Obe(a,e))):r}else e?(o=(await Promise.all(s.map((async e=>{const a=Obe(t,e);return await A(a&&a._f?{[e]:a}:a)})))).every(Boolean),(o||n.isValid)&&f()):o=r=await A(t);return m.state.next({...!cSe(e)||(c.isValid||d.isValid)&&r!==n.isValid?{}:{name:e},...a.resolver||!e?{isValid:r}:{},errors:n.errors}),i.shouldFocus&&!o&&ISe(t,E,e?s:l.mount),o},P=e=>{const a={...s.mount?o:r};return Dbe(e)?a:cSe(e)?Obe(a,e):e.map((e=>Obe(a,e)))},j=(e,a)=>({invalid:!!Obe((a||n).errors,e),isDirty:!!Obe((a||n).dirtyFields,e),error:Obe((a||n).errors,e),isValidating:!!Obe(n.validatingFields,e),isTouched:!!Obe((a||n).touchedFields,e)}),L=(e,a,i)=>{const r=(Obe(t,e,{_f:{}})._f||{}).ref,o=Obe(n.errors,e)||{},{ref:s,message:l,type:u,...c}=o;Gbe(n.errors,e,{...c,...a,ref:r}),m.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&r&&r.focus&&r.focus()},B=e=>m.state.subscribe({next:a=>{var t,i,r;i=a.name,r=e.exact,(t=e.name)&&i&&t!==i&&!gSe(t).some((e=>e&&(r?e===i:e.startsWith(i)||i.startsWith(e))))||!((e,a,n,t)=>{n(e);const{name:i,...r}=e;return vSe(r)||Object.keys(r).length>=Object.keys(a).length||Object.keys(r).find((e=>a[e]===(!t||$be)))})(a,e.formState||c,G,e.reRenderRoot)||e.callback({values:{...o},...n,...a})}}).unsubscribe,R=(e,i={})=>{for(const s of e?gSe(e):l.mount)l.mount.delete(s),l.array.delete(s),i.keepValue||(MSe(t,s),MSe(o,s)),!i.keepError&&MSe(n.errors,s),!i.keepDirty&&MSe(n.dirtyFields,s),!i.keepTouched&&MSe(n.touchedFields,s),!i.keepIsValidating&&MSe(n.validatingFields,s),!a.shouldUnregister&&!i.keepDefaultValue&&MSe(r,s);m.state.next({values:Rbe(o)}),m.state.next({...n,...i.keepDirty?{isDirty:w()}:{}}),!i.keepIsValid&&f()},z=({disabled:e,name:a})=>{(Kbe(e)&&s.mount||e||l.disabled.has(a))&&(e?l.disabled.add(a):l.disabled.delete(a))},D=(e,n={})=>{let i=Obe(t,e);const o=Kbe(n.disabled)||Kbe(a.disabled);return Gbe(t,e,{...i||{},_f:{...i&&i._f?i._f:{ref:{name:e}},name:e,mount:!0,...n}}),l.mount.add(e),i?z({disabled:Kbe(n.disabled)?n.disabled:a.disabled,name:e}):y(e,!0,n.value),{...o?{disabled:n.disabled||a.disabled}:{},...a.progressive?{required:!!n.required,min:DSe(n.min),max:DSe(n.max),minLength:DSe(n.minLength),maxLength:DSe(n.maxLength),pattern:DSe(n.pattern)}:{},name:e,onChange:N,onBlur:N,ref:o=>{if(o){D(e,n),i=Obe(t,e);const a=Dbe(o.value)&&o.querySelectorAll&&o.querySelectorAll("input,select,textarea")[0]||o,s=(e=>ASe(e)||xbe(e))(a),l=i._f.refs||[];if(s?l.find((e=>e===a)):a===i._f.ref)return;Gbe(t,e,{_f:{...i._f,...s?{refs:[...l.filter(wSe),a,...Array.isArray(Obe(r,e))?[{}]:[]],ref:{type:a.type,name:e}}:{ref:a}}}),y(e,!1,void 0,a)}else i=Obe(t,e,{}),i._f&&(i._f.mount=!1),(a.shouldUnregister||n.shouldUnregister)&&(!Lbe(l.array,e)||!s.action)&&l.unMount.add(e)}}},O=()=>a.shouldFocusError&&ISe(t,E,l.mount),K=(e,i)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let u=Rbe(o);if(m.state.next({isSubmitting:!0}),a.resolver){const{errors:e,values:a}=await S();n.errors=e,u=a}else await A(t);if(l.disabled.size)for(const e of l.disabled)Gbe(u,e,void 0);if(MSe(n.errors,"root"),vSe(n.errors)){m.state.next({errors:{}});try{await e(u,r)}catch(c){s=c}}else i&&await i({...n.errors},r),O(),setTimeout(O);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:vSe(n.errors)&&!s,submitCount:n.submitCount+1,errors:n.errors}),s)throw s},H=(e,i={})=>{const u=e?Rbe(e):r,d=Rbe(u),h=vSe(e),p=h?r:d;if(i.keepDefaultValues||(r=u),!i.keepValues){if(i.keepDirtyValues){const e=new Set([...l.mount,...Object.keys(NSe(r,o))]);for(const a of Array.from(e))Obe(n.dirtyFields,a)?Gbe(p,a,Obe(o,a)):x(a,Obe(p,a))}else{if(Bbe&&Dbe(e))for(const e of l.mount){const a=Obe(t,e);if(a&&a._f){const e=Array.isArray(a._f.refs)?a._f.refs[0]:a._f.ref;if(bSe(e)){const a=e.closest("form");if(a){a.reset();break}}}}for(const e of l.mount)x(e,Obe(p,e))}o=Rbe(p),m.array.next({values:{...p}}),m.state.next({values:{...p}})}l={mount:i.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!c.isValid||!!i.keepIsValid||!!i.keepDirtyValues,s.watch=!!a.shouldUnregister,m.state.next({submitCount:i.keepSubmitCount?n.submitCount:0,isDirty:!h&&(i.keepDirty?n.isDirty:!(!i.keepDefaultValues||lSe(e,r))),isSubmitted:!!i.keepIsSubmitted&&n.isSubmitted,dirtyFields:h?{}:i.keepDirtyValues?i.keepDefaultValues&&o?NSe(r,o):n.dirtyFields:i.keepDefaultValues&&e?NSe(r,e):i.keepDirty?n.dirtyFields:{},touchedFields:i.keepTouched?n.touchedFields:{},errors:i.keepErrors?n.errors:{},isSubmitSuccessful:!!i.keepIsSubmitSuccessful&&n.isSubmitSuccessful,isSubmitting:!1})},I=(e,a)=>H(kSe(e)?e(o):e,a),G=e=>{n={...n,...e}},F={control:{register:D,unregister:R,getFieldState:j,handleSubmit:K,setError:L,_subscribe:B,_runSchema:S,_getWatch:M,_getDirty:w,_setValid:f,_setFieldArray:(e,i=[],l,u,h=!0,p=!0)=>{if(u&&l&&!a.disabled){if(s.action=!0,p&&Array.isArray(Obe(t,e))){const a=l(Obe(t,e),u.argA,u.argB);h&&Gbe(t,e,a)}if(p&&Array.isArray(Obe(n.errors,e))){const a=l(Obe(n.errors,e),u.argA,u.argB);h&&Gbe(n.errors,e,a),((e,a)=>{!zbe(Obe(e,a)).length&&MSe(e,a)})(n.errors,e)}if((c.touchedFields||d.touchedFields)&&p&&Array.isArray(Obe(n.touchedFields,e))){const a=l(Obe(n.touchedFields,e),u.argA,u.argB);h&&Gbe(n.touchedFields,e,a)}(c.dirtyFields||d.dirtyFields)&&(n.dirtyFields=NSe(r,o)),m.state.next({name:e,isDirty:w(e,i),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Gbe(o,e,i)},_setDisabledField:z,_setErrors:e=>{n.errors=e,m.state.next({errors:n.errors,isValid:!1})},_getFieldArray:e=>zbe(Obe(s.mount?o:r,e,a.shouldUnregister?Obe(r,e,[]):[])),_reset:H,_resetDefaultValues:()=>kSe(a.defaultValues)&&a.defaultValues().then((e=>{I(e,a.resetOptions),m.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of l.unMount){const a=Obe(t,e);a&&(a._f.refs?a._f.refs.every((e=>!wSe(e))):!wSe(a._f.ref))&&R(e)}l.unMount=new Set},_disableForm:e=>{Kbe(e)&&(m.state.next({disabled:e}),ISe(t,((a,n)=>{const i=Obe(t,n);i&&(a.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach((a=>{a.disabled=i._f.disabled||e})))}),0,!1))},_subjects:m,_proxyFormState:c,get _fields(){return t},get _formValues(){return o},get _state(){return s},set _state(e){s=e},get _defaultValues(){return r},get _names(){return l},set _names(e){l=e},get _formState(){return n},get _options(){return a},set _options(e){a={...a,...e}}},subscribe:e=>(s.mount=!0,d={...d,...e.formState},B({...e,formState:d})),trigger:_,register:D,handleSubmit:K,watch:(e,a)=>kSe(e)?m.state.subscribe({next:n=>e(M(void 0,a),n)}):M(e,a,!0),setValue:x,getValues:P,reset:I,resetField:(e,a={})=>{Obe(t,e)&&(Dbe(a.defaultValue)?x(e,Rbe(Obe(r,e))):(x(e,a.defaultValue),Gbe(r,e,Rbe(a.defaultValue))),a.keepTouched||MSe(n.touchedFields,e),a.keepDirty||(MSe(n.dirtyFields,e),n.isDirty=a.defaultValue?w(e,Rbe(Obe(r,e))):w()),a.keepError||(MSe(n.errors,e),c.isValid&&f()),m.state.next({...n}))},clearErrors:e=>{e&&gSe(e).forEach((e=>MSe(n.errors,e))),m.state.next({errors:e?n.errors:{}})},unregister:R,setError:L,setFocus:(e,a={})=>{const n=Obe(t,e),i=n&&n._f;if(i){const e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),a.shouldSelect&&kSe(e.select)&&e.select())}},getFieldState:j};return{...F,formControl:F}}const $Se="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;function YSe(e={}){const n=a.useRef(void 0),t=a.useRef(void 0),[i,r]=a.useState({isDirty:!1,isValidating:!1,isLoading:kSe(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:kSe(e.defaultValues)?void 0:e.defaultValues});n.current||(n.current={...e.formControl?e.formControl:ZSe(e),formState:i},e.formControl&&e.defaultValues&&!kSe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));const o=n.current.control;return o._options=e,$Se((()=>{const e=o._subscribe({formState:o._proxyFormState,callback:()=>r({...o._formState}),reRenderRoot:!0});return r((e=>({...e,isReady:!0}))),e}),[o]),a.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),a.useEffect((()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode),e.errors&&!vSe(e.errors)&&o._setErrors(e.errors)}),[o,e.errors,e.mode,e.reValidateMode]),a.useEffect((()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})}),[o,e.shouldUnregister]),a.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,i.isDirty]),a.useEffect((()=>{e.values&&!lSe(e.values,t.current)?(o._reset(e.values,o._options.resetOptions),t.current=e.values,r((e=>({...e})))):o._resetDefaultValues()}),[o,e.values]),a.useEffect((()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),n.current.formState=oSe(i,o),n.current}const QSe=e=>{const{children:n,...t}=e;return a.createElement(iSe.Provider,{value:t},n)},XSe=r.createContext({}),eAe=({...e})=>n.jsx(XSe.Provider,{value:{name:e.name},children:n.jsx(hSe,{...e})}),aAe=()=>{const e=r.useContext(XSe),a=r.useContext(nAe),{getFieldState:n,formState:t}=rSe(),i=n(e.name,t);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:o}=a;return{id:o,name:e.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...i}},nAe=r.createContext({}),tAe=r.forwardRef((({className:e,...a},t)=>{const i=r.useId();return n.jsx(nAe.Provider,{value:{id:i},children:n.jsx("div",{ref:t,className:mz("space-y-2",e),...a})})}));tAe.displayName="FormItem";const iAe=r.forwardRef((({className:e,...a},t)=>{const{error:i,formItemId:r}=aAe();return n.jsx(bve,{ref:t,className:mz(i&&"text-destructive",e),htmlFor:r,...a})}));iAe.displayName="FormLabel";const rAe=r.forwardRef((({...e},a)=>{const{error:t,formItemId:i,formDescriptionId:r,formMessageId:o}=aAe();return n.jsx(yq,{ref:a,id:i,"aria-describedby":t?`${r} ${o}`:`${r}`,"aria-invalid":!!t,...e})}));rAe.displayName="FormControl";r.forwardRef((({className:e,...a},t)=>{const{formDescriptionId:i}=aAe();return n.jsx("p",{ref:t,id:i,className:mz("text-[0.8rem] text-muted-foreground",e),...a})})).displayName="FormDescription";const oAe=r.forwardRef((({className:e,children:a,...t},i)=>{const{error:r,formMessageId:o}=aAe(),s=r?String(r?.message):a;return s?n.jsx("p",{ref:i,id:o,className:mz("text-[0.8rem] font-medium text-destructive",e),...t,children:s}):null}));oAe.displayName="FormMessage";const sAe="onboarding",lAe="settings",uAe="todo",cAe="active",dAe="done",mAe={[dAe]:{icon:bB,className:"w-5 h-5 fill-green-500 text-background",style:{width:"1.5rem",height:"1.5rem"}},[cAe]:{icon:AB,className:"w-5 h-5 text-primary"},[uAe]:{icon:SB,className:"w-5 h-5 text-muted-foreground/60"}},hAe=a.createContext(null);function pAe({config:e,onStepChange:n,onClose:t}){const i=e.steps.map((e=>e.key)),[r,o]=a.useState(e.initialStep||i[0]),[s,l]=a.useState(new Set),[u,c]=a.useState(new Set([r])),[d,m]=a.useState({}),h=i.indexOf(r),p=0===h,g=h===i.length-1,f=!g,v=!p,y=a.useCallback((e=>{i.includes(e)&&(o(e),c((a=>new Set([...a,e]))),n?.(e))}),[i,n]),k=a.useCallback((()=>{if(f){y(i[h+1])}else g&&t&&t()}),[f,h,i,y,g,t]),b=a.useCallback((()=>{if(v){y(i[h-1])}}),[v,h,i,y]),S=a.useCallback((e=>{l((a=>new Set([...a,e])))}),[]),A=a.useCallback(((e,a)=>{m((n=>({...n,[e]:a}))),S(e)}),[S]),w=a.useCallback((e=>s.has(e)),[s]),M=a.useCallback((e=>u.has(e)),[u]);return{navigation:{currentStep:r,steps:i,goToStep:y,goToNextStep:k,goToPreviousStep:b,canGoNext:f,canGoPrevious:v,currentStepIndex:h,isFirstStep:p,isLastStep:g},state:{completedSteps:Array.from(s),visitedSteps:Array.from(u),formData:d,markStepComplete:S,isStepComplete:w,isStepVisited:M,updateFormData:A}}}const gAe=sq,fAe=lq,vAe=uq,yAe=r.forwardRef((({className:e,...a},t)=>n.jsx(cq,{className:mz("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a,ref:t})));yAe.displayName=cq.displayName;const kAe=XL("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),bAe=r.forwardRef((({side:e="right",className:a,children:t,...i},r)=>n.jsxs(vAe,{children:[n.jsx(yAe,{}),n.jsxs(dq,{ref:r,className:mz(kAe({side:e}),a),"data-reach-root":!0,...i,children:[t,n.jsxs(pq,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[n.jsx(yR,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]})));bAe.displayName=dq.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(mq,{ref:t,className:mz("text-lg font-semibold text-foreground",e),...a}))).displayName=mq.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(hq,{ref:t,className:mz("text-sm text-muted-foreground",e),...a}))).displayName=hq.displayName;const SAe="reach-wizard-sidebar-module__buttonBase___yHuwB",AAe="reach-wizard-sidebar-module__buttonOnboarding___0P7B4",wAe="reach-wizard-sidebar-module__buttonSettings___JKPkG",MAe="reach-wizard-sidebar-module__buttonOnboardingActive___NyRja",CAe="reach-wizard-sidebar-module__buttonSettingsActive___NZlSF",TAe=XL(["reach-wizard-sidebar-module__base___-bfXZ"],{variants:{mode:{onboarding:"reach-wizard-sidebar-module__onboarding___pxUBM",settings:"reach-wizard-sidebar-module__settings___m6NkU"}},defaultVariants:{mode:sAe}}),xAe=XL([SAe],{variants:{mode:{onboarding:AAe,settings:wAe},isActive:{true:"",false:""}},defaultVariants:{mode:sAe,isActive:!1}}),NAe=({status:e})=>{const a=mAe[e]??mAe[uAe];return n.jsx(a.icon,{className:a.className,...a.style&&{style:a.style}})},EAe=({items:e,currentItem:a,onItemChange:t,completedItems:i=[],mode:r=sAe,className:o})=>n.jsx("div",{className:mz(TAe({mode:r}),o,r===sAe?"":"max-w-[22ch]"),children:n.jsx("div",{className:mz(r===sAe?"space-y-1":"space-y-2"),children:e.map((e=>{const o=e.status||((e,a,n=[])=>n.includes(e)?dAe:e===a?cAe:uAe)(e.key,a,i),s=a===e.key,l=e.icon;return n.jsxs(f3,{variant:s?"secondary":"ghost",onClick:()=>t(e.key),className:mz(xAe({mode:r,isActive:s}),"group",r===sAe&&s&&MAe,r===lAe&&s&&CAe),children:[r===sAe&&n.jsx("div",{className:"w-7 h-7 flex items-center justify-center flex-shrink-0",children:n.jsx(NAe,{status:o})}),r===lAe&&l&&n.jsx(l,{className:"w-4 h-4 transition-colors",style:{color:o===cAe?"hsl(var(--reach-foreground))":"hsl(var(--reach-muted-foreground) / 0.5)"}}),n.jsx("span",{className:"text-sm font-medium",children:e.label})]},e.key)}))})}),_Ae=({open:e,onOpenChange:t,title:i,description:r,sidebarItems:o,currentStep:s,onStepChange:l,completedSteps:u=[],mode:c="onboarding",showSidebar:d=!0,showMobileNav:m=!0,children:h,className:p,contentClassName:g})=>{const[f,v]=a.useState(!1);return n.jsx(Cq,{open:e,onOpenChange:t,modal:!0,children:n.jsxs(Eq,{className:mz("@container/wizard w-[90vw] max-h-[90vh] h-full flex flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl p-0",p),onEscapeKeyDown:()=>{t(!1)},onPointerDownOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onInteractOutside:e=>{const a=e.target;(e.composedPath().some((e=>"classList"in e&&Array.from(e.classList).includes("pac-item")))||a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onFocusOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},children:[n.jsxs(wq,{children:[n.jsx(jq,{children:i}),n.jsx(Lq,{children:r})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex",children:[d&&n.jsxs(n.Fragment,{children:[n.jsx(EAe,{mode:c,items:o,currentItem:s,onItemChange:l,completedItems:u,className:"hidden @lg/wizard:block"}),m&&n.jsxs(gAe,{open:f,onOpenChange:v,children:[n.jsx(fAe,{asChild:!0,children:n.jsx(f3,{variant:"ghost",size:"icon",className:"flex @lg/wizard:hidden absolute top-4 left-4 z-10",children:n.jsx(KB,{className:"h-4 w-4"})})}),n.jsx(bAe,{side:"left",className:"w-64 p-0",children:n.jsx(EAe,{mode:c,items:o,currentItem:s,onItemChange:e=>{l(e),m&&v(!1)},completedItems:u,className:"border-r-0"})})]})]}),n.jsx("div",{className:mz("flex-1 min-h-0",g),children:h})]})]})})},PAe=({title:e,description:a,className:t})=>n.jsxs("div",{className:mz("px-8",t),children:[n.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:e}),a&&n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:a})]}),jAe=({control:e,name:a,label:t,placeholder:i,type:r="text",disabled:o})=>n.jsx(eAe,{control:e,name:a,render:({field:e})=>n.jsxs(tAe,{children:[n.jsx(iAe,{children:t}),n.jsx(rAe,{children:n.jsx(U7,{...e,type:r,placeholder:i,disabled:o,className:"bg-background"})}),n.jsx(oAe,{})]})}),LAe=({control:e,name:a,label:t,placeholder:i,options:r,disabled:o})=>n.jsx(eAe,{control:e,name:a,render:({field:e})=>n.jsxs(tAe,{children:[n.jsx(iAe,{children:t}),n.jsxs(Zke,{onValueChange:e.onChange,value:e.value,disabled:o,children:[n.jsx(rAe,{children:n.jsx(Qke,{className:"bg-background",children:n.jsx(Yke,{placeholder:i})})}),n.jsx(abe,{children:r.map((e=>n.jsx(nbe,{value:e.value,children:n.jsxs("div",{className:"flex flex-col text-left",children:[n.jsx("span",{children:e.label}),e.description&&n.jsx("span",{className:"text-xs text-muted-foreground",children:e.description})]})},e.value)))})]}),n.jsx(oAe,{})]})}),BAe=({title:e,description:a,children:t,variant:i="default"})=>n.jsxs("div",{className:"highlighted"===i?"bg-muted/50 p-6 rounded-lg border border-muted space-y-4":"space-y-4",children:[e&&n.jsx("h3",{className:"text-lg font-medium text-foreground",children:e}),a&&n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a}),n.jsx("div",{className:"space-y-4",children:t})]}),RAe=({variant:e="default",onBack:a,onNext:t,onSkip:i,isSubmitting:r=!1,canGoBack:o=!0,canGoNext:s=!0,backLabel:l="Back",nextLabel:u="Next",skipLabel:c="Skip",className:d,mode:m})=>{const h="compact"===e?"sm":"default",p="default"===e?"text-sm":"";return n.jsxs("div",{className:mz("flex items-center","compact"===e?"gap-2":"justify-between gap-4",d),children:[a&&n.jsxs(f3,{variant:"outline",size:h,onClick:a,disabled:r||!o,className:mz("flex items-center gap-2",p),children:[n.jsx(pB,{className:"w-4 h-4"}),l]}),n.jsxs("div",{className:"flex items-center gap-4 ml-auto",children:[i&&n.jsx(f3,{variant:"outline",size:h,onClick:i,disabled:r,className:mz("flex items-center gap-2",p),children:c}),t&&n.jsx(f3,{size:h,onClick:t,disabled:r||!s,className:mz("flex items-center gap-2",p),children:n.jsxs(n.Fragment,r?{children:[n.jsx(RB,{className:"w-4 h-4 animate-spin"}),"Saving..."]}:{children:[u,"onboarding"===m&&n.jsx(oB,{className:"w-4 h-4"})]})})]})]})},zAe=a.forwardRef((({children:e,className:a,showNavigation:t=!0,mode:i="onboarding",...r},o)=>{const s="settings"!==i&&r.onBack;return n.jsxs("div",{ref:o,className:mz("h-full flex flex-col",a),children:[n.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-y-auto pt-10 @lg/onboarding-sidebar:pt-16",children:[n.jsx(PAe,{title:r.title,description:r.description}),n.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e})]}),t&&n.jsx("div",{className:"border-t border-border py-6 px-8 bg-background",children:n.jsx(RAe,{onBack:s?r.onBack:void 0,onNext:r.onNext,onSkip:r.onSkip,isSubmitting:r.isSubmitting,canGoBack:r.canGoBack,canGoNext:r.canGoNext,backLabel:r.backLabel||"Previous Step",nextLabel:r.submitLabel||"Next step",skipLabel:r.skipLabel||"Not now",mode:i})})]})}));zAe.displayName="WizardFormWrapper";const DAe=(e,a,n)=>{if(e&&"reportValidity"in e){const t=Obe(n,a);e.setCustomValidity(t&&t.message||""),e.reportValidity()}},OAe=(e,a)=>{for(const n in a.fields){const t=a.fields[n];t&&t.ref&&"reportValidity"in t.ref?DAe(t.ref,n,e):t.refs&&t.refs.forEach((a=>DAe(a,n,e)))}},KAe=(e,a)=>{a.shouldUseNativeValidation&&OAe(e,a);const n={};for(const t in e){const i=Obe(a.fields,t),r=Object.assign(e[t]||{},{ref:i&&i.ref});if(HAe(a.names||Object.keys(e),t)){const e=Object.assign({},Obe(n,t));Gbe(e,"root",r),Gbe(n,t,e)}else Gbe(n,t,r)}return n},HAe=(e,a)=>e.some((e=>e.startsWith(a+".")));var IAe=function(e,a){for(var n={};e.length;){var t=e[0],i=t.code,r=t.message,o=t.path.join(".");if(!n[o])if("unionErrors"in t){var s=t.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:r,type:i};if("unionErrors"in t&&t.unionErrors.forEach((function(a){return a.errors.forEach((function(a){return e.push(a)}))})),a){var l=n[o].types,u=l&&l[t.code];n[o]=pSe(o,a,n,i,u?[].concat(u,t.message):t.message)}e.shift()}return n},GAe=function(e,a,n){return void 0===n&&(n={}),function(t,i,r){try{return Promise.resolve(function(i,o){try{var s=Promise.resolve(e["sync"===n.mode?"parse":"parseAsync"](t,a)).then((function(e){return r.shouldUseNativeValidation&&OAe({},r),{errors:{},values:n.raw?t:e}}))}catch(jHe){return o(jHe)}return s&&s.then?s.then(void 0,o):s}(0,(function(e){if(a=e,Array.isArray(null==a?void 0:a.errors))return{values:{},errors:KAe(IAe(e.errors,!r.shouldUseNativeValidation&&"all"===r.criteriaMode),r)};var a;throw e})))}catch(jHe){return Promise.reject(jHe)}}};const FAe=[{code:"US",name:"United States"},{code:"AE",name:"United Arab Emirates"},{code:"AF",name:"Afghanistan"},{code:"AM",name:"Armenia"},{code:"AR",name:"Argentina"},{code:"AT",name:"Austria"},{code:"AU",name:"Australia"},{code:"AZ",name:"Azerbaijan"},{code:"BD",name:"Bangladesh"},{code:"BE",name:"Belgium"},{code:"BF",name:"Burkina Faso"},{code:"BG",name:"Bulgaria"},{code:"BH",name:"Bahrain"},{code:"BI",name:"Burundi"},{code:"BJ",name:"Benin"},{code:"BO",name:"Bolivia"},{code:"BR",name:"Brazil"},{code:"BT",name:"Bhutan"},{code:"BW",name:"Botswana"},{code:"BY",name:"Belarus"},{code:"CA",name:"Canada"},{code:"CD",name:"Democratic Republic of the Congo"},{code:"CF",name:"Central African Republic"},{code:"CG",name:"Republic of the Congo"},{code:"CH",name:"Switzerland"},{code:"CI",name:"Ivory Coast"},{code:"CL",name:"Chile"},{code:"CM",name:"Cameroon"},{code:"CN",name:"China"},{code:"CO",name:"Colombia"},{code:"CV",name:"Cape Verde"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DE",name:"Germany"},{code:"DJ",name:"Djibouti"},{code:"DK",name:"Denmark"},{code:"DZ",name:"Algeria"},{code:"EC",name:"Ecuador"},{code:"EE",name:"Estonia"},{code:"EG",name:"Egypt"},{code:"ER",name:"Eritrea"},{code:"ES",name:"Spain"},{code:"ET",name:"Ethiopia"},{code:"FI",name:"Finland"},{code:"FJ",name:"Fiji"},{code:"FK",name:"Falkland Islands"},{code:"FR",name:"France"},{code:"GA",name:"Gabon"},{code:"GB",name:"United Kingdom"},{code:"GE",name:"Georgia"},{code:"GF",name:"French Guiana"},{code:"GH",name:"Ghana"},{code:"GM",name:"Gambia"},{code:"GN",name:"Guinea"},{code:"GQ",name:"Equatorial Guinea"},{code:"GR",name:"Greece"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HK",name:"Hong Kong"},{code:"HR",name:"Croatia"},{code:"HU",name:"Hungary"},{code:"ID",name:"Indonesia"},{code:"IE",name:"Ireland"},{code:"IL",name:"Israel"},{code:"IN",name:"India"},{code:"IQ",name:"Iraq"},{code:"IR",name:"Iran"},{code:"IS",name:"Iceland"},{code:"IT",name:"Italy"},{code:"JO",name:"Jordan"},{code:"JP",name:"Japan"},{code:"KE",name:"Kenya"},{code:"KG",name:"Kyrgyzstan"},{code:"KM",name:"Comoros"},{code:"KR",name:"South Korea"},{code:"KW",name:"Kuwait"},{code:"KZ",name:"Kazakhstan"},{code:"LB",name:"Lebanon"},{code:"LK",name:"Sri Lanka"},{code:"LR",name:"Liberia"},{code:"LS",name:"Lesotho"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"LV",name:"Latvia"},{code:"LY",name:"Libya"},{code:"MA",name:"Morocco"},{code:"MD",name:"Moldova"},{code:"MG",name:"Madagascar"},{code:"ML",name:"Mali"},{code:"MO",name:"Macau"},{code:"MR",name:"Mauritania"},{code:"MT",name:"Malta"},{code:"MU",name:"Mauritius"},{code:"MV",name:"Maldives"},{code:"MW",name:"Malawi"},{code:"MX",name:"Mexico"},{code:"MY",name:"Malaysia"},{code:"MZ",name:"Mozambique"},{code:"NA",name:"Namibia"},{code:"NC",name:"New Caledonia"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NL",name:"Netherlands"},{code:"NO",name:"Norway"},{code:"NP",name:"Nepal"},{code:"NZ",name:"New Zealand"},{code:"OM",name:"Oman"},{code:"PE",name:"Peru"},{code:"PF",name:"French Polynesia"},{code:"PG",name:"Papua New Guinea"},{code:"PH",name:"Philippines"},{code:"PK",name:"Pakistan"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PY",name:"Paraguay"},{code:"QA",name:"Qatar"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"SA",name:"Saudi Arabia"},{code:"SC",name:"Seychelles"},{code:"SD",name:"Sudan"},{code:"SE",name:"Sweden"},{code:"SG",name:"Singapore"},{code:"SI",name:"Slovenia"},{code:"SK",name:"Slovakia"},{code:"SL",name:"Sierra Leone"},{code:"SN",name:"Senegal"},{code:"SO",name:"Somalia"},{code:"SR",name:"Suriname"},{code:"SS",name:"South Sudan"},{code:"ST",name:"São Tomé and Príncipe"},{code:"SY",name:"Syria"},{code:"SZ",name:"Eswatini"},{code:"TD",name:"Chad"},{code:"TG",name:"Togo"},{code:"TH",name:"Thailand"},{code:"TJ",name:"Tajikistan"},{code:"TM",name:"Turkmenistan"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TW",name:"Taiwan"},{code:"TZ",name:"Tanzania"},{code:"UA",name:"Ukraine"},{code:"UG",name:"Uganda"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"YE",name:"Yemen"},{code:"ZA",name:"South Africa"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}];var VAe=(e=>(e.BRAND="brand",e.BUSINESS="business",e.EMAIL="email",e.SMS="sms",e.MERGE_FIELDS="merge-fields",e.SPLASH="splash",e.BUSINESS_SKIP_INTERSTITIAL="business-skip-interstitial",e.SMS_INTERSTITIAL="sms-interstitial",e.COMPLETION="completion",e))(VAe||{});const JAe="Engage Settings",UAe="Configure your brand, business, and channel settings",WAe="Engage Setup",qAe="Set up your brand and channels for email and SMS marketing",ZAe="Brand Settings",$Ae="Business Information",YAe="Email Channel",QAe="SMS Channel",XAe="Merge Fields",ewe="Customize Your Brand",awe="Business Settings",nwe="Email Channel Settings",twe="Connect Your SMS",iwe="DBA legal name",rwe="ZIP Code",owe="ZIP code",swe="Select country",lwe="First Name",uwe="First name",cwe="Last Name",dwe="Last name",mwe="Email address",hwe="Contact Phone",pwe="Auto Parse",gwe={brand:{label:ZAe},business:{label:$Ae},email:{label:YAe},sms:{label:QAe},"merge-fields":{label:XAe}},fwe=[{key:"brand",label:gwe.brand.label},{key:"business",label:gwe.business.label},{key:"email",label:gwe.email.label},{key:"sms",label:gwe.sms.label},{key:"merge-fields",label:gwe["merge-fields"].label}],vwe=[{key:"brand",label:gwe.brand.label},{key:"email",label:gwe.email.label},{key:"business",label:gwe.business.label},{key:"sms",label:gwe.sms.label},{key:"merge-fields",label:gwe["merge-fields"].label},{key:"completion",label:"Completion"}],ywe=({control:e,disabled:a=!1,namePrefix:t="company",context:i="email"})=>{const r="email"===i,o=FAe.map((e=>({value:e.code,label:e.name})));return n.jsxs(n.Fragment,{children:[r&&n.jsx("div",{className:"rounded-lg border border-blue-100 bg-blue-50 p-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-blue-100",children:n.jsx(DB,{className:"w-4 h-4 text-blue-600"})})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h4",{className:"text-sm font-medium text-blue-900 mb-1",children:"Email Footer Information"}),n.jsx("p",{className:"text-sm text-blue-700",children:"Your business address will be included in email footers as required by law. This ensures compliance with email marketing regulations and provides recipients with your business contact information."})]})]})}),n.jsx(jAe,{control:e,name:`${t}.name`,label:iwe,placeholder:"Enter your DBA or legal business name",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.address1`,label:"Business Address",placeholder:"Street address",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.address2`,label:"Business Address Line 2",placeholder:"Apartment, suite, unit, etc. (optional)",disabled:a}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsx(jAe,{control:e,name:`${t}.city`,label:"City",placeholder:"City",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.stateProvince`,label:"State/Province",placeholder:"State/Province",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.zipCode`,label:rwe,placeholder:owe,disabled:a})]}),n.jsx(LAe,{control:e,name:`${t}.country`,label:"Country",placeholder:swe,options:o,disabled:a})]})},kwe=({control:e,disabled:a=!1,namePrefix:t="contact"})=>n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsx(jAe,{control:e,name:`${t}.firstName`,label:lwe,placeholder:uwe,disabled:a}),n.jsx(jAe,{control:e,name:`${t}.lastName`,label:cwe,placeholder:dwe,disabled:a})]}),n.jsx(jAe,{control:e,name:`${t}.email`,label:"Email",placeholder:mwe,type:"email",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.phoneNumber`,label:hwe,placeholder:"+1234567890",description:"Must start with + and country code",type:"tel",disabled:a})]}),bwe=$re,Swe=a.forwardRef((({isSubmitting:e,onSubmit:t,hideSubmitButton:i=!1},r)=>{const o=YSe({resolver:GAe(bwe),defaultValues:{type:Wre.TWILIO_TOLL_FREE_NUMBER,tollFreeNumber:"",company:{name:"",address1:"",address2:"",city:"",stateProvince:"",zipCode:"",country:""},contact:{firstName:"",lastName:"",email:"",phoneNumber:""},messagingUseCase:{monthlyVolume:0,category:qre.PROMOTIONS_MARKETING,useCaseDetails:""},messageSamples:[""]},values:void 0}),s=o.watch("messageSamples");a.useImperativeHandle(r,(()=>({submit:()=>{o.handleSubmit(l)()}})));const l=async e=>{const a={...e,messagingUseCase:{...e.messagingUseCase,monthlyVolume:Number(e.messagingUseCase.monthlyVolume)}};await t(a)};return n.jsx("div",{className:"w-full max-w-4xl text-left",children:n.jsx(QSe,{...o,children:n.jsxs("form",{onSubmit:o.handleSubmit(l),className:"space-y-6",children:[n.jsx(BAe,{title:"Legal Business Settings",description:"Provide your legal business information required for SMS channel verification and future communications.",children:n.jsx(ywe,{control:o.control,disabled:e,context:"sms"})}),n.jsx(BAe,{title:"Contact Information",description:"Provide the contact information of the person authorized to represent your business.",children:n.jsx(kwe,{control:o.control,disabled:e})}),n.jsxs(BAe,{title:"Messaging Use Case",description:"Tell us about how you plan to use SMS messaging.",children:[n.jsx(jAe,{control:o.control,name:"messagingUseCase.monthlyVolume",label:"Expected Monthly Volume",placeholder:"1000",type:"number",disabled:e}),n.jsx(jAe,{control:o.control,name:"messagingUseCase.useCaseDetails",label:"Use Case Details",placeholder:"Describe your use case in detail",disabled:e})]}),n.jsxs(BAe,{title:"Message Samples",description:"Provide examples of messages you plan to send (up to 3 samples).",children:[n.jsx(Yq,{children:s.map(((a,t)=>n.jsxs(R2.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"relative",children:[n.jsx(jAe,{control:o.control,name:`messageSamples.${t}`,label:`Sample Message ${t+1}`,placeholder:"Enter a sample message",disabled:e}),s.length>1&&n.jsx(R2.button,{type:"button",onClick:()=>(e=>{if(s.length>1){const a=s.filter(((a,n)=>n!==e));o.setValue("messageSamples",a)}})(t),className:"absolute -right-2 -top-2 rounded-full bg-destructive/10 p-1 text-destructive hover:bg-destructive/20",whileHover:{scale:1.1},whileTap:{scale:.9},children:n.jsx(b3.CloseButton,{className:"h-4 w-4"})})]},t)))}),s.length<3&&n.jsxs(R2.button,{type:"button",onClick:()=>{s.length<3&&o.setValue("messageSamples",[...s,""])},className:"mt-4 flex items-center gap-2 rounded-lg border border-dashed border-border px-4 py-2 text-sm text-muted-foreground hover:border-border/80 hover:text-foreground",whileHover:{scale:1.02},whileTap:{scale:.98},children:[n.jsx(b3.PlusIcon,{className:"h-4 w-4"}),"Add another sample"]})]}),!i&&n.jsx("div",{className:"flex gap-3 pt-4 justify-end",children:n.jsx(f3,{type:"submit",disabled:e,children:e?"Submitting...":"Submit for approval"})})]})})})})),Awe=({onSubmit:e,onApplicationSubmit:t,hideSubmitButton:i=!1,formRef:r,onFormVisibilityChange:o})=>{const[s,l]=a.useState(!1),{data:u,isLoading:c}=yte(),{createSmsRegistrationApplication:d,isCreating:m}=kte();a.useEffect((()=>{o?.(s)}),[s,o]);if(!u||c)return n.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:n.jsx(Dq,{text:["Loading business information..."]})});const h={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}},p=u&&u.status===Yre.PENDING;return n.jsxs(R2.div,{initial:"hidden",animate:"visible",exit:"exit",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1],staggerChildren:.1}},exit:{opacity:0,y:-20,transition:{duration:.3,ease:[.4,0,1,1]}}},className:mz("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto","bg-background"),children:[n.jsx(R2.div,{variants:h,className:"w-16 h-16 rounded-xl flex items-center justify-center",children:n.jsx(b3.SmsIcon,{})}),n.jsx(R2.h2,{variants:h,className:"text-sm font-medium text-foreground",children:"Request your SMS sending number"}),n.jsxs(R2.div,{variants:h,className:"max-w-xl mx-auto",children:[n.jsx("p",{className:"text-sm font-normal text-muted-foreground mb-2",children:"Before you can send messages, we need to verify your business info with our SMS provider. Once approved, we'll assign you a phone number to send SMS campaigns."}),n.jsx("p",{className:"text-sm font-normal text-muted-foreground",children:"This usually takes 3-7 business days."})]}),n.jsx(Yq,{mode:"wait",children:s?n.jsx(R2.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3,ease:[.4,0,.2,1]},className:"w-full",children:n.jsx(Swe,{isSubmitting:m,onSubmit:async a=>{if(t)await t(a);else try{d({application:a,onSuccess:()=>{l(!1),e?.()}})}catch(n){}},hideSubmitButton:i,ref:r})},"form"):p?n.jsxs(R2.div,{variants:h,className:"flex items-center gap-2 px-3 py-1.5 bg-orange-50 border border-orange-200 rounded-full",children:[n.jsx(R2.div,{animate:{scale:[1,1.2,1],opacity:[1,.8,1]},transition:{duration:2,repeat:Number.POSITIVE_INFINITY,ease:"easeInOut"},className:"w-2 h-2 bg-orange-500 rounded-full"}),n.jsx("span",{className:"text-sm font-medium text-orange-800",children:"Pending approval"})]},"pending"):n.jsx(R2.div,{variants:h,children:n.jsx(f3,{variant:"outline",className:"bg-background",onClick:()=>l(!0),children:"Request approval"})},"button")})]})},wwe=e=>{const{companyName:a,smsBody:n}=e;return a&&n?`${a}:\n${n}`:n??""},Mwe="undefined"!=typeof window&&"undefined"!=typeof document;function Cwe(e){if(!e.startsWith("data:"))throw new Error('Invalid data URL: must start with "data:"');const a=e.split(",");if(2!==a.length)throw new Error("Invalid data URL format: missing base64 data");if(!a[0].includes(";base64"))throw new Error("Invalid data URL format: missing base64 encoding");return a[1]}const Twe=(e,a)=>{if(!e||!a)return[];return[...e.matchAll(/\{\{([^}]+)\}\}/g)].map((e=>{const n=e[1],t=a.mergeFields?.flatMap((e=>e.entries)).find((e=>e.value===`{{${n}}}`));return t?t.label:n})).filter(Boolean)},xwe=e=>{switch(e){case"default":default:return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200";case"subtle":return"inline-flex items-center font-medium mx-[1px] leading-none align-middle px-1 py-0.5 rounded-md bg-white/30 text-inherit shadow-[0_0_0_1px_rgba(0,0,0,0.05)]";case"minimal":return"inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-gray-50 text-gray-700 font-medium border border-gray-200";case"inline":return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-gray-100 text-gray-800 font-medium";case"badge":return"inline-flex items-center px-2 py-1 rounded-full text-xs bg-indigo-100 text-indigo-800 font-medium border border-indigo-200"}},Nwe=({content:e,mergeFieldsResponse:t,variant:i="default",className:r="",asHtml:o=!0})=>{const s=a.useMemo((()=>t?.mergeFields?.flatMap((e=>e.entries))??[]),[t]),l=a.useMemo((()=>((e,a,n)=>e?e.replace(/\{\{.*?\}\}/g,(e=>{const t=a.find((a=>a.value===e));return t?`<span class="${xwe(n)}" data-merge-field="true" data-template-name="${t.value}" data-display-name="${t.label}">${t.label}</span>`:e})):"")(e,s,i)),[e,s,i]);if(!o){const a=e?.replace(/\{\{.*?\}\}/g,(e=>{const a=s.find((a=>a.value===e));return a?a.label:e}))||"";return n.jsx("span",{className:r,children:a})}return n.jsx("span",{className:r,dangerouslySetInnerHTML:{__html:l}})},Ewe=({body:e,imageUrls:t})=>{const i=d3(),{getMergeFields:r,isGetting:o}=la(i?.id??void 0),s=a.useCallback((e=>/\{\{[^}]+\}\}/.test(e)),[]);return o||void 0===r?null:n.jsx("div",{className:"sms-preview-outer @container",children:n.jsxs("div",{className:"sms-phone-mockup",children:[n.jsx("div",{className:"sms-phone-notch"}),n.jsxs("div",{className:"sms-phone-inner",children:[t&&t.length>0&&t.map(((e,a)=>n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:s(e)?n.jsx("div",{className:"sms-message-image-placeholder",children:n.jsxs("div",{className:"text-center text-white text-[10px] leading-tight",children:[n.jsx("div",{className:"font-medium mb-1",children:"Image will be populated at send time based on the following merge fields:"}),n.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:Twe(e,r).map(((e,a)=>n.jsx("span",{className:"inline-flex items-center px-1 py-0.5 rounded text-[10px] bg-green-500/30 text-white font-medium border border-green-400/40",children:e},a)))})]})}):n.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:n.jsx(Nwe,{content:e,mergeFieldsResponse:r,variant:"subtle",className:"text-white"})})})]}),n.jsx("div",{className:"sms-phone-home-indicator"})]})})};function _we(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}var Pwe="Checkbox",[jwe,Lwe]=H4(Pwe),[Bwe,Rwe]=jwe(Pwe),zwe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:t,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),f=vq(a,(e=>g(e))),v=r.useRef(!1),y=!p||(m||!!p.closest("form")),[k=!1,b]=F4({prop:o,defaultProp:s,onChange:d}),S=r.useRef(k);return r.useEffect((()=>{const e=p?.form;if(e){const a=()=>b(S.current);return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)}}),[p,b]),n.jsxs(Bwe,{scope:t,state:k,disabled:u,children:[n.jsx(Z4.button,{type:"button",role:"checkbox","aria-checked":Hwe(k)?"mixed":k,"aria-required":l,"data-state":Iwe(k),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:f,onKeyDown:K4(e.onKeyDown,(e=>{"Enter"===e.key&&e.preventDefault()})),onClick:K4(e.onClick,(e=>{b((e=>!!Hwe(e)||!e)),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())}))}),y&&n.jsx(Kwe,{control:p,bubbles:!v.current,name:i,value:c,checked:k,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"},defaultChecked:!Hwe(s)&&s})]})}));zwe.displayName=Pwe;var Dwe="CheckboxIndicator",Owe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:t,forceMount:i,...r}=e,o=Rwe(Dwe,t);return n.jsx(T8,{present:i||Hwe(o.state)||!0===o.state,children:n.jsx(Z4.span,{"data-state":Iwe(o.state),"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{pointerEvents:"none",...e.style}})})}));Owe.displayName=Dwe;var Kwe=e=>{const{control:a,checked:t,bubbles:i=!0,defaultChecked:o,...s}=e,l=r.useRef(null),u=_we(t),c=n8(a);r.useEffect((()=>{const e=l.current,a=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(a,"checked").set;if(u!==t&&n){const a=new Event("click",{bubbles:i});e.indeterminate=Hwe(t),n.call(e,!Hwe(t)&&t),e.dispatchEvent(a)}}),[u,t,i]);const d=r.useRef(!Hwe(t)&&t);return n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??d.current,...s,tabIndex:-1,ref:l,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Hwe(e){return"indeterminate"===e}function Iwe(e){return Hwe(e)?"indeterminate":e?"checked":"unchecked"}var Gwe=zwe,Fwe=Owe;const Vwe=r.forwardRef((({className:e,...a},t)=>n.jsx(Gwe,{ref:t,className:mz("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...a,children:n.jsx(Fwe,{className:mz("flex items-center justify-center text-current"),children:n.jsx(mB,{className:"h-4 w-4"})})})));Vwe.displayName=Gwe.displayName;var Jwe=.999,Uwe=/[\\\/_+.#"@\[\(\{&]/,Wwe=/[\\\/_+.#"@\[\(\{&]/g,qwe=/[\s-]/,Zwe=/[\s-]/g;function $we(e,a,n,t,i,r,o){if(r===a.length)return i===e.length?1:.99;var s=`${i},${r}`;if(void 0!==o[s])return o[s];for(var l,u,c,d,m=t.charAt(r),h=n.indexOf(m,i),p=0;h>=0;)(l=$we(e,a,n,t,h+1,r+1,o))>p&&(h===i?l*=1:Uwe.test(e.charAt(h-1))?(l*=.8,(c=e.slice(i,h-1).match(Wwe))&&i>0&&(l*=Math.pow(Jwe,c.length))):qwe.test(e.charAt(h-1))?(l*=.9,(d=e.slice(i,h-1).match(Zwe))&&i>0&&(l*=Math.pow(Jwe,d.length))):(l*=.17,i>0&&(l*=Math.pow(Jwe,h-i))),e.charAt(h)!==a.charAt(r)&&(l*=.9999)),(l<.1&&n.charAt(h-1)===t.charAt(r+1)||t.charAt(r+1)===t.charAt(r)&&n.charAt(h-1)!==t.charAt(r))&&(.1*(u=$we(e,a,n,t,h+1,r+2,o))>l&&(l=.1*u)),l>p&&(p=l),h=n.indexOf(m,h+1);return o[s]=p,p}function Ywe(e){return e.toLowerCase().replace(Zwe," ")}function Qwe(e,a,n){return $we(e=n&&n.length>0?""+(e+" "+n.join(" ")):e,a,Ywe(e),Ywe(a),0,0,{})}var Xwe,eMe={exports:{}},aMe={};var nMe,tMe={};
83
+ */_ge.exports="production"===process.env.NODE_ENV?function(){if(xge)return Pge;xge=1;var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},n=Sge.useSyncExternalStore,t=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;return Pge.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d=t(null);if(null===d.current){var m={hasValue:!1,value:null};d.current=m}else m=d.current;d=r((function(){function a(a){if(!i){if(i=!0,n=a,a=u(a),void 0!==c&&m.hasValue){var r=m.value;if(c(r,a))return t=r}return t=a}if(r=t,e(n,a))return r;var o=u(a);return void 0!==c&&c(r,o)?r:(n=a,t=o)}var n,t,i=!1,r=void 0===l?null:l;return[function(){return a(s())},null===r?void 0:function(){return a(r())}]}),[s,l,u,c]);var h=n(a,d[0],d[1]);return i((function(){m.hasValue=!0,m.value=h}),[h]),o(h),h},Pge}():(jge||(jge=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},n=Sge.useSyncExternalStore,t=a.useRef,i=a.useEffect,r=a.useMemo,o=a.useDebugValue;Lge.useSyncExternalStoreWithSelector=function(a,s,l,u,c){var d,m=t(null);null===m.current?m.current=d={hasValue:!1,value:null}:d=m.current;var h=r((function(){var a,n,t=!1,i=function(i){if(!t){t=!0,a=i;var r=u(i);if(void 0!==c&&d.hasValue){var o=d.value;if(c(o,r))return n=o,o}return n=r,r}var s=n;if(e(a,i))return s;var l=u(i);return void 0!==c&&c(s,l)?s:(a=i,n=l,l)},r=void 0===l?null:l;return[function(){return i(s())},null===r?void 0:function(){return i(r())}]}),[s,l,u,c]),p=n(a,h[0],h[1]);return i((function(){d.hasValue=!0,d.value=p}),[p]),o(p),p},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Lge);var Bge=_ge.exports;const Rge="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;class zge{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach((e=>e()))},a=this.editor;return a.on("transaction",e),()=>{a.off("transaction",e)}}}}const Dge="production"!==process.env.NODE_ENV,Oge="undefined"==typeof window,Kge=Oge||Boolean("undefined"!=typeof window&&window.next);class Hge{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((e=>e()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return Oge||Kge?null:this.createEditor();if(this.options.current.immediatelyRender&&Oge&&Dge)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(a,...e)},onBlur:(...e)=>{var a,n;return null===(n=(a=this.options.current).onBlur)||void 0===n?void 0:n.call(a,...e)},onCreate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onCreate)||void 0===n?void 0:n.call(a,...e)},onDestroy:(...e)=>{var a,n;return null===(n=(a=this.options.current).onDestroy)||void 0===n?void 0:n.call(a,...e)},onFocus:(...e)=>{var a,n;return null===(n=(a=this.options.current).onFocus)||void 0===n?void 0:n.call(a,...e)},onSelectionUpdate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(a,...e)},onTransaction:(...e)=>{var a,n;return null===(n=(a=this.options.current).onTransaction)||void 0===n?void 0:n.call(a,...e)},onUpdate:(...e)=>{var a,n;return null===(n=(a=this.options.current).onUpdate)||void 0===n?void 0:n.call(a,...e)},onContentError:(...e)=>{var a,n;return null===(n=(a=this.options.current).onContentError)||void 0===n?void 0:n.call(a,...e)},onDrop:(...e)=>{var a,n;return null===(n=(a=this.options.current).onDrop)||void 0===n?void 0:n.call(a,...e)},onPaste:(...e)=>{var a,n;return null===(n=(a=this.options.current).onPaste)||void 0===n?void 0:n.call(a,...e)}};return new lge(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,a){return Object.keys(e).every((n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&a.extensions?e.extensions.length===a.extensions.length&&e.extensions.every(((e,n)=>{var t;return e===(null===(t=a.extensions)||void 0===t?void 0:t[n])})):e[n]===a[n])))}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?Hge.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=e);if(this.previousDeps.length===e.length&&this.previousDeps.every(((a,n)=>a===e[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,a=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===e?a&&a.setOptions(this.options.current):a&&!a.isDestroyed&&(a.destroy(),this.instanceId===e&&this.setEditor(null))}),1)}}function Ige(e={},n=[]){const t=a.useRef(e);t.current=e;const[i]=a.useState((()=>new Hge(t))),r=Sge.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return a.useDebugValue(r),a.useEffect(i.onRender(n)),function(e){var n;const[t]=a.useState((()=>new zge(e.editor))),i=Bge.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,null!==(n=e.equalityFn)&&void 0!==n?n:Ege);Rge((()=>t.watch(e.editor)),[e.editor,t]),a.useDebugValue(i)}({editor:r,selector:({transactionNumber:a})=>!1===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===a?0:a+1}),r}a.createContext({editor:null});const Gge=a.createContext({onDragStart:void 0}),Fge=a.forwardRef(((e,n)=>{const{onDragStart:t}=a.useContext(Gge);return a.createElement(e.as||"div",{...e,ref:n,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...e.style}})}));function Vge(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function Jge(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}class Uge{constructor(e,{editor:a,props:n={},as:i="div",className:r=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=a,this.props=n,this.element=document.createElement(i),this.element.classList.add("react-renderer"),r&&this.element.classList.add(...r.split(" ")),this.editor.isInitialized?t.flushSync((()=>{this.render()})):this.render()}render(){var e;const n=this.component,t=this.props,i=this.editor,r=function(){try{if(a.version)return parseInt(a.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(Vge(e))return!0;if(Jge(e))return!0;if(function(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.memo)"!==e.$$typeof.toString()&&"react.memo"!==e.$$typeof.description)}(e)){const a=e.type;if(a)return Vge(a)||Jge(a)}return!1}(n),s={...t};!s.ref||r||o||delete s.ref,s.ref||!r&&!o||(s.ref=e=>{this.ref=e}),this.reactElement=a.createElement(n,{...s}),null===(e=null==i?void 0:i.contentComponent)||void 0===e||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const a=this.editor;null===(e=null==a?void 0:a.contentComponent)||void 0===e||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach((a=>{this.element.setAttribute(a,e[a])}))}}class Wge extends hge{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:a.createRef()};if(!this.component.displayName){this.component.displayName=(e=>e.charAt(0).toUpperCase()+e.substring(1))(this.extension.name)}const n={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&e.appendChild(this.contentDOMElement)}},t=this.component,i=a.memo((e=>a.createElement(Gge.Provider,{value:n},a.createElement(t,e))));i.displayName="ReactNodeView",this.contentDOMElement=this.node.isLeaf?null:this.options.contentDOMElementTag?document.createElement(this.options.contentDOMElementTag):document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let r=this.node.isInline?"span":"div";this.options.as&&(r=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Uge(i,{editor:this.editor,props:e,as:r,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null===(e=this.renderer.element.firstElementChild)||void 0===e?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:a}=this.editor.state.selection,n=this.getPos();if("number"==typeof n)if(e<=n&&a>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,a,n){const t=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,r=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=a,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:r,newNode:e,newDecorations:a,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>t({node:e,decorations:a,innerDecorations:n})})}return e===this.node&&this.decorations===a&&this.innerDecorations===n||(this.node=e,this.decorations=a,this.innerDecorations=n,t({node:e,decorations:a,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){const a=Xhe(this.node,this.editor.extensionManager.attributes);e=this.options.attrs({node:this.node,HTMLAttributes:a})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function qge(e,a){return n=>n.editor.contentComponent?new Wge(e,n,a):{}}const Zge=/^\s*>\s$/,$ge=mge.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return["blockquote",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[dge({find:Zge,type:this.type})]}}),Yge=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Qge=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Xge=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,efe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,afe=hpe.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[uge({find:Yge,type:this.type}),uge({find:Xge,type:this.type})]},addPasteRules(){return[pge({find:Qge,type:this.type}),pge({find:efe,type:this.type})]}}),nfe="textStyle",tfe=/^\s*([-+*])\s$/,ife=mge.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(nfe)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=dge({find:tfe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=dge({find:tfe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(nfe),editor:this.editor})),[e]}}),rfe=/(^|[^`])`([^`]+)`(?!`)/,ofe=/(^|[^`])`([^`]+)`(?!`)/g,sfe=hpe.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[uge({find:rfe,type:this.type})]},addPasteRules(){return[pge({find:ofe,type:this.type})]}}),lfe=/^```([a-z]+)?[\s\n]$/,ufe=/^~~~([a-z]+)?[\s\n]$/,cfe=mge.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var a;const{languageClassPrefix:n}=this.options,t=[...(null===(a=e.firstElementChild)||void 0===a?void 0:a.classList)||[]].filter((e=>e.startsWith(n))).map((e=>e.replace(n,"")))[0];return t||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:a}){return["pre",Qhe(this.options.HTMLAttributes,a),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:a})=>a.setNode(this.name,e),toggleCodeBlock:e=>({commands:a})=>a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:a}=this.editor.state.selection;return!(!e||a.parent.type.name!==this.name)&&(!(!(1===a.pos)&&a.parent.textContent.length)&&this.editor.commands.clearNodes())},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:a}=e,{selection:n}=a,{$from:t,empty:i}=n;if(!i||t.parent.type!==this.type)return!1;const r=t.parentOffset===t.parent.nodeSize-2,o=t.parent.textContent.endsWith("\n\n");return!(!r||!o)&&e.chain().command((({tr:e})=>(e.delete(t.pos-2,t.pos),!0))).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:a}=e,{selection:n,doc:t}=a,{$from:i,empty:r}=n;if(!r||i.parent.type!==this.type)return!1;if(!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();if(void 0===o)return!1;return t.nodeAt(o)?e.commands.command((({tr:e})=>(e.setSelection(Cue.near(t.resolve(o))),!0))):e.commands.exitCode()}}},addInputRules(){return[cge({find:lfe,type:this.type,getAttributes:e=>({language:e[1]})}),cge({find:ufe,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Vue({key:new Wue("codeBlockVSCodeHandler"),props:{handlePaste:(e,a)=>{if(!a.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=a.clipboardData.getData("text/plain"),t=a.clipboardData.getData("vscode-editor-data"),i=t?JSON.parse(t):void 0,r=null==i?void 0:i.mode;if(!n||!r)return!1;const{tr:o,schema:s}=e.state,l=s.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:r},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(Eue.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),dfe=mge.create({name:"doc",topNode:!0,content:"block+"});function mfe(e={}){return new Vue({view:a=>new hfe(a,e)})}class hfe{constructor(e,a){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=a.width)&&void 0!==n?n:1,this.color=!1===a.color?void 0:a.color||"black",this.class=a.class,this.handlers=["dragover","dragend","drop","dragleave"].map((a=>{let n=e=>{this[a](e)};return e.dom.addEventListener(a,n),{name:a,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:a})=>this.editorView.dom.removeEventListener(e,a)))}update(e,a){null!=this.cursorPos&&a.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,a=this.editorView.state.doc.resolve(this.cursorPos),n=!a.parent.inlineContent,t=this.editorView.dom,i=t.getBoundingClientRect(),r=i.width/t.offsetWidth,o=i.height/t.offsetHeight;if(n){let n=a.nodeBefore,t=a.nodeAfter;if(n||t){let a=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(a){let i=a.getBoundingClientRect(),r=n?i.bottom:i.top;n&&t&&(r=(r+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;e={left:i.left,right:i.right,top:r-s,bottom:r+s}}}}if(!e){let a=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*r;e={left:a.left-n,right:a.left+n,top:a.top,bottom:a.bottom}}let s,l,u=this.editorView.dom.offsetParent;if(this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!u||u==document.body&&"static"==getComputedStyle(u).position)s=-pageXOffset,l=-pageYOffset;else{let e=u.getBoundingClientRect();s=e.left-u.scrollLeft*(e.width/u.offsetWidth),l=e.top-u.scrollTop*(e.height/u.offsetHeight)}this.element.style.left=(e.left-s)/r+"px",this.element.style.top=(e.top-l)/o+"px",this.element.style.width=(e.right-e.left)/r+"px",this.element.style.height=(e.bottom-e.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let a=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=a&&a.inside>=0&&this.editorView.state.doc.nodeAt(a.inside),t=n&&n.type.spec.disableDropCursor,i="function"==typeof t?t(this.editorView,a,e):t;if(a&&!i){let e=a.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=uue(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=a&&(e=a)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const pfe=kpe.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[mfe(this.options)]}});class gfe extends Cue{constructor(e){super(e,e)}map(e,a){let n=e.resolve(a.map(this.head));return gfe.valid(n)?new gfe(n):Cue.near(n)}content(){return Rse.empty}eq(e){return e instanceof gfe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,a){if("number"!=typeof a.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new gfe(e.resolve(a.pos))}getBookmark(){return new ffe(this.anchor)}static valid(e){let a=e.parent;if(a.isTextblock||!function(e){for(let a=e.depth;a>=0;a--){let n=e.index(a),t=e.node(a);if(0!=n)for(let e=t.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(t.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let a=e.depth;a>=0;a--){let n=e.indexAfter(a),t=e.node(a);if(n!=t.childCount)for(let e=t.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(t.type.spec.isolating)return!0}return!0}(e))return!1;let n=a.type.spec.allowGapCursor;if(null!=n)return n;let t=a.contentMatchAt(e.index()).defaultType;return t&&t.isTextblock}static findGapCursorFrom(e,a,n=!1){e:for(;;){if(!n&&gfe.valid(e))return e;let t=e.pos,i=null;for(let n=e.depth;;n--){let r=e.node(n);if(a>0?e.indexAfter(n)<r.childCount:e.index(n)>0){i=r.child(a>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;t+=a;let o=e.doc.resolve(t);if(gfe.valid(o))return o}for(;;){let r=a>0?i.firstChild:i.lastChild;if(!r){if(i.isAtom&&!i.isText&&!Pue.isSelectable(i)){e=e.doc.resolve(t+i.nodeSize*a),n=!1;continue e}break}i=r,t+=a;let o=e.doc.resolve(t);if(gfe.valid(o))return o}return null}}}gfe.prototype.visible=!1,gfe.findFrom=gfe.findGapCursorFrom,Cue.jsonID("gapcursor",gfe);class ffe{constructor(e){this.pos=e}map(e){return new ffe(e.map(this.pos))}resolve(e){let a=e.resolve(this.pos);return gfe.valid(a)?new gfe(a):Cue.near(a)}}const vfe=bhe({ArrowLeft:yfe("horiz",-1),ArrowRight:yfe("horiz",1),ArrowUp:yfe("vert",-1),ArrowDown:yfe("vert",1)});function yfe(e,a){const n="vert"==e?a>0?"down":"up":a>0?"right":"left";return function(e,t,i){let r=e.selection,o=a>0?r.$to:r.$from,s=r.empty;if(r instanceof Eue){if(!i.endOfTextblock(n)||0==o.depth)return!1;s=!1,o=e.doc.resolve(a>0?o.after():o.before())}let l=gfe.findGapCursorFrom(o,a,s);return!!l&&(t&&t(e.tr.setSelection(new gfe(l))),!0)}}function kfe(e,a,n){if(!e||!e.editable)return!1;let t=e.state.doc.resolve(a);if(!gfe.valid(t))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Pue.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new gfe(t))),!0)}function bfe(e,a){if("insertCompositionText"!=a.inputType||!(e.state.selection instanceof gfe))return!1;let{$from:n}=e.state.selection,t=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!t)return!1;let i=Ese.empty;for(let o=t.length-1;o>=0;o--)i=Ese.from(t[o].createAndFill(null,i));let r=e.state.tr.replace(n.pos,n.pos,new Rse(i,0,0));return r.setSelection(Eue.near(r.doc.resolve(n.pos+1))),e.dispatch(r),!1}function Sfe(e){if(!(e.selection instanceof gfe))return null;let a=document.createElement("div");return a.className="ProseMirror-gapcursor",Lme.create(e.doc,[_me.widget(e.selection.head,a,{key:"gapcursor"})])}const Afe=kpe.create({name:"gapCursor",addProseMirrorPlugins:()=>[new Vue({props:{decorations:Sfe,createSelectionBetween:(e,a,n)=>a.pos==n.pos&&gfe.valid(n)?new gfe(n):null,handleClick:kfe,handleKeyDown:vfe,handleDOMEvents:{beforeinput:bfe}}})],extendNodeSchema(e){var a;return{allowGapCursor:null!==(a=ape(qhe(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==a?a:null}}}),wfe=mge.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",Qhe(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:a,state:n,editor:t})=>e.first([()=>e.exitCode(),()=>e.command((()=>{const{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:r}=this.options,{splittableMarks:o}=t.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return a().insertContent({type:this.name}).command((({tr:e,dispatch:a})=>{if(a&&s&&r){const a=s.filter((e=>o.includes(e.type.name)));e.ensureMarks(a)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Mfe=mge.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((e=>({tag:`h${e}`,attrs:{level:e}})))},renderHTML({node:e,HTMLAttributes:a}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Qhe(this.options.HTMLAttributes,a),0]},addCommands(){return{setHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.setNode(this.name,e),toggleHeading:e=>({commands:a})=>!!this.options.levels.includes(e.level)&&a.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce(((e,a)=>({...e,[`Mod-Alt-${a}`]:()=>this.editor.commands.toggleHeading({level:a})})),{})},addInputRules(){return this.options.levels.map((e=>cge({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}})))}});var Cfe=200,Tfe=function(){};Tfe.prototype.append=function(e){return e.length?(e=Tfe.from(e),!this.length&&e||e.length<Cfe&&this.leafAppend(e)||this.length<Cfe&&e.leafPrepend(this)||this.appendInner(e)):this},Tfe.prototype.prepend=function(e){return e.length?Tfe.from(e).append(this):this},Tfe.prototype.appendInner=function(e){return new Nfe(this,e)},Tfe.prototype.slice=function(e,a){return void 0===e&&(e=0),void 0===a&&(a=this.length),e>=a?Tfe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,a))},Tfe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Tfe.prototype.forEach=function(e,a,n){void 0===a&&(a=0),void 0===n&&(n=this.length),a<=n?this.forEachInner(e,a,n,0):this.forEachInvertedInner(e,a,n,0)},Tfe.prototype.map=function(e,a,n){void 0===a&&(a=0),void 0===n&&(n=this.length);var t=[];return this.forEach((function(a,n){return t.push(e(a,n))}),a,n),t},Tfe.from=function(e){return e instanceof Tfe?e:e&&e.length?new xfe(e):Tfe.empty};var xfe=function(e){function a(a){e.call(this),this.values=a}e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a;var n={length:{configurable:!0},depth:{configurable:!0}};return a.prototype.flatten=function(){return this.values},a.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new a(this.values.slice(e,n))},a.prototype.getInner=function(e){return this.values[e]},a.prototype.forEachInner=function(e,a,n,t){for(var i=a;i<n;i++)if(!1===e(this.values[i],t+i))return!1},a.prototype.forEachInvertedInner=function(e,a,n,t){for(var i=a-1;i>=n;i--)if(!1===e(this.values[i],t+i))return!1},a.prototype.leafAppend=function(e){if(this.length+e.length<=Cfe)return new a(this.values.concat(e.flatten()))},a.prototype.leafPrepend=function(e){if(this.length+e.length<=Cfe)return new a(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(a.prototype,n),a}(Tfe);Tfe.empty=new xfe([]);var Nfe=function(e){function a(a,n){e.call(this),this.left=a,this.right=n,this.length=a.length+n.length,this.depth=Math.max(a.depth,n.depth)+1}return e&&(a.__proto__=e),(a.prototype=Object.create(e&&e.prototype)).constructor=a,a.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},a.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},a.prototype.forEachInner=function(e,a,n,t){var i=this.left.length;return!(a<i&&!1===this.left.forEachInner(e,a,Math.min(n,i),t))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(a-i,0),Math.min(this.length,n)-i,t+i))&&void 0)},a.prototype.forEachInvertedInner=function(e,a,n,t){var i=this.left.length;return!(a>i&&!1===this.right.forEachInvertedInner(e,a-i,Math.max(n,i)-i,t+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(a,i),n,t))&&void 0)},a.prototype.sliceInner=function(e,a){if(0==e&&a==this.length)return this;var n=this.left.length;return a<=n?this.left.slice(e,a):e>=n?this.right.slice(e-n,a-n):this.left.slice(e,n).append(this.right.slice(0,a-n))},a.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new a(this.left,n)},a.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new a(n,this.right)},a.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new a(this.left,new a(this.right,e)):new a(this,e)},a}(Tfe);class Efe{constructor(e,a){this.items=e,this.eventCount=a}popEvent(e,a){if(0==this.eventCount)return null;let n,t,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}a&&(n=this.remapping(i,this.items.length),t=n.maps.length);let r,o,s=e.tr,l=[],u=[];return this.items.forEach(((e,a)=>{if(!e.step)return n||(n=this.remapping(i,a+1),t=n.maps.length),t--,void u.push(e);if(n){u.push(new _fe(e.map));let a,i=e.step.map(n.slice(t));i&&s.maybeStep(i).doc&&(a=s.mapping.maps[s.mapping.maps.length-1],l.push(new _fe(a,void 0,void 0,l.length+u.length))),t--,a&&n.appendMap(a,t)}else s.maybeStep(e.step);return e.selection?(r=n?e.selection.map(n.slice(t)):e.selection,o=new Efe(this.items.slice(0,i).append(u.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:s,selection:r}}addTransform(e,a,n,t){let i=[],r=this.eventCount,o=this.items,s=!t&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let n,l=e.steps[u].invert(e.docs[u]),c=new _fe(e.mapping.maps[u],l,a);(n=s&&s.merge(c))&&(c=n,u?i.pop():o=o.slice(0,o.length-1)),i.push(c),a&&(r++,a=void 0),t||(s=c)}let l=r-n.depth;return l>jfe&&(o=function(e,a){let n;return e.forEach(((e,t)=>{if(e.selection&&0==a--)return n=t,!1})),e.slice(n)}(o,l),r-=l),new Efe(o.append(i),r)}remapping(e,a){let n=new Hle;return this.items.forEach(((a,t)=>{n.appendMap(a.map,null!=a.mirrorOffset&&t-a.mirrorOffset>=e?n.maps.length-a.mirrorOffset:void 0)}),e,a),n}addMaps(e){return 0==this.eventCount?this:new Efe(this.items.append(e.map((e=>new _fe(e)))),this.eventCount)}rebased(e,a){if(!this.eventCount)return this;let n=[],t=Math.max(0,this.items.length-a),i=e.mapping,r=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),t);let s=a;this.items.forEach((a=>{let t=i.getMirror(--s);if(null==t)return;r=Math.min(r,t);let l=i.maps[t];if(a.step){let r=e.steps[t].invert(e.docs[t]),u=a.selection&&a.selection.map(i.slice(s+1,t));u&&o++,n.push(new _fe(l,r,u))}else n.push(new _fe(l))}),t);let l=[];for(let d=a;d<r;d++)l.push(new _fe(i.maps[d]));let u=this.items.slice(0,t).append(l).append(n),c=new Efe(u,o);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach((a=>{a.step||e++})),e}compress(e=this.items.length){let a=this.remapping(0,e),n=a.maps.length,t=[],i=0;return this.items.forEach(((r,o)=>{if(o>=e)t.push(r),r.selection&&i++;else if(r.step){let e=r.step.map(a.slice(n)),o=e&&e.getMap();if(n--,o&&a.appendMap(o,n),e){let s=r.selection&&r.selection.map(a.slice(n));s&&i++;let l,u=new _fe(o.invert(),e,s),c=t.length-1;(l=t.length&&t[c].merge(u))?t[c]=l:t.push(u)}}else r.map&&n--}),this.items.length,0),new Efe(Tfe.from(t.reverse()),i)}}Efe.empty=new Efe(Tfe.empty,0);let _fe=class e{constructor(e,a,n,t){this.map=e,this.step=a,this.selection=n,this.mirrorOffset=t}merge(a){if(this.step&&a.step&&!a.selection){let n=a.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}};class Pfe{constructor(e,a,n,t,i){this.done=e,this.undone=a,this.prevRanges=n,this.prevTime=t,this.prevComposition=i}}const jfe=20;function Lfe(e){let a=[];for(let n=e.length-1;n>=0&&0==a.length;n--)e[n].forEach(((e,n,t,i)=>a.push(t,i)));return a}function Bfe(e,a){if(!e)return null;let n=[];for(let t=0;t<e.length;t+=2){let i=a.map(e[t],1),r=a.map(e[t+1],-1);i<=r&&n.push(i,r)}return n}let Rfe=!1,zfe=null;function Dfe(e){let a=e.plugins;if(zfe!=a){Rfe=!1,zfe=a;for(let e=0;e<a.length;e++)if(a[e].spec.historyPreserveItems){Rfe=!0;break}}return Rfe}const Ofe=new Wue("history"),Kfe=new Wue("closeHistory");function Hfe(e={}){return new Vue({key:Ofe,state:{init:()=>new Pfe(Efe.empty,Efe.empty,null,0,-1),apply:(a,n,t)=>function(e,a,n,t){let i,r=n.getMeta(Ofe);if(r)return r.historyState;n.getMeta(Kfe)&&(e=new Pfe(e.done,e.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(Ofe))return o.getMeta(Ofe).redo?new Pfe(e.done.addTransform(n,void 0,t,Dfe(a)),e.undone,Lfe(n.mapping.maps),e.prevTime,e.prevComposition):new Pfe(e.done,e.undone.addTransform(n,void 0,t,Dfe(a)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new Pfe(e.done.rebased(n,i),e.undone.rebased(n,i),Bfe(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Pfe(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Bfe(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let i=n.getMeta("composition"),r=0==e.prevTime||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-t.newGroupDelay||!function(e,a){if(!a)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,t)=>{for(let i=0;i<a.length;i+=2)e<=a[i+1]&&t>=a[i]&&(n=!0)})),n}(n,e.prevRanges)),s=o?Bfe(e.prevRanges,n.mapping):Lfe(n.mapping.maps);return new Pfe(e.done.addTransform(n,r?a.selection.getBookmark():void 0,t,Dfe(a)),Efe.empty,s,n.time,null==i?e.prevComposition:i)}}(n,t,a,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,a){let n=a.inputType,t="historyUndo"==n?Gfe:"historyRedo"==n?Ffe:null;return!!t&&(a.preventDefault(),t(e.state,e.dispatch))}}}})}function Ife(e,a){return(n,t)=>{let i=Ofe.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(t){let r=function(e,a,n){let t=Dfe(a),i=Ofe.get(a).spec.config,r=(n?e.undone:e.done).popEvent(a,t);if(!r)return null;let o=r.selection.resolve(r.transform.doc),s=(n?e.done:e.undone).addTransform(r.transform,a.selection.getBookmark(),i,t),l=new Pfe(n?s:r.remaining,n?r.remaining:s,null,0,-1);return r.transform.setSelection(o).setMeta(Ofe,{redo:n,historyState:l})}(i,n,e);r&&t(a?r.scrollIntoView():r)}return!0}}const Gfe=Ife(!1,!0),Ffe=Ife(!0,!0),Vfe=kpe.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:a})=>Gfe(e,a),redo:()=>({state:e,dispatch:a})=>Ffe(e,a)}),addProseMirrorPlugins(){return[Hfe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Jfe=mge.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",Qhe(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:a})=>{const{selection:n}=a,{$from:t,$to:i}=n,r=e();return 0===t.parentOffset?r.insertContentAt({from:Math.max(t.pos-1,0),to:i.pos},{type:this.name}):n instanceof Pue?r.insertContentAt(i.pos,{type:this.name}):r.insertContent({type:this.name}),r.command((({tr:e,dispatch:a})=>{var n;if(a){const{$to:a}=e.selection,t=a.end();if(a.nodeAfter)e.setSelection(a.nodeAfter.isTextblock?Eue.create(e.doc,a.pos+1):a.nodeAfter.isBlock?Pue.create(e.doc,a.pos):Eue.create(e.doc,a.pos));else{const i=null===(n=a.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();i&&(e.insert(t,i),e.setSelection(Eue.create(e.doc,t+1)))}e.scrollIntoView()}return!0})).run()}}},addInputRules(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new lpe({find:e.find,handler:({state:a,range:n,match:t})=>{const i=ape(e.getAttributes,void 0,t)||{},{tr:r}=a,o=n.from;let s=n.to;const l=e.type.create(i);if(t[1]){let e=o+t[0].lastIndexOf(t[1]);e>s?e=s:s=e+t[1].length,r.insertText(t[0][t[0].length-1],o+t[0].length-1),r.replaceWith(e,s,l)}else t[0]&&r.insert(e.type.isInline?o:o-1,e.type.create(i)).delete(r.mapping.map(o),r.mapping.map(s));r.scrollIntoView()}}))];var e}}),Ufe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Wfe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,qfe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Zfe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$fe=hpe.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[uge({find:Ufe,type:this.type}),uge({find:qfe,type:this.type})]},addPasteRules(){return[pge({find:Wfe,type:this.type}),pge({find:Zfe,type:this.type})]}}),Yfe=mge.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",Qhe(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Qfe="textStyle",Xfe=/^(\d+)\.\s$/,eve=mge.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){const{start:a,...n}=e;return 1===a?["ol",Qhe(this.options.HTMLAttributes,n),0]:["ol",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:a})=>this.options.keepAttributes?a().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Qfe)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=dge({find:Xfe,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=dge({find:Xfe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Qfe)}),joinPredicate:(e,a)=>a.childCount+a.attrs.start===+e[1],editor:this.editor})),[e]}}),ave=mge.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),nve=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,tve=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ive=hpe.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",Qhe(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[uge({find:nve,type:this.type})]},addPasteRules(){return[pge({find:tve,type:this.type})]}}),rve=mge.create({name:"text",group:"inline"}),ove=kpe.create({name:"starterKit",addExtensions(){const e=[];return!1!==this.options.bold&&e.push(afe.configure(this.options.bold)),!1!==this.options.blockquote&&e.push($ge.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(ife.configure(this.options.bulletList)),!1!==this.options.code&&e.push(sfe.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(cfe.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(dfe.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(pfe.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(Afe.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(wfe.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(Mfe.configure(this.options.heading)),!1!==this.options.history&&e.push(Vfe.configure(this.options.history)),!1!==this.options.horizontalRule&&e.push(Jfe.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push($fe.configure(this.options.italic)),!1!==this.options.listItem&&e.push(Yfe.configure(this.options.listItem)),!1!==this.options.orderedList&&e.push(eve.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(ave.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(ive.configure(this.options.strike)),!1!==this.options.text&&e.push(rve.configure(this.options.text)),e}}),sve=e=>n.jsx(Fge,{as:"span",className:"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200",children:e.node.attrs.displayName}),lve=mge.create({name:"mergeField",group:"inline",inline:!0,atom:!0,addAttributes:()=>({templateName:{default:null,parseHTML:e=>e.getAttribute("data-template-name")},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name")}}),parseHTML:()=>[{tag:"span[data-merge-field]"}],renderHTML:({HTMLAttributes:e})=>["span",Qhe(e,{"data-merge-field":"true"})],renderText:({node:e})=>e.attrs.templateName,addNodeView:()=>qge(sve)}),uve=({value:e,onChange:t,className:i="",mergeFieldsResponse:r,placeholder:o="Enter text",ariaLabel:s="Insert merge field",icon:l="MergeField"})=>{const[u,c]=a.useState(!1),d=a.useRef(null),m=a.useRef(null),h=a.useMemo((()=>r?.mergeFields?.flatMap((e=>e.entries))??[]),[r]),p=a.useCallback((e=>{if(!e)return"";return e.replace(/\{\{.*?\}\}/g,(e=>{const a=h.find((a=>a.value===e));return a?`<span class="inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200" data-merge-field="true" data-template-name="${a.value}" data-display-name="${a.label}">${a.label}</span>`:e}))}),[h]),g=Ige({extensions:[ove,lve],content:"",editorProps:{attributes:{class:`min-h-[40px] px-3 py-2 border border-input bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50 rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent resize-none prose prose-sm max-w-none ${i}`,placeholder:o}},onUpdate:({editor:e})=>{const a=e.getText();t(a)}});a.useEffect((()=>{if(g&&e){if(g.getText()!==e){const a=p(e);g.commands.setContent(a,!1)}}}),[g,e,p]);const f=a.useCallback((e=>{if(g){const a=h.find((a=>a.value===e));a&&g.chain().focus().insertContent({type:"mergeField",attrs:{templateName:a.value,displayName:a.label}}).run()}c(!1)}),[g,h]);if(a.useEffect((()=>{if(u)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){const a=e.target;m.current&&!m.current.contains(a)&&d.current&&!d.current.contains(a)&&c(!1)}}),[u]),!g)return n.jsx("div",{children:"Loading editor..."});const v=b3[l]||b3.MergeField;return n.jsx("div",{className:"relative",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:"flex-1",children:n.jsx(Tge,{editor:g})}),r&&n.jsxs(n.Fragment,{children:[n.jsx(f3,{ref:d,type:"button",variant:"ghost",size:"icon",className:"ml-2 h-10 w-7 p-0 rounded-md border border-input shadow-sm hover:bg-accent/60 focus:bg-accent/80 transition-colors","aria-label":s,onClick:()=>c((e=>!e)),children:n.jsx(v,{className:"w-4 h-4"})}),u&&n.jsx("div",{ref:m,className:"absolute z-50 mt-2 right-0 w-56 bg-white border border-gray-200 rounded-lg shadow-lg p-1",style:{top:"100%"},children:0===h.length?n.jsx("div",{className:"px-4 py-2 text-muted-foreground text-sm",children:"No merge fields found"}):n.jsx("ul",{className:"py-1",children:h.map((e=>n.jsx("li",{children:n.jsx("button",{className:"w-full text-left px-4 py-2 hover:bg-accent/40 rounded text-sm transition-colors",onClick:()=>f(e.value),type:"button",children:e.label})},e.value)))})})]})]})})},cve=()=>{const[e,t]=a.useState("desktop"),i=a.useRef(null),r=a.useRef(null);return a.useEffect((()=>{const e=()=>t("desktop"),a=()=>t("mobile"),n=i.current,o=r.current;return n&&n.addEventListener("click",e),o&&o.addEventListener("click",a),()=>{n&&n.removeEventListener("click",e),o&&o.removeEventListener("click",a)}}),[]),n.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5 shadow-inner border w-fit",children:[n.jsxs(f3,{ref:i,type:"button","aria-pressed":"desktop"===e,"aria-label":"Show desktop preview",className:"desktop-view-button toggle-desktop-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("desktop"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["desktop"===e&&n.jsx(R2.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),n.jsx("span",{className:"relative z-10 flex items-center justify-center",children:n.jsx(b3.DesktopIcon,{className:"w-4 h-4"})})]}),n.jsxs(f3,{ref:r,type:"button","aria-pressed":"mobile"===e,"aria-label":"Show mobile preview",className:"mobile-view-button toggle-mobile-button relative flex items-center justify-center px-2 py-0 rounded-md transition-colors duration-200"+("mobile"===e?" bg-background shadow text-primary":" bg-transparent text-muted-foreground hover:bg-accent"),variant:"ghost",style:{minWidth:32,minHeight:32},children:["mobile"===e&&n.jsx(R2.span,{layoutId:"toggle-indicator",className:"absolute inset-0 rounded-md border-2 bg-background/80 z-0 border-[color:var(--reach-primary)]",transition:{type:"spring",stiffness:400,damping:30}}),n.jsx("span",{className:"relative z-10 flex items-center justify-center",children:n.jsx(b3.MobileIcon,{className:"w-4 h-4"})})]})]})};function dve(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function mve(e){const a=hve(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(gve);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function hve(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?function(...e){return a=>{let n=!1;const t=e.map((e=>{const t=dve(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():dve(e[a],null)}}}}(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var pve=Symbol("radix.slottable");function gve(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===pve}var fve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=mve(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),vve=r.forwardRef(((e,a)=>n.jsx(fve.label,{...e,ref:a,onMouseDown:a=>{a.target.closest("button, input, select, textarea")||(e.onMouseDown?.(a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}})));vve.displayName="Label";var yve=vve;const kve=XL("text-foreground text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),bve=r.forwardRef((({className:e,...a},t)=>n.jsx(yve,{ref:t,className:mz(kve(),e),...a})));function Sve(e,[a,n]){return Math.min(n,Math.max(a,e))}function Ave(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}function wve(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},Mve(i,...a)]}function Mve(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function Cve(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function Tve(...e){return a=>{let n=!1;const t=e.map((e=>{const t=Cve(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():Cve(e[a],null)}}}}function xve(...e){return r.useCallback(Tve(...e),e)}function Nve(e){const a=Eve(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Pve);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function Eve(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?Tve(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}bve.displayName=yve.displayName;var _ve=Symbol("radix.slottable");function Pve(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===_ve}var jve=r.createContext(void 0);var Lve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=Nve(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});function Bve(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}var Rve,zve="dismissableLayer.update",Dve="dismissableLayer.pointerDownOutside",Ove="dismissableLayer.focusOutside",Kve=r.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Hve=r.forwardRef(((e,a)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...c}=e,d=r.useContext(Kve),[m,h]=r.useState(null),p=m?.ownerDocument??globalThis?.document,[,g]=r.useState({}),f=xve(a,(e=>h(e))),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),k=v.indexOf(y),b=m?v.indexOf(m):-1,S=d.layersWithOutsidePointerEventsDisabled.size>0,A=b>=k,w=function(e,a=globalThis?.document){const n=Bve(e),t=r.useRef(!1),i=r.useRef((()=>{}));return r.useEffect((()=>{const e=e=>{if(e.target&&!t.current){let t=function(){Gve(Dve,n,r,{discrete:!0})};const r={originalEvent:e};"touch"===e.pointerType?(a.removeEventListener("click",i.current),i.current=t,a.addEventListener("click",i.current,{once:!0})):t()}else a.removeEventListener("click",i.current);t.current=!1},r=window.setTimeout((()=>{a.addEventListener("pointerdown",e)}),0);return()=>{window.clearTimeout(r),a.removeEventListener("pointerdown",e),a.removeEventListener("click",i.current)}}),[a,n]),{onPointerDownCapture:()=>t.current=!0}}((e=>{const a=e.target,n=[...d.branches].some((e=>e.contains(a)));A&&!n&&(o?.(e),l?.(e),e.defaultPrevented||u?.())}),p),M=function(e,a=globalThis?.document){const n=Bve(e),t=r.useRef(!1);return r.useEffect((()=>{const e=e=>{if(e.target&&!t.current){Gve(Ove,n,{originalEvent:e},{discrete:!1})}};return a.addEventListener("focusin",e),()=>a.removeEventListener("focusin",e)}),[a,n]),{onFocusCapture:()=>t.current=!0,onBlurCapture:()=>t.current=!1}}((e=>{const a=e.target;[...d.branches].some((e=>e.contains(a)))||(s?.(e),l?.(e),e.defaultPrevented||u?.())}),p);return function(e,a=globalThis?.document){const n=Bve(e);r.useEffect((()=>{const e=e=>{"Escape"===e.key&&n(e)};return a.addEventListener("keydown",e,{capture:!0}),()=>a.removeEventListener("keydown",e,{capture:!0})}),[n,a])}((e=>{b===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))}),p),r.useEffect((()=>{if(m)return t&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(Rve=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),Ive(),()=>{t&&1===d.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Rve)}}),[m,p,t,d]),r.useEffect((()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),Ive())}),[m,d]),r.useEffect((()=>{const e=()=>g({});return document.addEventListener(zve,e),()=>document.removeEventListener(zve,e)}),[]),n.jsx(Lve.div,{...c,ref:f,style:{pointerEvents:S?A?"auto":"none":void 0,...e.style},onFocusCapture:Ave(e.onFocusCapture,M.onFocusCapture),onBlurCapture:Ave(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:Ave(e.onPointerDownCapture,w.onPointerDownCapture)})}));Hve.displayName="DismissableLayer";function Ive(){const e=new CustomEvent(zve);document.dispatchEvent(e)}function Gve(e,a,n,{discrete:t}){const i=n.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});a&&i.addEventListener(e,a,{once:!0}),t?function(e,a){e&&o.flushSync((()=>e.dispatchEvent(a)))}(i,r):i.dispatchEvent(r)}r.forwardRef(((e,a)=>{const t=r.useContext(Kve),i=r.useRef(null),o=xve(a,i);return r.useEffect((()=>{const e=i.current;if(e)return t.branches.add(e),()=>{t.branches.delete(e)}}),[t.branches]),n.jsx(Lve.div,{...e,ref:o})})).displayName="DismissableLayerBranch";var Fve=0;function Vve(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Jve="focusScope.autoFocusOnMount",Uve="focusScope.autoFocusOnUnmount",Wve={bubbles:!1,cancelable:!0},qve=r.forwardRef(((e,a)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...l}=e,[u,c]=r.useState(null),d=Bve(o),m=Bve(s),h=r.useRef(null),p=xve(a,(e=>c(e))),g=r.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;r.useEffect((()=>{if(i){let e=function(e){if(g.paused||!u)return;const a=e.target;u.contains(a)?h.current=a:Qve(h.current,{select:!0})},a=function(e){if(g.paused||!u)return;const a=e.relatedTarget;null!==a&&(u.contains(a)||Qve(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const a of e)a.removedNodes.length>0&&Qve(u)};document.addEventListener("focusin",e),document.addEventListener("focusout",a);const t=new MutationObserver(n);return u&&t.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",a),t.disconnect()}}}),[i,u,g.paused]),r.useEffect((()=>{if(u){Xve.add(g);const a=document.activeElement;if(!u.contains(a)){const n=new CustomEvent(Jve,Wve);u.addEventListener(Jve,d),u.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:a=!1}={}){const n=document.activeElement;for(const t of e)if(Qve(t,{select:a}),document.activeElement!==n)return}((e=Zve(u),e.filter((e=>"A"!==e.tagName))),{select:!0}),document.activeElement===a&&Qve(u))}return()=>{u.removeEventListener(Jve,d),setTimeout((()=>{const e=new CustomEvent(Uve,Wve);u.addEventListener(Uve,m),u.dispatchEvent(e),e.defaultPrevented||Qve(a??document.body,{select:!0}),u.removeEventListener(Uve,m),Xve.remove(g)}),0)}}var e}),[u,d,m,g]);const f=r.useCallback((e=>{if(!t&&!i)return;if(g.paused)return;const a=document.activeElement;if("Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&a){const n=e.currentTarget,[i,r]=function(e){const a=Zve(e),n=$ve(a,e),t=$ve(a.reverse(),e);return[n,t]}(n);i&&r?e.shiftKey||a!==r?e.shiftKey&&a===i&&(e.preventDefault(),t&&Qve(r,{select:!0})):(e.preventDefault(),t&&Qve(i,{select:!0})):a===n&&e.preventDefault()}}),[t,i,g.paused]);return n.jsx(Lve.div,{tabIndex:-1,...l,ref:p,onKeyDown:f})}));function Zve(e){const a=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.disabled||e.hidden||"INPUT"===e.tagName&&"hidden"===e.type?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)a.push(n.currentNode);return a}function $ve(e,a){for(const n of e)if(!Yve(n,{upTo:a}))return n}function Yve(e,{upTo:a}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==a&&e===a)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Qve(e,{select:a=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&a&&e.select()}}qve.displayName="FocusScope";var Xve=function(){let e=[];return{add(a){const n=e[0];a!==n&&n?.pause(),e=eye(e,a),e.unshift(a)},remove(a){e=eye(e,a),e[0]?.resume()}}}();function eye(e,a){const n=[...e],t=n.indexOf(a);return-1!==t&&n.splice(t,1),n}var aye=globalThis?.document?r.useLayoutEffect:()=>{},nye=r[" useId ".trim().toString()]||(()=>{}),tye=0;function iye(e){const[a,n]=r.useState(nye());return aye((()=>{n((e=>e??String(tye++)))}),[e]),e||(a?`radix-${a}`:"")}var rye=r.forwardRef(((e,a)=>{const{children:t,width:i=10,height:r=5,...o}=e;return n.jsx(Lve.svg,{...o,ref:a,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?t:n.jsx("polygon",{points:"0,0 30,0 15,10"})})}));rye.displayName="Arrow";var oye=rye;var sye="Popper",[lye,uye]=wve(sye),[cye,dye]=lye(sye),mye=e=>{const{__scopePopper:a,children:t}=e,[i,o]=r.useState(null);return n.jsx(cye,{scope:a,anchor:i,onAnchorChange:o,children:t})};mye.displayName=sye;var hye="PopperAnchor",pye=r.forwardRef(((e,a)=>{const{__scopePopper:t,virtualRef:i,...o}=e,s=dye(hye,t),l=r.useRef(null),u=xve(a,l);return r.useEffect((()=>{s.onAnchorChange(i?.current||l.current)})),i?null:n.jsx(Lve.div,{...o,ref:u})}));pye.displayName=hye;var gye="PopperContent",[fye,vye]=lye(gye),yye=r.forwardRef(((e,a)=>{const{__scopePopper:t,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:f,...v}=e,y=dye(gye,t),[k,b]=r.useState(null),S=xve(a,(e=>b(e))),[A,w]=r.useState(null),M=function(e){const[a,n]=r.useState(void 0);return aye((()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver((a=>{if(!Array.isArray(a))return;if(!a.length)return;const t=a[0];let i,r;if("borderBoxSize"in t){const e=t.borderBoxSize,a=Array.isArray(e)?e[0]:e;i=a.inlineSize,r=a.blockSize}else i=e.offsetWidth,r=e.offsetHeight;n({width:i,height:r})}));return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}n(void 0)}),[e]),a}(A),C=M?.width??0,T=M?.height??0,x=i+("center"!==s?"-"+s:""),N="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},E=Array.isArray(d)?d:[d],_=E.length>0,P={padding:N,boundary:E.filter(Aye),altBoundary:_},{refs:j,floatingStyles:L,placement:B,isPositioned:R,middlewareData:z}=J6({strategy:"fixed",placement:x,whileElementsMounted:(...e)=>P6(...e,{animationFrame:"always"===g}),elements:{reference:y.anchor},middleware:[W6({mainAxis:o+T,alignmentAxis:l}),c&&q6({mainAxis:!0,crossAxis:!1,limiter:"partial"===h?Z6():void 0,...P}),c&&$6({...P}),Y6({...P,apply:({elements:e,rects:a,availableWidth:n,availableHeight:t})=>{const{width:i,height:r}=a.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${n}px`),o.setProperty("--radix-popper-available-height",`${t}px`),o.setProperty("--radix-popper-anchor-width",`${i}px`),o.setProperty("--radix-popper-anchor-height",`${r}px`)}}),A&&X6({element:A,padding:u}),wye({arrowWidth:C,arrowHeight:T}),p&&Q6({strategy:"referenceHidden",...P})]}),[D,O]=Mye(B),K=Bve(f);aye((()=>{R&&K?.()}),[R,K]);const H=z.arrow?.x,I=z.arrow?.y,G=0!==z.arrow?.centerOffset,[F,V]=r.useState();return aye((()=>{k&&V(window.getComputedStyle(k).zIndex)}),[k]),n.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:R?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:F,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(" "),...z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(fye,{scope:t,placedSide:D,onArrowChange:w,arrowX:H,arrowY:I,shouldHideArrow:G,children:n.jsx(Lve.div,{"data-side":D,"data-align":O,...v,ref:S,style:{...v.style,animation:R?void 0:"none"}})})})}));yye.displayName=gye;var kye="PopperArrow",bye={top:"bottom",right:"left",bottom:"top",left:"right"},Sye=r.forwardRef((function(e,a){const{__scopePopper:t,...i}=e,r=vye(kye,t),o=bye[r.placedSide];return n.jsx("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:n.jsx(oye,{...i,ref:a,style:{...i.style,display:"block"}})})}));function Aye(e){return null!==e}Sye.displayName=kye;var wye=e=>({name:"transformOrigin",options:e,fn(a){const{placement:n,rects:t,middlewareData:i}=a,r=0!==i.arrow?.centerOffset,o=r?0:e.arrowWidth,s=r?0:e.arrowHeight,[l,u]=Mye(n),c={start:"0%",center:"50%",end:"100%"}[u],d=(i.arrow?.x??0)+o/2,m=(i.arrow?.y??0)+s/2;let h="",p="";return"bottom"===l?(h=r?c:`${d}px`,p=-s+"px"):"top"===l?(h=r?c:`${d}px`,p=`${t.floating.height+s}px`):"right"===l?(h=-s+"px",p=r?c:`${m}px`):"left"===l&&(h=`${t.floating.width+s}px`,p=r?c:`${m}px`),{data:{x:h,y:p}}}});function Mye(e){const[a,n="center"]=e.split("-");return[a,n]}var Cye=mye,Tye=pye,xye=yye,Nye=Sye,Eye=r.forwardRef(((e,a)=>{const{container:i,...o}=e,[s,l]=r.useState(!1);aye((()=>l(!0)),[]);const u=i||s&&globalThis?.document?.body;return u?t.createPortal(n.jsx(Lve.div,{...o,ref:a}),u):null}));Eye.displayName="Portal";var _ye=r[" useInsertionEffect ".trim().toString()]||aye;function Pye({prop:e,defaultProp:a,onChange:n=()=>{},caller:t}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[n,t]=r.useState(e),i=r.useRef(n),o=r.useRef(a);return _ye((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==n&&(o.current?.(n),i.current=n)}),[n,i]),[n,t,o]}({defaultProp:a,onChange:n}),l=void 0!==e,u=l?e:i;{const a=r.useRef(void 0!==e);r.useEffect((()=>{const e=a.current;if(e!==l){}a.current=l}),[l,t])}const c=r.useCallback((a=>{if(l){const n=function(e){return"function"==typeof e}(a)?a(e):a;n!==e&&s.current?.(n)}else o(a)}),[l,e,o,s]);return[u,c]}var jye=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});r.forwardRef(((e,a)=>n.jsx(Lve.span,{...e,ref:a,style:{...jye,...e.style}}))).displayName="VisuallyHidden";var Lye=[" ","Enter","ArrowUp","ArrowDown"],Bye=[" ","Enter"],Rye="Select",[zye,Dye,Oye]=function(e){const t=e+"CollectionProvider",[i,r]=wve(t),[o,s]=i(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return n.jsx(o,{scope:t,itemMap:s,collectionRef:r,children:i})};l.displayName=t;const u=e+"CollectionSlot",c=Nve(u),d=a.forwardRef(((e,a)=>{const{scope:t,children:i}=e,r=xve(a,s(u,t).collectionRef);return n.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=Nve(m),g=a.forwardRef(((e,t)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=xve(t,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),n.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(n){const t=s(e+"CollectionConsumer",n);return a.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(t.itemMap.values()).sort(((e,n)=>a.indexOf(e.ref.current)-a.indexOf(n.ref.current)))}),[t.collectionRef,t.itemMap])},r]}(Rye),[Kye,Hye]=wve(Rye,[Oye,uye]),Iye=uye(),[Gye,Fye]=Kye(Rye),[Vye,Jye]=Kye(Rye),Uye=e=>{const{__scopeSelect:a,children:t,open:i,defaultOpen:o,onOpenChange:s,value:l,defaultValue:u,onValueChange:c,dir:d,name:m,autoComplete:h,disabled:p,required:g,form:f}=e,v=Iye(a),[y,k]=r.useState(null),[b,S]=r.useState(null),[A,w]=r.useState(!1),M=function(e){const a=r.useContext(jve);return e||a||"ltr"}(d),[C,T]=Pye({prop:i,defaultProp:o??!1,onChange:s,caller:Rye}),[x,N]=Pye({prop:l,defaultProp:u,onChange:c,caller:Rye}),E=r.useRef(null),_=!y||(f||!!y.closest("form")),[P,j]=r.useState(new Set),L=Array.from(P).map((e=>e.props.value)).join(";");return n.jsx(Cye,{...v,children:n.jsxs(Gye,{required:g,scope:a,trigger:y,onTriggerChange:k,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:A,onValueNodeHasChildrenChange:w,contentId:iye(),value:x,onValueChange:N,open:C,onOpenChange:T,dir:M,triggerPointerDownPosRef:E,disabled:p,children:[n.jsx(zye.Provider,{scope:a,children:n.jsx(Vye,{scope:e.__scopeSelect,onNativeOptionAdd:r.useCallback((e=>{j((a=>new Set(a).add(e)))}),[]),onNativeOptionRemove:r.useCallback((e=>{j((a=>{const n=new Set(a);return n.delete(e),n}))}),[]),children:t})}),_?n.jsxs(Lke,{"aria-hidden":!0,required:g,tabIndex:-1,name:m,autoComplete:h,value:x,onChange:e=>N(e.target.value),disabled:p,form:f,children:[void 0===x?n.jsx("option",{value:""}):null,Array.from(P)]},L):null]})})};Uye.displayName=Rye;var Wye="SelectTrigger",qye=r.forwardRef(((e,a)=>{const{__scopeSelect:t,disabled:i=!1,...o}=e,s=Iye(t),l=Fye(Wye,t),u=l.disabled||i,c=xve(a,l.onTriggerChange),d=Dye(t),m=r.useRef("touch"),[h,p,g]=Rke((e=>{const a=d().filter((e=>!e.disabled)),n=a.find((e=>e.value===l.value)),t=zke(a,e,n);void 0!==t&&l.onValueChange(t.value)})),f=e=>{u||(l.onOpenChange(!0),g()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return n.jsx(Tye,{asChild:!0,...s,children:n.jsx(Lve.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":Bke(l.value)?"":void 0,...o,ref:c,onClick:Ave(o.onClick,(e=>{e.currentTarget.focus(),"mouse"!==m.current&&f(e)})),onPointerDown:Ave(o.onPointerDown,(e=>{m.current=e.pointerType;const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(f(e),e.preventDefault())})),onKeyDown:Ave(o.onKeyDown,(e=>{const a=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),a&&" "===e.key||Lye.includes(e.key)&&(f(),e.preventDefault())}))})})}));qye.displayName=Wye;var Zye="SelectValue",$ye=r.forwardRef(((e,a)=>{const{__scopeSelect:t,className:i,style:r,children:o,placeholder:s="",...l}=e,u=Fye(Zye,t),{onValueNodeHasChildrenChange:c}=u,d=void 0!==o,m=xve(a,u.onValueNodeChange);return aye((()=>{c(d)}),[c,d]),n.jsx(Lve.span,{...l,ref:m,style:{pointerEvents:"none"},children:Bke(u.value)?n.jsx(n.Fragment,{children:s}):o})}));$ye.displayName=Zye;var Yye=r.forwardRef(((e,a)=>{const{__scopeSelect:t,children:i,...r}=e;return n.jsx(Lve.span,{"aria-hidden":!0,...r,ref:a,children:i||"▼"})}));Yye.displayName="SelectIcon";var Qye=e=>n.jsx(Eye,{asChild:!0,...e});Qye.displayName="SelectPortal";var Xye="SelectContent",eke=r.forwardRef(((e,a)=>{const t=Fye(Xye,e.__scopeSelect),[i,s]=r.useState();if(aye((()=>{s(new DocumentFragment)}),[]),!t.open){const a=i;return a?o.createPortal(n.jsx(nke,{scope:e.__scopeSelect,children:n.jsx(zye.Slot,{scope:e.__scopeSelect,children:n.jsx("div",{children:e.children})})}),a):null}return n.jsx(rke,{...e,ref:a})}));eke.displayName=Xye;var ake=10,[nke,tke]=Kye(Xye),ike=Nve("SelectContent.RemoveScroll"),rke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:l,side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y,...k}=e,b=Fye(Xye,t),[S,A]=r.useState(null),[w,M]=r.useState(null),C=xve(a,(e=>A(e))),[T,x]=r.useState(null),[N,E]=r.useState(null),_=Dye(t),[P,j]=r.useState(!1),L=r.useRef(!1);r.useEffect((()=>{if(S)return xW(S)}),[S]),r.useEffect((()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Vve()),document.body.insertAdjacentElement("beforeend",e[1]??Vve()),Fve++,()=>{1===Fve&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),Fve--}}),[]);const B=r.useCallback((e=>{const[a,...n]=_().map((e=>e.ref.current)),[t]=n.slice(-1),i=document.activeElement;for(const r of e){if(r===i)return;if(r?.scrollIntoView({block:"nearest"}),r===a&&w&&(w.scrollTop=0),r===t&&w&&(w.scrollTop=w.scrollHeight),r?.focus(),document.activeElement!==i)return}}),[_,w]),R=r.useCallback((()=>B([T,S])),[B,T,S]);r.useEffect((()=>{P&&R()}),[P,R]);const{onOpenChange:z,triggerPointerDownPosRef:D}=b;r.useEffect((()=>{if(S){let e={x:0,y:0};const a=a=>{e={x:Math.abs(Math.round(a.pageX)-(D.current?.x??0)),y:Math.abs(Math.round(a.pageY)-(D.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():S.contains(n.target)||z(!1),document.removeEventListener("pointermove",a),D.current=null};return null!==D.current&&(document.addEventListener("pointermove",a),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",n,{capture:!0})}}}),[S,z,D]),r.useEffect((()=>{const e=()=>z(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}}),[z]);const[O,K]=Rke((e=>{const a=_().filter((e=>!e.disabled)),n=a.find((e=>e.ref.current===document.activeElement)),t=zke(a,e,n);t&&setTimeout((()=>t.ref.current.focus()))})),H=r.useCallback(((e,a,n)=>{const t=!L.current&&!n;(void 0!==b.value&&b.value===a||t)&&(x(e),t&&(L.current=!0))}),[b.value]),I=r.useCallback((()=>S?.focus()),[S]),G=r.useCallback(((e,a,n)=>{(void 0!==b.value&&b.value===a||!L.current&&!n)&&E(e)}),[b.value]),F="popper"===i?ske:oke,V=F===ske?{side:u,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:f,hideWhenDetached:v,avoidCollisions:y}:{};return n.jsx(nke,{scope:t,content:S,viewport:w,onViewportChange:M,itemRefCallback:H,selectedItem:T,onItemLeave:I,itemTextRefCallback:G,focusSelectedItem:R,selectedItemText:N,position:i,isPositioned:P,searchRef:O,children:n.jsx(bW,{as:ike,allowPinchZoom:!0,children:n.jsx(qve,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Ave(o,(e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()})),children:n.jsx(Hve,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:n.jsx(F,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:e=>e.preventDefault(),...k,...V,onPlaced:()=>j(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Ave(k.onKeyDown,(e=>{const a=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),a||1!==e.key.length||K(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let a=_().filter((e=>!e.disabled)).map((e=>e.ref.current));if(["ArrowUp","End"].includes(e.key)&&(a=a.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=a.indexOf(e.target);a=a.slice(n+1)}setTimeout((()=>B(a))),e.preventDefault()}}))})})})})})}));rke.displayName="SelectContentImpl";var oke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,onPlaced:i,...o}=e,s=Fye(Xye,t),l=tke(Xye,t),[u,c]=r.useState(null),[d,m]=r.useState(null),h=xve(a,(e=>m(e))),p=Dye(t),g=r.useRef(!1),f=r.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:k,focusSelectedItem:b}=l,S=r.useCallback((()=>{if(s.trigger&&s.valueNode&&u&&d&&v&&y&&k){const e=s.trigger.getBoundingClientRect(),a=d.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),t=k.getBoundingClientRect();if("rtl"!==s.dir){const i=n.left-(t.left-a.left),r=e.width+(e.left-i),o=Math.max(r,a.width),s=window.innerWidth-ake,l=Sve(i,[ake,Math.max(ake,s-o)]);u.style.minWidth=r+"px",u.style.left=l+"px"}else{const i=window.innerWidth-n.right-(a.right-t.right),r=window.innerWidth-e.right-i,o=e.width+r,s=Math.max(o,a.width),l=window.innerWidth-ake,c=Sve(i,[ake,Math.max(ake,l-s)]);u.style.minWidth=o+"px",u.style.right=c+"px"}const r=p(),o=window.innerHeight-2*ake,l=v.scrollHeight,c=window.getComputedStyle(d),m=parseInt(c.borderTopWidth,10),h=parseInt(c.paddingTop,10),f=parseInt(c.borderBottomWidth,10),b=m+h+l+parseInt(c.paddingBottom,10)+f,S=Math.min(5*y.offsetHeight,b),A=window.getComputedStyle(v),w=parseInt(A.paddingTop,10),M=parseInt(A.paddingBottom,10),C=e.top+e.height/2-ake,T=o-C,x=y.offsetHeight/2,N=m+h+(y.offsetTop+x),E=b-N;if(N<=C){const e=r.length>0&&y===r[r.length-1].ref.current;u.style.bottom="0px";const a=Math.max(T,x+(e?M:0)+(d.clientHeight-v.offsetTop-v.offsetHeight)+f);u.style.height=N+a+"px"}else{const e=r.length>0&&y===r[0].ref.current;u.style.top="0px";const a=Math.max(C,m+v.offsetTop+(e?w:0)+x);u.style.height=a+E+"px",v.scrollTop=N-C+v.offsetTop}u.style.margin=`${ake}px 0`,u.style.minHeight=S+"px",u.style.maxHeight=o+"px",i?.(),requestAnimationFrame((()=>g.current=!0))}}),[p,s.trigger,s.valueNode,u,d,v,y,k,s.dir,i]);aye((()=>S()),[S]);const[A,w]=r.useState();aye((()=>{d&&w(window.getComputedStyle(d).zIndex)}),[d]);const M=r.useCallback((e=>{e&&!0===f.current&&(S(),b?.(),f.current=!1)}),[S,b]);return n.jsx(lke,{scope:t,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:M,children:n.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:n.jsx(Lve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})}));oke.displayName="SelectItemAlignedPosition";var ske=r.forwardRef(((e,a)=>{const{__scopeSelect:t,align:i="start",collisionPadding:r=ake,...o}=e,s=Iye(t);return n.jsx(xye,{...s,...o,ref:a,align:i,collisionPadding:r,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})}));ske.displayName="SelectPopperPosition";var[lke,uke]=Kye(Xye,{}),cke="SelectViewport",dke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,nonce:i,...o}=e,s=tke(cke,t),l=uke(cke,t),u=xve(a,s.onViewportChange),c=r.useRef(0);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),n.jsx(zye.Slot,{scope:t,children:n.jsx(Lve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ave(o.onScroll,(e=>{const a=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:t}=l;if(t?.current&&n){const e=Math.abs(c.current-a.scrollTop);if(e>0){const t=window.innerHeight-2*ake,i=parseFloat(n.style.minHeight),r=parseFloat(n.style.height),o=Math.max(i,r);if(o<t){const i=o+e,r=Math.min(t,i),s=i-r;n.style.height=r+"px","0px"===n.style.bottom&&(a.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}c.current=a.scrollTop}))})})]})}));dke.displayName=cke;var mke="SelectGroup",[hke,pke]=Kye(mke),gke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e,r=iye();return n.jsx(hke,{scope:t,id:r,children:n.jsx(Lve.div,{role:"group","aria-labelledby":r,...i,ref:a})})}));gke.displayName=mke;var fke="SelectLabel",vke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e,r=pke(fke,t);return n.jsx(Lve.div,{id:r.id,...i,ref:a})}));vke.displayName=fke;var yke="SelectItem",[kke,bke]=Kye(yke),Ske=r.forwardRef(((e,a)=>{const{__scopeSelect:t,value:i,disabled:o=!1,textValue:s,...l}=e,u=Fye(yke,t),c=tke(yke,t),d=u.value===i,[m,h]=r.useState(s??""),[p,g]=r.useState(!1),f=xve(a,(e=>c.itemRefCallback?.(e,i,o))),v=iye(),y=r.useRef("touch"),k=()=>{o||(u.onValueChange(i),u.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return n.jsx(kke,{scope:t,value:i,disabled:o,textId:v,isSelected:d,onItemTextChange:r.useCallback((e=>{h((a=>a||(e?.textContent??"").trim()))}),[]),children:n.jsx(zye.ItemSlot,{scope:t,value:i,disabled:o,textValue:m,children:n.jsx(Lve.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":d&&p,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:f,onFocus:Ave(l.onFocus,(()=>g(!0))),onBlur:Ave(l.onBlur,(()=>g(!1))),onClick:Ave(l.onClick,(()=>{"mouse"!==y.current&&k()})),onPointerUp:Ave(l.onPointerUp,(()=>{"mouse"===y.current&&k()})),onPointerDown:Ave(l.onPointerDown,(e=>{y.current=e.pointerType})),onPointerMove:Ave(l.onPointerMove,(e=>{y.current=e.pointerType,o?c.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})})),onPointerLeave:Ave(l.onPointerLeave,(e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()})),onKeyDown:Ave(l.onKeyDown,(e=>{""!==c.searchRef?.current&&" "===e.key||(Bye.includes(e.key)&&k()," "===e.key&&e.preventDefault())}))})})})}));Ske.displayName=yke;var Ake="SelectItemText",wke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,className:i,style:s,...l}=e,u=Fye(Ake,t),c=tke(Ake,t),d=bke(Ake,t),m=Jye(Ake,t),[h,p]=r.useState(null),g=xve(a,(e=>p(e)),d.onItemTextChange,(e=>c.itemTextRefCallback?.(e,d.value,d.disabled))),f=h?.textContent,v=r.useMemo((()=>n.jsx("option",{value:d.value,disabled:d.disabled,children:f},d.value)),[d.disabled,d.value,f]),{onNativeOptionAdd:y,onNativeOptionRemove:k}=m;return aye((()=>(y(v),()=>k(v))),[y,k,v]),n.jsxs(n.Fragment,{children:[n.jsx(Lve.span,{id:d.textId,...l,ref:g}),d.isSelected&&u.valueNode&&!u.valueNodeHasChildren?o.createPortal(l.children,u.valueNode):null]})}));wke.displayName=Ake;var Mke="SelectItemIndicator",Cke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e;return bke(Mke,t).isSelected?n.jsx(Lve.span,{"aria-hidden":!0,...i,ref:a}):null}));Cke.displayName=Mke;var Tke="SelectScrollUpButton",xke=r.forwardRef(((e,a)=>{const t=tke(Tke,e.__scopeSelect),i=uke(Tke,e.__scopeSelect),[o,s]=r.useState(!1),l=xve(a,i.onScrollButtonChange);return aye((()=>{if(t.viewport&&t.isPositioned){let e=function(){s(a.scrollTop>0)};const a=t.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[t.viewport,t.isPositioned]),o?n.jsx(_ke,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=t;e&&a&&(e.scrollTop=e.scrollTop-a.offsetHeight)}}):null}));xke.displayName=Tke;var Nke="SelectScrollDownButton",Eke=r.forwardRef(((e,a)=>{const t=tke(Nke,e.__scopeSelect),i=uke(Nke,e.__scopeSelect),[o,s]=r.useState(!1),l=xve(a,i.onScrollButtonChange);return aye((()=>{if(t.viewport&&t.isPositioned){let e=function(){const e=a.scrollHeight-a.clientHeight,n=Math.ceil(a.scrollTop)<e;s(n)};const a=t.viewport;return e(),a.addEventListener("scroll",e),()=>a.removeEventListener("scroll",e)}}),[t.viewport,t.isPositioned]),o?n.jsx(_ke,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:a}=t;e&&a&&(e.scrollTop=e.scrollTop+a.offsetHeight)}}):null}));Eke.displayName=Nke;var _ke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,onAutoScroll:i,...o}=e,s=tke("SelectScrollButton",t),l=r.useRef(null),u=Dye(t),c=r.useCallback((()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)}),[]);return r.useEffect((()=>()=>c()),[c]),aye((()=>{const e=u().find((e=>e.ref.current===document.activeElement));e?.ref.current?.scrollIntoView({block:"nearest"})}),[u]),n.jsx(Lve.div,{"aria-hidden":!0,...o,ref:a,style:{flexShrink:0,...o.style},onPointerDown:Ave(o.onPointerDown,(()=>{null===l.current&&(l.current=window.setInterval(i,50))})),onPointerMove:Ave(o.onPointerMove,(()=>{s.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))})),onPointerLeave:Ave(o.onPointerLeave,(()=>{c()}))})})),Pke=r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e;return n.jsx(Lve.div,{"aria-hidden":!0,...i,ref:a})}));Pke.displayName="SelectSeparator";var jke="SelectArrow";r.forwardRef(((e,a)=>{const{__scopeSelect:t,...i}=e,r=Iye(t),o=Fye(jke,t),s=tke(jke,t);return o.open&&"popper"===s.position?n.jsx(Nye,{...r,...i,ref:a}):null})).displayName=jke;var Lke=r.forwardRef((({__scopeSelect:e,value:a,...t},i)=>{const o=r.useRef(null),s=xve(i,o),l=function(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}(a);return r.useEffect((()=>{const e=o.current;if(!e)return;const n=window.HTMLSelectElement.prototype,t=Object.getOwnPropertyDescriptor(n,"value").set;if(l!==a&&t){const n=new Event("change",{bubbles:!0});t.call(e,a),e.dispatchEvent(n)}}),[l,a]),n.jsx(Lve.select,{...t,style:{...jye,...t.style},ref:s,defaultValue:a})}));function Bke(e){return""===e||void 0===e}function Rke(e){const a=Bve(e),n=r.useRef(""),t=r.useRef(0),i=r.useCallback((e=>{const i=n.current+e;a(i),function e(a){n.current=a,window.clearTimeout(t.current),""!==a&&(t.current=window.setTimeout((()=>e("")),1e3))}(i)}),[a]),o=r.useCallback((()=>{n.current="",window.clearTimeout(t.current)}),[]);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),[n,i,o]}function zke(e,a,n){const t=a.length>1&&Array.from(a).every((e=>e===a[0]))?a[0]:a,i=n?e.indexOf(n):-1;let r=(o=e,s=Math.max(i,0),o.map(((e,a)=>o[(s+a)%o.length])));var o,s;1===t.length&&(r=r.filter((e=>e!==n)));const l=r.find((e=>e.textValue.toLowerCase().startsWith(t.toLowerCase())));return l!==n?l:void 0}Lke.displayName="SelectBubbleInput";var Dke=qye,Oke=Yye,Kke=Qye,Hke=eke,Ike=dke,Gke=vke,Fke=Ske,Vke=wke,Jke=Cke,Uke=xke,Wke=Eke,qke=Pke;const Zke=Uye,$ke=gke,Yke=$ye,Qke=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(Dke,{ref:i,className:mz("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-border/10 px-3 py-2 text-sm shadow-sm ring-offset-background !placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...t,children:[a,n.jsx(Oke,{asChild:!0,children:n.jsx(hB,{className:"h-4 w-4 opacity-50"})})]})));Qke.displayName=Dke.displayName;const Xke=r.forwardRef((({className:e,...a},t)=>n.jsx(Uke,{ref:t,className:mz("flex cursor-default items-center justify-center py-1",e),...a,children:n.jsx(fB,{className:"h-4 w-4"})})));Xke.displayName=Uke.displayName;const ebe=r.forwardRef((({className:e,...a},t)=>n.jsx(Wke,{ref:t,className:mz("flex cursor-default items-center justify-center py-1",e),...a,children:n.jsx(hB,{className:"h-4 w-4"})})));ebe.displayName=Wke.displayName;const abe=r.forwardRef((({className:e,children:a,position:t="popper",...i},r)=>n.jsx(Kke,{children:n.jsxs(Hke,{ref:r,className:mz("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===t&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:t,...i,children:[n.jsx(Xke,{}),n.jsx(Ike,{className:mz("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),n.jsx(ebe,{})]})})));abe.displayName=Hke.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(Gke,{ref:t,className:mz("px-2 py-1.5 text-sm font-semibold text-muted-foreground",e),...a}))).displayName=Gke.displayName;const nbe=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(Fke,{ref:i,className:mz("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t,children:[n.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(Jke,{children:n.jsx(mB,{className:"h-4 w-4"})})}),n.jsx(Vke,{children:a})]})));nbe.displayName=Fke.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(qke,{ref:t,className:mz("-mx-1 my-1 h-px bg-muted",e),...a}))).displayName=qke.displayName;const tbe=(e,n)=>{const[t,i]=a.useState(e);return a.useEffect((()=>{const a=setTimeout((()=>{i(e)}),n);return()=>clearTimeout(a)}),[e,n]),t},ibe=async()=>(await Re(s)).data,rbe=async(e,a)=>(await Re(s,{method:"PATCH",body:JSON.stringify({uiDefaults:{[e]:a}})})).data,obe=["me"],sbe=()=>{const e=ce(),{toast:a}=ea(),n=ye({queryKey:obe,queryFn:ibe,...Me}),t=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({website:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Website updated 🚀"})},onError:()=>{a({title:"Failed to update website",description:"Please try again",variant:"destructive"})}}),i=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({locations:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Locations updated 🚀"})},onError:()=>{a({title:"Failed to update locations",description:"Please try again",variant:"destructive"})}}),r=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({branding:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Brand settings saved 🚀"})},onError:()=>{a({title:"Failed to save brand settings",description:"Please try again",variant:"destructive"})}}),o=ke({mutationFn:e=>(async e=>{const a=e.company.address1?.trim()||e.company.city?.trim()||e.company.stateProvince?.trim()||e.company.zipCode?.trim(),n=e.company.name?.trim();if(!a&&!n)return{success:!0,message:"No updates needed"};const t={locations:[{addressLine1:e.company.address1?.trim()||"",addressLine2:e.company.address2?.trim(),locality:e.company.city?.trim()||"",district:e.company.stateProvince?.trim()||"",postalCode:e.company.zipCode?.trim()||"",countryCode:e.company.country?.trim()||""}],...n&&{name:e.company.name?.trim()}};try{return(await Re(s,{method:"PATCH",body:JSON.stringify(t)})).data}catch(i){throw i}})(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Business settings saved 🚀"})},onError:()=>{a({title:"Failed to save business settings",description:"Please try again",variant:"destructive"})}}),l=ke({mutationFn:e=>(async e=>(await Re(s,{method:"PATCH",body:JSON.stringify({uiDefaults:e})})).data)(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe}),a({title:"Business UI defaults updated 🚀"})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),u=ke({mutationFn:e=>rbe(e.key,e.value),onSuccess:()=>{e.invalidateQueries({queryKey:obe})},onError:()=>{a({title:"Failed to update business UI defaults",description:"Please try again",variant:"destructive"})}}),c=ke({mutationFn:e=>(async e=>rbe("emailHelpDialogShow",e))(e),onSuccess:()=>{e.invalidateQueries({queryKey:obe})},onError:()=>{a({title:"Failed to update dialog state",description:"Please try again",variant:"destructive"})}});return{data:n.data,isLoading:n.isLoading,error:n.error,refetch:n.refetch,updateWebsite:t.mutate,updateLocations:i.mutate,updateBrandSettings:r.mutate,updateBusinessSettings:o.mutate,updateBusinessSettingsAsync:o.mutateAsync,updateBusinessUiDefaults:l.mutate,updateBusinessUiDefaultsAsync:l.mutateAsync,updateBusinessUiDefaultProperty:u.mutate,updateBusinessUiDefaultPropertyAsync:u.mutateAsync,toggleEmailHelpDialog:c.mutate,toggleEmailHelpDialogAsync:c.mutateAsync,isUpdatingWebsite:t.isPending,isUpdatingLocations:i.isPending,isUpdatingBrandSettings:r.isPending,isUpdatingBusinessSettings:o.isPending,isUpdatingBusinessUiDefaults:l.isPending,isUpdatingBusinessUiDefaultProperty:u.isPending,isTogglingEmailHelpDialog:c.isPending}};var lbe=(e=>(e.WORKFLOW="workflow",e.RECIPIENTS="recipients",e.INSIGHTS="insights",e))(lbe||{}),ube=(e=>(e.EMAIL="email",e.SMS="sms",e))(ube||{});const cbe=[0,100,500,1e3,2e3],dbe=320,mbe=({type:e})=>n.jsxs("div",{className:"w-full h-full min-h-[300px] flex flex-col items-center justify-center bg-gradient-to-b from-gray-50 to-white p-8",children:[n.jsx("div",{className:"mb-4 text-gray-300",children:n.jsx("svg",{className:"w-16 h-16",fill:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"})})}),n.jsxs("p",{className:"text-gray-400 font-medium text-lg text-center mb-2",children:["No ","email"===e?"Email":"SMS"," Preview Available"]}),n.jsxs("p",{className:"text-gray-400 text-sm text-center",children:["Edit your ","email"===e?"Email":"SMS"," template to see a preview here"]})]}),hbe=({html:e,onHeightChange:t})=>{const i=a.useRef(),[r,o]=a.useState({type:"loading"}),[s,l]=a.useState(null),u=a.useCallback((e=>{e&&l(e)}),[]),c=d3(),{getMergeFields:d,isGetting:m}=la(c?.id??void 0),h=a.useMemo((()=>d?.mergeFields?.flatMap((e=>e.entries))??[]),[d?.mergeFields]),p=a.useMemo((()=>((e,a)=>{if(!e)return"";const n=e.includes("merge-field-pill-styles")?"":'\n <style id="merge-field-pill-styles">\n .merge-field-pill {\n display: inline-block !important;\n padding: 4px 8px !important;\n border-radius: 6px !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n font-size: 0.875rem !important;\n border: 1px solid #e5e7eb !important;\n font-weight: 500 !important;\n margin: 0 2px !important;\n vertical-align: middle !important;\n line-height: 1.2 !important;\n white-space: nowrap !important;\n box-sizing: border-box !important;\n }\n </style>\n ';let t=e;return n&&e.includes("<head>")?t=e.replace("<head>",`<head>${n}`):n&&(t=`<head>${n}</head>${e}`),t.replace(/\{\{.*?\}\}/g,(e=>{const n=a?.find((a=>a.value===e));return`<span class="merge-field-pill" style="display: inline-block; padding: 4px 8px; border-radius: 6px; background: #f3f4f6; color: #6b7280; font-size: 0.875rem; border: 1px solid #e5e7eb; font-weight: 500; margin: 0 2px; vertical-align: middle; line-height: 1.2; white-space: nowrap; box-sizing: border-box;">${n?n.label:e}</span>`}))})(e,h)),[e,h]),g=a.useCallback((e=>{o((a=>"ready"===a.type||"calculating"===a.type?(t?.(e),{type:"ready",height:e}):a))}),[t]),f=a.useCallback((()=>{o({type:"error",fallbackHeight:400}),g(400)}),[g]),v=a.useCallback((e=>{try{const a=e.split("\n").length;return Math.max(200,Math.min(800,20*a))}catch(a){return 400}}),[]),y=a.useCallback((()=>{const e=v(p);o({type:"error",fallbackHeight:e}),g(e)}),[p,v,g]);if(a.useEffect((()=>{p&&(o({type:"calculating"}),i.current&&clearTimeout(i.current))}),[p]),a.useEffect((()=>{if(!p||!s)return;if("ready"===r.type)return;const e=s,a=Math.max(5e3,5e3);i.current=setTimeout((()=>{f()}),a);const n=setTimeout((()=>{"calculating"===r.type&&y()}),1e4),t=v(p),l=()=>{try{const n=e.contentDocument||e.contentWindow?.document;if(!n)return o({type:"error",fallbackHeight:t}),void g(t);const i=()=>{try{n.querySelectorAll("style[data-merge-field-pills]").forEach((e=>e.remove()));const e=n.createElement("style");e.textContent="html, body { height: auto !important; min-height: 0 !important; }",n.head.appendChild(e);const a=n.createElement("style");a.setAttribute("data-merge-field-pills","true"),a.textContent="\n .merge-field-pill {\n display: inline-block !important;\n padding: 4px 8px !important;\n border-radius: 6px !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n font-size: 0.875rem !important;\n border: 1px solid #e5e7eb !important;\n font-weight: 500 !important;\n margin: 0 2px !important;\n vertical-align: middle !important;\n line-height: 1.2 !important;\n white-space: nowrap !important;\n box-sizing: border-box !important;\n }\n \n /* Ensure pills are visible even with conflicting styles */\n span.merge-field-pill {\n display: inline-block !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n border: 1px solid #e5e7eb !important;\n }\n \n /* Force override any inherited styles */\n * .merge-field-pill {\n display: inline-block !important;\n background: #f3f4f6 !important;\n color: #6b7280 !important;\n border: 1px solid #e5e7eb !important;\n padding: 4px 8px !important;\n border-radius: 6px !important;\n }\n ",n.head.appendChild(a)}catch(e){}};"complete"===n.readyState||"interactive"===n.readyState?i():(n.addEventListener("DOMContentLoaded",i),n.addEventListener("load",i));try{const a=n.createElement("script");a.textContent=`\n (function() {\n let lastHeight = 0;\n let checkCount = 0;\n const MAX_CHECKS = 20; // Prevent infinite loops\n \n // Calculate max height from various measurements with better error handling\n function getContentHeight() {\n try {\n const { body, documentElement: html } = document;\n if (!body || !html) {\n return 0;\n }\n \n const measurements = [\n body.scrollHeight,\n body.offsetHeight,\n html.clientHeight,\n html.scrollHeight,\n html.offsetHeight\n ].filter(h => h > 0 && isFinite(h));\n \n if (measurements.length === 0) {\n console.warn('HeightMonitor: No valid height measurements found');\n return 0;\n }\n \n return Math.max(...measurements);\n } catch (error) {\n console.warn('HeightMonitor: Error calculating height', error);\n return 0;\n }\n }\n \n function reportHeight() {\n try {\n const height = getContentHeight();\n if (height > 0 && height !== lastHeight) {\n lastHeight = height;\n window.parent.postMessage({\n type: 'IFRAME_HEIGHT_UPDATE',\n height: height + 10\n }, '*');\n }\n } catch (error) {\n console.warn('HeightMonitor: Error reporting height', error);\n }\n }\n \n // Enhanced height monitoring with multiple strategies\n function setupHeightMonitoring() {\n try {\n // Strategy 1: ResizeObserver for real-time monitoring\n if (window.ResizeObserver) {\n const observer = new ResizeObserver(() => {\n requestAnimationFrame(() => {\n reportHeight();\n checkCount++;\n });\n });\n observer.observe(document.body);\n observer.observe(document.documentElement);\n } else {\n console.warn('HeightMonitor: ResizeObserver not available, using fallback');\n }\n \n // Strategy 2: Handle image loading with better error handling\n const images = document.querySelectorAll('img');\n images.forEach(img => {\n if (!img.complete) {\n img.addEventListener('load', () => {\n setTimeout(reportHeight, 100); // Small delay to ensure layout is complete\n });\n img.addEventListener('error', () => {\n setTimeout(reportHeight, 100);\n });\n }\n });\n \n // Strategy 3: Watch for DOM changes with throttling\n let mutationTimeout;\n new MutationObserver(() => {\n if (mutationTimeout) clearTimeout(mutationTimeout);\n mutationTimeout = setTimeout(() => {\n requestAnimationFrame(reportHeight);\n checkCount++;\n }, 100); // Throttle mutations\n }).observe(document.body, { \n childList: true, \n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class']\n });\n \n // Strategy 4: Periodic checks with exponential backoff\n let checkDelay = 100;\n const periodicCheck = () => {\n if (checkCount >= MAX_CHECKS) {\n console.warn('HeightMonitor: Max checks reached, stopping periodic checks');\n return;\n }\n \n reportHeight();\n checkCount++;\n \n // Exponential backoff for periodic checks\n checkDelay = Math.min(checkDelay * 1.5, 2000);\n setTimeout(periodicCheck, checkDelay);\n };\n \n // Start periodic checks after initial setup\n setTimeout(periodicCheck, 500);\n \n } catch (error) {\n console.warn('HeightMonitor: Error setting up monitoring', error);\n }\n }\n \n // Initial setup with multiple triggers\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', setupHeightMonitoring);\n } else {\n setupHeightMonitoring();\n }\n \n window.addEventListener('load', () => {\n setTimeout(() => {\n reportHeight();\n checkCount++;\n }, 100);\n });\n \n // Initial checks with progressive delays\n ${cbe.map((e=>`setTimeout(() => { reportHeight(); checkCount++; }, ${e});`)).join("\n ")}\n \n // Final fallback check\n setTimeout(() => {\n if (lastHeight === 0) {\n console.warn('HeightMonitor: No height reported, forcing final check');\n reportHeight();\n }\n }, 4000);\n \n })();\n `,n.body.appendChild(a),setTimeout((()=>{if("calculating"===r.type)try{const a=e.contentDocument||e.contentWindow?.document;if(a){const e=a.body?.scrollHeight||a.body?.offsetHeight;e&&e>0?g(e+10):(o({type:"error",fallbackHeight:t}),g(t))}}catch(a){o({type:"error",fallbackHeight:t}),g(t)}}),2e3)}catch(a){setTimeout((()=>{try{const a=e.contentDocument||e.contentWindow?.document;if(a){const e=a.body?.scrollHeight||a.body?.offsetHeight;e&&e>0?g(e+10):(o({type:"error",fallbackHeight:t}),g(t))}else o({type:"error",fallbackHeight:t}),g(t)}catch(a){o({type:"error",fallbackHeight:t}),g(t)}}),1e3)}}catch(n){o({type:"error",fallbackHeight:t}),g(t)}},u=a=>{if("IFRAME_HEIGHT_UPDATE"===a.data?.type&&a.source===e.contentWindow){const e=a.data.height;e>0&&(i.current&&clearTimeout(i.current),g(e))}},c=()=>{o({type:"error",fallbackHeight:t}),g(t)},d=()=>{l()};return e.addEventListener("load",d),e.addEventListener("error",c),window.addEventListener("message",u),setTimeout((()=>{if("calculating"===r.type)try{const a=e.contentDocument||e.contentWindow?.document;a&&"complete"===a.readyState?l():(o({type:"error",fallbackHeight:t}),g(t))}catch(a){o({type:"error",fallbackHeight:t}),g(t)}}),1e3),()=>{e.removeEventListener("load",d),e.removeEventListener("error",c),window.removeEventListener("message",u),i.current&&clearTimeout(i.current),clearTimeout(n)}}),[p,g,f,y,v,r.type,s]),m&&void 0===d)return n.jsx("div",{className:"flex items-center justify-center py-5",children:n.jsx(Dq,{text:"Fetching merge fields..."})});if(!e)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx(mbe,{type:"email"})});const k="ready"===r.type?r.height:"error"===r.type?r.fallbackHeight:0,b="ready"===r.type||"error"===r.type;return n.jsxs("div",{className:"w-full h-full bg-white rounded-lg border-0 overflow-visible",children:[n.jsx("iframe",{ref:u,title:"Email Preview",srcDoc:p,className:"w-full block",style:{border:"none",backgroundColor:"white",width:"100%",height:"1px",overflow:"hidden",position:"absolute",top:"-9999px",left:"-9999px",visibility:"hidden"}}),n.jsx(Yq,{mode:"wait",children:b?n.jsx(R2.div,{initial:{height:0,opacity:0},animate:{height:k,opacity:1},transition:{height:{type:"spring",stiffness:400,damping:25,duration:"error"===r.type?.3:void 0},opacity:{duration:.2}},className:"overflow-hidden",children:"error"===r.type?n.jsx("div",{className:"w-full",style:{height:`${k}px`}}):n.jsx("iframe",{title:"Email Preview",srcDoc:p,className:"w-full block",style:{border:"none",backgroundColor:"white",width:"100%",height:`${k}px`,overflow:"hidden"}})},"content"):n.jsx(R2.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex items-center justify-center py-8",children:n.jsx(Dq,{text:"Calculating email preview..."})},"loader")})]})},pbe=()=>{const e=[{id:"dynamic-content",title:"Dynamic Content",image:"https://cdn.embedreach.com/assets/engage/merge-tags-demo.gif",imageAlt:`${DD("engage:merge_field")} Demo`,imageDesc:`Demonstration: Adding ${DD("engage:merge_field").toLowerCase()} to personalize your emails`,selectorTitle:"Dynamic Content",selectorSubtitle:"Dynamic content is a way to insert dynamic content into your email like name, email, or other details.",selectorIcon:n.jsx(HB,{})},{id:"responsive-design",title:"Responsive Design",image:"https://cdn.embedreach.com/assets/engage/layout-mobile-desktop.gif",imageAlt:"Mobile Desktop Switch Demo",imageDesc:"Demonstration: Switching between mobile and desktop preview modes",selectorTitle:"Responsive Design",selectorSubtitle:"Switch between mobile and desktop preview modes to ensure your emails look great on all devices.",selectorIcon:n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(rR,{className:"w-4 h-4"}),n.jsx(FB,{className:"w-4 h-4"})]})}],{toggleEmailHelpDialog:t,data:i}=sbe(),{toast:r}=ea(),[o,s]=a.useState("dynamic-content"),l=!1!==i?.uiDefaults?.emailHelpDialogShow,u=e.find((e=>e.id===o))??e[0];return n.jsxs("div",{className:"p-6 overflow-y-auto",children:[n.jsxs("div",{className:"mb-8 text-center",children:[n.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"Email Editor Help Center"}),n.jsx("p",{className:"text-gray-500",children:"Learn how to use our email editor's powerful features"})]}),n.jsx("div",{className:"mb-8 flex flex-col items-center min-h-[340px]",children:n.jsx(Yq,{mode:"wait",children:n.jsxs(R2.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:-24},transition:{duration:.3},className:"w-full flex flex-col items-center",children:[n.jsx("h3",{className:"text-lg font-medium mb-2",children:u.title}),n.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-gray-50 w-full max-w-2xl",children:[n.jsx("img",{src:u.image,alt:u.imageAlt,className:"w-full shadow-lg max-w-md mx-auto"}),n.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 to-transparent p-4",children:n.jsx("p",{className:"text-white text-sm",children:u.imageDesc})})]})]},u.id)})}),n.jsx("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-6 max-w-xl mx-auto",children:e.map((e=>n.jsx("div",{className:"flex-1",children:n.jsx(k3,{onClick:()=>s(e.id),title:e.selectorTitle,subtitle:e.selectorSubtitle,icon:e.selectorIcon,selected:o===e.id})},e.id)))}),l&&n.jsx("div",{className:"flex justify-center pt-4",children:n.jsx(f3,{size:"sm",onClick:()=>{t(!1),r({title:"Email editor help dialog will not show again!"})},children:"Don't show me again"})})]})},gbe=({type:e})=>n.jsxs("div",{className:"flex items-start space-x-2 text-sm text-gray-600",children:[n.jsx("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),n.jsxs("span",{children:["Please configure at least one ",e," sender before editing the template"]})]}),fbe=({containerRef:e,stripoDialogDimensions:t,showSaving:i})=>(a.useEffect((()=>{const a=a=>{const n=e.current;if(!n)return;const t=n.querySelector("ui-editor");if(!t)return;const i=t.shadowRoot;if(!i)return;const r=i.host.getBoundingClientRect();const o=function(e){for(;e;){const a=getComputedStyle(e);if(("auto"===a.overflowY||"scroll"===a.overflowY)&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null}(i.elementFromPoint(a.clientX-r.left,a.clientY-r.top))||i.firstElementChild;o&&(o.scrollTop+=a.deltaY,o.scrollLeft+=a.deltaX,a.preventDefault())},n=e.current;return n&&n.addEventListener("wheel",a,{passive:!1}),()=>{n&&n.removeEventListener("wheel",a)}}),[e]),a.useEffect((()=>{const e="stripo-service-element-hider";let a=document.getElementById(e);return a||(a=document.createElement("style"),a.id=e,document.head.appendChild(a)),a.textContent='\n /* Hide service elements with title attributes */\n #stripoEditorContainer small.service-element[title],\n #stripoEditorContainer .service-element[title],\n #stripoEditorContainer span.service-element[title],\n #stripoEditorContainer [class*="service-element"][title] {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n \n /* Also hide elements with our custom class */\n .stripo-hidden-service-element {\n display: none !important;\n visibility: hidden !important;\n opacity: 0 !important;\n position: absolute !important;\n left: -9999px !important;\n top: -9999px !important;\n width: 0 !important;\n height: 0 !important;\n overflow: hidden !important;\n pointer-events: none !important;\n }\n ',()=>{a&&a.parentNode&&a.parentNode.removeChild(a)}}),[]),a.useEffect((()=>{const a=e.current;if(!a)return;const n=()=>{const e=a.querySelector("ui-editor");if(!e)return null;const n=e.shadowRoot;return n||null},t=()=>{const e=n();if(!e)return;["small.service-element[title]",".service-element[title]","span.service-element[title]",'[class*="service-element"][title]'].forEach((a=>{e.querySelectorAll(a).forEach((e=>{const a=e,n=a.getAttribute("title")||"";/^\{\{.*\}\}$/.test(n.trim())&&(a.style.display="none",a.style.visibility="hidden",a.style.opacity="0",a.style.position="absolute",a.style.left="-9999px",a.style.top="-9999px",a.classList.add("stripo-hidden-service-element"),a.setAttribute("style",a.getAttribute("style")+"; display: none !important; visibility: hidden !important; opacity: 0 !important;"))}))}));e.querySelectorAll("span.service-element.caption.ng-star-inserted").forEach((e=>{const a=e;"Merge Tags"===a.textContent?.trim()&&(a.textContent=DD("engage:merge_field",{count:2}))}))};let i=null;let r=0;const o=setInterval((()=>{n()?(t(),(()=>{const e=n();e&&(i&&i.disconnect(),i=new MutationObserver((e=>{let a=!1;e.forEach(((e,n)=>{"childList"===e.type&&e.addedNodes.length>0&&(a=!0)})),a&&setTimeout((()=>{t()}),10)})),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","title"]}))})(),clearInterval(o)):(r++,r>20&&clearInterval(o))}),100),s=setInterval((()=>{t()}),2e3);return()=>{i&&i.disconnect(),clearInterval(s),clearInterval(o)}}),[e]),n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center",children:[n.jsx("div",{id:"externalSystemContainer",className:"flex items-center px-4 py-2"}),i&&n.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-black/50 flex items-center justify-center z-50",children:n.jsx(Dq,{textColor:"text-white",text:["Saving..."]})}),n.jsx("div",{id:"stripoEditorContainer",ref:e,style:{width:t.width-75,height:t.height-75},className:"z-10"})]})),vbe="UiEditorScript",ybe=e=>new Promise(((a,n)=>{const t=()=>{let n;e.forceRecreate&&(n=!0),window.UIEditor&&(window.UIEditor.initEditor(e.container,{...n&&{forceRecreate:n},metadata:{emailId:e.emailId},html:e.html,css:e.css,locale:"en",onTokenRefreshRequest:e=>{Promise.resolve().then((async()=>{try{const{token:a}=await(async()=>(await Re(`${m}/token`)).data)();e(a)}catch(a){}}))},messageSettingsEnabled:!1,conditionsEnabled:!1,syncModulesEnabled:!1,notifications:{info:console.info,error:console.error,warn:console.warn,success:console.log},mergeTags:e.mergeFields,mobileViewButtonSelector:".toggle-mobile-button",desktopViewButtonSelector:".toggle-desktop-button"}),a(void 0))};if(document.getElementById(vbe))t();else{const e=document.createElement("script");e.id=vbe,e.type="module",e.src="https://plugins.stripo.email/resources/uieditor/rev/2.21.0/UIEditor.js",e.onload=()=>{window.UIEditor?t():n(new Error("UIEditor not found after script load"))},e.onerror=e=>{n(e)},document.head.appendChild(e)}})),kbe=({automation:e,showStripoEditor:t,setShowStripoEditor:i,saveClicked:r,setSaveClicked:o,stripoDialogDimensions:s,mergeFieldsResponse:l,cancelClicked:u,setCancelClicked:c,actionId:d,onEditorReadyChange:m})=>{const[h,p]=a.useState(!1),[g,f]=a.useState(!1),[v,y]=a.useState(!1),k=a.useRef(!1),b=a.useRef(null),S=a.useRef(null),{data:A,isLoading:w,error:M}=(e=>{const{automationId:a,actionId:n}=e;return ye({queryKey:na.templateForActionId(a,n),queryFn:()=>ia({automationId:a,actionId:n}),...Ce})})({automationId:e.id,actionId:d}),{data:C,isLoading:T,error:x}=(()=>{const e=ce();return{...ye({queryKey:na.editorData(),queryFn:ta,...Me}),invalidateEditorData:()=>e.invalidateQueries({queryKey:na.editorData()})}})(),{updateCommunicationGroup:N}=sa(),E=a.useCallback((()=>{const e=!(!window.StripoEditorApi?.actionsApi||"function"!=typeof window.StripoEditorApi.actionsApi.save||"function"!=typeof window.StripoEditorApi.actionsApi.compileEmail);return e&&!v&&(y(!0),m?.(!0),S.current&&(clearInterval(S.current),S.current=null)),e}),[v,m]),_=a.useCallback((()=>{o(!1),c(!1),p(!1),f(!1),y(!1),m?.(!1),i(!1),S.current&&(clearInterval(S.current),S.current=null)}),[o,c,p,f,y,m,i]),P=a.useCallback((async()=>{if(v&&window.StripoEditorApi?.actionsApi&&A?.communicationGroupId)try{const e=()=>new Promise(((e,a)=>{window.StripoEditorApi.actionsApi.compileEmail({callback:async function(n,t){if(n)a(new Error(`Compile failed: ${n}`));else{try{await N({groupId:A.communicationGroupId,params:{emailHtmlBody:t}})}catch(KGe){a(KGe)}f(!0),e()}},minimize:!0,mergeTags:[],forceAmp:!1,resetDataSavedFlag:!1,disableLineHeightsReplace:!0}),window.StripoEditorApi.actionsApi.save((function(e){e?a(new Error(`Save failed: ${e}`)):p(!0)}))}));await e()}catch(e){}}),[A,N,v]);return a.useEffect((()=>{r&&v?P():r&&!v&&o(!1)}),[r,P,v,o]),a.useEffect((()=>{(h&&g||!1===t)&&_()}),[h,g,t,_]),a.useEffect((()=>{u&&_()}),[u,_]),a.useEffect((()=>{if(C?.businessId&&b.current&&A&&!k.current){(async()=>{try{await ybe({emailId:A.communicationGroupId,html:A.html||"<div></div>",css:A.css||"",container:b.current,businessId:C.businessId,mergeFields:l.mergeFields||[],forceRecreate:A.forceRecreate}),k.current=!0,S.current=setInterval((()=>{E()}),500)}catch(e){}})()}}),[C,l,A,E]),a.useEffect((()=>()=>{S.current&&clearInterval(S.current)}),[]),M||x?n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center",children:[n.jsx("div",{className:"text-red-500 mb-4",children:"Failed to load editor data"}),n.jsx(f3,{onClick:()=>window.location.reload(),variant:"outline",children:"Retry"})]}):n.jsx("div",w||T||!C||!A?{className:"w-full h-full flex flex-col items-center justify-center",children:n.jsx(Dq,{text:["Loading editor..."]})}:{className:"w-full h-full flex flex-col",children:n.jsx(fbe,{containerRef:b,stripoDialogDimensions:s,showSaving:r&&v})})},bbe=({mergeFieldsResponse:e,emailChannelSendersWithChannelAccounts:t})=>{const i=d3(),r=c3(),{updateCommunicationGroup:o}=sa(),{refetchAutomation:s}=ha(r?.id||""),{channelSenders:l}=pte(),{channelAccounts:u}=dte(),{state:{selectedActionId:c}}=a.useContext($2),{state:{replyToSettingsText:d,replyToSettingsLink:m,fromNameSettingsText:h,fromNameSettingsLink:p}}=a.useContext(Bq),{data:g,isLoading:f}=sbe(),[v,y]=a.useState(!1),[k,b]=a.useState(i?.emailChannelSenderId||null),[S,A]=a.useState(i?.emailSubject||null),[w,M]=a.useState(i?.emailPreviewText||null),[C,T]=a.useState(i?.emailHtmlBody||null),[x,N]=a.useState(!1),[E,_]=a.useState(!1),[P,j]=a.useState(!1),[L,B]=a.useState(!1),[R,z]=a.useState(""),[D,O]=a.useState(""),[K,H]=a.useState(null),I=a.useRef(!0),[G,F]=a.useState(!0),[V,J]=a.useState(!1),[U,W]=a.useState({width:0,height:0});a.useEffect((()=>{g&&!1!==x&&null===K&&(g?.uiDefaults?g?.uiDefaults?.emailHelpDialogShow&&!K&&H(!0):H(!0))}),[g,g?.uiDefaults?.emailHelpDialogShow,K,x]);const q=tbe(S,500),Z=tbe(w,500),$=a.useMemo((()=>t||l?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=u?.results?.find((a=>a.id===e.channelAccountId));return a&&(a.channelAccountMetadata.type===mte.REACH_MANAGED||a.channelAccountMetadata.type===mte.REACH_MANAGED_SES)?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`}]:[]}))||[]),[t,l?.results,u?.results]),Y=a.useRef(null);return a.useEffect((()=>{const e=setTimeout((()=>{I.current=!1}),500);return()=>clearTimeout(e)}),[]),a.useEffect((()=>{i?.emailHtmlBody&&T(i.emailHtmlBody),i?.emailCompiledHtml&&T(i.emailCompiledHtml)}),[i?.emailHtmlBody,i?.emailCompiledHtml,s]),a.useEffect((()=>{if(v){const e=setTimeout((()=>{y(!1)}),2e3);return()=>clearTimeout(e)}}),[v]),a.useEffect((()=>{const e=()=>{W({width:window.innerWidth,height:window.innerHeight})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a.useEffect((()=>{if(!I.current&&k&&q&&C&&i?.id){y(!0);(async()=>{try{o({groupId:i.id,params:{emailChannelSenderId:k,emailSubject:q,...Z&&{emailPreviewText:Z}}})}catch(e){}finally{y(!1)}})()}}),[k,q,Z,C,i?.id,o]),a.useEffect((()=>{if(l?.results&&k){const e=l.results.find((e=>e.id===k));e&&(V&&!G||O(e.channelSenderMetadata.emailReplyTo),G&&z(e.channelSenderMetadata.emailFromName),F(!1))}}),[l?.results,k,V,G]),a.useEffect((()=>{if(l?.results&&!k){const e=l.results.filter((e=>e.channelSenderMetadata.userPart));if(e[0]){const a=e[0];b(a.id),o({groupId:i?.id||"",params:{emailChannelSenderId:a.id}})}}}),[l?.results,k,i?.id,o]),a.useEffect((()=>{!1===x&&i?.id&&s()}),[x,i?.id,s]),u&&l&&c&&!f?n.jsxs("div",{className:"relative",children:[n.jsx(Cq,{open:K??!1,onOpenChange:H,children:n.jsxs(Eq,{className:"max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full",children:[n.jsxs(wq,{children:[n.jsx(jq,{children:"Email Preview Help"}),n.jsx(Lq,{children:"Learn more about the email preview and how to use it to create your email."})]}),n.jsx(pbe,{})]})}),n.jsx(Cq,{open:x,onOpenChange:N,children:n.jsxs(Eq,{className:"min-w-[100vw] min-h-[100vh]",hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault()},children:[n.jsxs(wq,{children:[n.jsx(jq,{children:"Email Editor"}),n.jsx(Lq,{children:"Learn more about the email editor and how to use it to create your email."})]}),n.jsxs("div",{className:"w-full h-full",children:[n.jsxs("div",{className:"flex justify-between items-center p-1 border-b",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h2",{className:"text-lg font-medium",children:"Email Editor"}),n.jsx(f3,{size:"sm",onClick:()=>H(!0),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium text-sm",children:"Help"}),n.jsx(b3.InfoIcon,{className:"w-4 h-4"})]})})]}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsx(cve,{})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(f3,{variant:"destructive",onClick:()=>{j(!0)},className:"text-sm px-3 py-1 rounded",children:"Cancel"}),n.jsx(f3,{onClick:()=>_(!0),className:"text-sm px-3 py-1 rounded",disabled:!L,children:"Save"})]})]}),r&&n.jsx(kbe,{cancelClicked:P,setCancelClicked:j,showStripoEditor:x,automation:r,setShowStripoEditor:N,saveClicked:E,setSaveClicked:_,stripoDialogDimensions:U,mergeFieldsResponse:e,actionId:c,onEditorReadyChange:B})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(bve,{className:"text-foreground",children:"From Email"}),n.jsxs(Zke,{onValueChange:e=>{b(e),F(!0),J(!1)},value:k??void 0,disabled:v,children:[n.jsx(Qke,{children:n.jsx(Yke,{placeholder:"Select email",className:"text-muted-foreground",children:k?$?.find((e=>e.channelSenderId===k))?.fullDomain:""})}),n.jsx(abe,{children:$?.map((e=>n.jsx(nbe,{value:e.channelSenderId,children:e.fullDomain},e.channelSenderId)))})]})]}),n.jsxs("div",{children:[n.jsx(bve,{children:n.jsxs("div",{className:"flex items-center gap-2 py-1",children:["From Name",n.jsx(wse,{title:h||"From name can be configured under settings in the home screen",link:p?{url:p}:void 0})]})}),n.jsx(U7,{value:R??"",className:"text-muted-foreground",disabled:!0})]}),n.jsxs("div",{children:[n.jsx(bve,{children:n.jsxs("div",{className:"flex items-center gap-2 py-1",children:["Reply To Email",n.jsx(wse,{title:d||"Reply to email can be configured under settings in the home screen",link:m?{url:m}:void 0})]})}),n.jsx(U7,{value:D??(k?$?.find((e=>e.channelSenderId===k))?.fullDomain:""),className:"text-muted-foreground",disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-0 py-1",children:[n.jsx(bve,{className:"text-foreground",children:"Subject"}),n.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),n.jsx(uve,{value:S,onChange:A,mergeFieldsResponse:e,placeholder:"Enter email subject",className:"text-muted-foreground",ariaLabel:"Insert merge field into subject"})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx(bve,{className:"text-foreground",children:"Preview Text"}),n.jsx(wse,{title:"This text will be used for the preview text of the email in the inbox"})]}),n.jsx(uve,{value:w,onChange:M,className:"text-muted-foreground",mergeFieldsResponse:e})]})]}),n.jsxs("div",{className:"rounded-none p-4 h-full flex flex-col",children:[n.jsxs("div",{className:"flex justify-between items-center mb-4",children:[n.jsx("h3",{className:"font-medium",children:"Preview"}),n.jsxs("div",{children:[n.jsx(f3,{onClick:()=>N(!0),className:"text-sm px-3 py-1 rounded",disabled:v||0===(t?.length??0),children:"Edit"}),0===(t?.length??0)&&n.jsx("div",{className:"relative inline-block",children:n.jsx("div",{className:"absolute right-0 top-full mt-2 w-64 p-3 bg-white border rounded-lg shadow-lg z-10",children:n.jsx(gbe,{type:"email"})})})]})]}),n.jsx("div",{className:"flex-1 w-full overflow-auto",ref:Y,children:n.jsx(hbe,{html:C??""})})]})]})]}):n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(Dq,{text:["Fetching Email Preview..."]})})};var Sbe=(e=>(e.CUSTOM="custom",e.MANAGED="managed",e))(Sbe||{}),Abe=(e=>(e.EditAudience="edit-audience",e.EditTime="edit-time",e))(Abe||{}),wbe=(e=>(e.EMAIL="email",e.SMS="sms",e))(wbe||{});const Mbe=({title:e,type:t})=>{const i=d3(),r=c3(),{toast:o}=ea(),[s,l]=a.useState(!1),{resetCommunicationGroupToDefault:u,isPending:c}=ca(),d=!!i&&(i.type===Sbe.MANAGED&&(t===ube.SMS?i.updatedFromDefault?.text_message_body:i.updatedFromDefault?.email_text_body||i.updatedFromDefault?.email_html_body)),m=t===ube.EMAIL?"Email":"SMS";return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h4",{className:"text-xl font-medium text-foreground",children:e}),n.jsx("div",{className:"flex items-center gap-2",children:d&&n.jsx(n.Fragment,{children:c?n.jsx(Dq,{}):n.jsx(f3,{variant:"outline",size:"sm",onClick:()=>l(!0),children:"Reset To Default"})})})]}),n.jsx(Cq,{open:s,onOpenChange:l,children:n.jsxs(Eq,{className:"sm:max-w-[425px]",children:[n.jsxs(_q,{children:[n.jsx(jq,{className:"text-xl font-semibold",children:"Reset To Default"}),n.jsxs(Lq,{className:"text-base text-muted-foreground",children:["Are you sure you want to reset this ",m.toLowerCase()," ","template to its default state? This action cannot be undone."]})]}),n.jsxs(Pq,{className:"flex flex-row justify-end gap-3 mt-6",children:[n.jsx(f3,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),n.jsx(f3,{variant:"destructive",onClick:async()=>{i&&r?u({communicationGroupId:i.id,automationId:r.id,type:t===ube.EMAIL?"email":"sms"},{onSuccess:()=>{o({title:DD("engage:success.communication_reset","Communication reset to default!")}),l(!1)},onSettled:()=>{l(!1)},onError:()=>{o({title:"Error updating",description:"No sender found",variant:"destructive"})}}):o({title:"Error updating",description:"No sender found",variant:"destructive"})},children:"Reset To Default"})]})]})})]})},Cbe=e=>{const{channelSenders:a,channelAccounts:n}=e;return a?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=n?.find((a=>a.id===e.channelAccountId));return a&&(a.channelAccountMetadata.type===mte.REACH_MANAGED||a.channelAccountMetadata.type===mte.REACH_MANAGED_SES)?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,baseDomain:e.channelSenderMetadata.baseDomain??void 0,channelSender:e}]:[]}))||[]},Tbe=()=>{const e=a.useRef(null),t=d3(),{channelSenders:i}=pte(),{channelAccounts:r}=dte(),{getMergeFields:o,isGetting:s}=la(t?.id??void 0),l=a.useMemo((()=>Cbe({channelSenders:i?.results??[],channelAccounts:r?.results??[]})),[i?.results,r?.results]);return!s&&o&&l?n.jsxs("div",{className:"bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:e,children:[n.jsx(Mbe,{title:"Email Campaign",type:ube.EMAIL}),n.jsx(bbe,{mergeFieldsResponse:o,emailChannelSendersWithChannelAccounts:l})]}):n.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-card text-card-foreground rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(Dq,{text:["Fetching Content..."]})})};var xbe=e=>"checkbox"===e.type,Nbe=e=>e instanceof Date,Ebe=e=>null==e;const _be=e=>"object"==typeof e;var Pbe=e=>!Ebe(e)&&!Array.isArray(e)&&_be(e)&&!Nbe(e),jbe=e=>Pbe(e)&&e.target?xbe(e.target)?e.target.checked:e.target.value:e,Lbe=(e,a)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(a)),Bbe="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function Rbe(e){let a;const n=Array.isArray(e),t="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)a=new Date(e);else if(e instanceof Set)a=new Set(e);else{if(Bbe&&(e instanceof Blob||t)||!n&&!Pbe(e))return e;if(a=n?[]:{},n||(e=>{const a=e.constructor&&e.constructor.prototype;return Pbe(a)&&a.hasOwnProperty("isPrototypeOf")})(e))for(const n in e)e.hasOwnProperty(n)&&(a[n]=Rbe(e[n]));else a=e}return a}var zbe=e=>Array.isArray(e)?e.filter(Boolean):[],Dbe=e=>void 0===e,Obe=(e,a,n)=>{if(!a||!Pbe(e))return n;const t=zbe(a.split(/[,[\].]+?/)).reduce(((e,a)=>Ebe(e)?e:e[a]),e);return Dbe(t)||t===e?Dbe(e[a])?n:e[a]:t},Kbe=e=>"boolean"==typeof e,Hbe=e=>/^\w*$/.test(e),Ibe=e=>zbe(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Gbe=(e,a,n)=>{let t=-1;const i=Hbe(a)?[a]:Ibe(a),r=i.length,o=r-1;for(;++t<r;){const a=i[t];let r=n;if(t!==o){const n=e[a];r=Pbe(n)||Array.isArray(n)?n:isNaN(+i[t+1])?{}:[]}if("__proto__"===a||"constructor"===a||"prototype"===a)return;e[a]=r,e=e[a]}};const Fbe="blur",Vbe="focusout",Jbe="change",Ube="onBlur",Wbe="onChange",qbe="onSubmit",Zbe="onTouched",$be="all",Ybe="max",Qbe="min",Xbe="maxLength",eSe="minLength",aSe="pattern",nSe="required",tSe="validate",iSe=a.createContext(null),rSe=()=>a.useContext(iSe);var oSe=(e,a,n,t=!0)=>{const i={defaultValues:a._defaultValues};for(const r in e)Object.defineProperty(i,r,{get:()=>{const i=r;return a._proxyFormState[i]!==$be&&(a._proxyFormState[i]=!t||$be),n&&(n[i]=!0),e[i]}});return i},sSe=e=>Ebe(e)||!_be(e);function lSe(e,a){if(sSe(e)||sSe(a))return e===a;if(Nbe(e)&&Nbe(a))return e.getTime()===a.getTime();const n=Object.keys(e),t=Object.keys(a);if(n.length!==t.length)return!1;for(const i of n){const n=e[i];if(!t.includes(i))return!1;if("ref"!==i){const e=a[i];if(Nbe(n)&&Nbe(e)||Pbe(n)&&Pbe(e)||Array.isArray(n)&&Array.isArray(e)?!lSe(n,e):n!==e)return!1}}return!0}const uSe=(e,n)=>{const t=a.useRef(n);lSe(n,t.current)||(t.current=n),a.useEffect(e,t.current)};var cSe=e=>"string"==typeof e,dSe=(e,a,n,t,i)=>cSe(e)?(t&&a.watch.add(e),Obe(n,e,i)):Array.isArray(e)?e.map((e=>(t&&a.watch.add(e),Obe(n,e)))):(t&&(a.watchAll=!0),n);function mSe(e){const n=rSe(),{name:t,disabled:i,control:r=n.control,shouldUnregister:o}=e,s=Lbe(r._names.array,t),l=function(e){const n=rSe(),{control:t=n.control,name:i,defaultValue:r,disabled:o,exact:s}=e||{},[l,u]=a.useState(t._getWatch(i,r));return uSe((()=>t._subscribe({name:i,formState:{values:!0},exact:s,callback:e=>!o&&u(dSe(i,t._names,e.values||t._formValues,!1,r))})),[i,r,o,s]),a.useEffect((()=>t._removeUnmounted())),l}({control:r,name:t,defaultValue:Obe(r._formValues,t,Obe(r._defaultValues,t,e.defaultValue)),exact:!0}),u=function(e){const n=rSe(),{control:t=n.control,disabled:i,name:r,exact:o}=e||{},[s,l]=a.useState(t._formState),u=a.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return uSe((()=>t._subscribe({name:r,formState:u.current,exact:o,callback:e=>{!i&&l({...t._formState,...e})}})),[r,i,o]),a.useEffect((()=>{u.current.isValid&&t._setValid(!0)}),[t]),a.useMemo((()=>oSe(s,t,u.current,!1)),[s,t])}({control:r,name:t,exact:!0}),c=a.useRef(e),d=a.useRef(r.register(t,{...e.rules,value:l,...Kbe(e.disabled)?{disabled:e.disabled}:{}})),m=a.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Obe(u.errors,t)},isDirty:{enumerable:!0,get:()=>!!Obe(u.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!Obe(u.touchedFields,t)},isValidating:{enumerable:!0,get:()=>!!Obe(u.validatingFields,t)},error:{enumerable:!0,get:()=>Obe(u.errors,t)}})),[u,t]),h=a.useCallback((e=>d.current.onChange({target:{value:jbe(e),name:t},type:Jbe})),[t]),p=a.useCallback((()=>d.current.onBlur({target:{value:Obe(r._formValues,t),name:t},type:Fbe})),[t,r._formValues]),g=a.useCallback((e=>{const a=Obe(r._fields,t);a&&e&&(a._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:a=>e.setCustomValidity(a),reportValidity:()=>e.reportValidity()})}),[r._fields,t]),f=a.useMemo((()=>({name:t,value:l,...Kbe(i)||u.disabled?{disabled:u.disabled||i}:{},onChange:h,onBlur:p,ref:g})),[t,i,u.disabled,h,p,g,l]);return a.useEffect((()=>{const e=r._options.shouldUnregister||o;r.register(t,{...c.current.rules,...Kbe(c.current.disabled)?{disabled:c.current.disabled}:{}});const a=(e,a)=>{const n=Obe(r._fields,e);n&&n._f&&(n._f.mount=a)};if(a(t,!0),e){const e=Rbe(Obe(r._options.defaultValues,t));Gbe(r._defaultValues,t,e),Dbe(Obe(r._formValues,t))&&Gbe(r._formValues,t,e)}return!s&&r.register(t),()=>{(s?e&&!r._state.action:e)?r.unregister(t):a(t,!1)}}),[t,r,s,o]),a.useEffect((()=>{r._setDisabledField({disabled:i,name:t})}),[i,t,r]),a.useMemo((()=>({field:f,formState:u,fieldState:m})),[f,u,m])}const hSe=e=>e.render(mSe(e));var pSe=(e,a,n,t,i)=>a?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[t]:i||!0}}:{},gSe=e=>Array.isArray(e)?e:[e],fSe=()=>{let e=[];return{get observers(){return e},next:a=>{for(const n of e)n.next&&n.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter((e=>e!==a))}}),unsubscribe:()=>{e=[]}}},vSe=e=>Pbe(e)&&!Object.keys(e).length,ySe=e=>"file"===e.type,kSe=e=>"function"==typeof e,bSe=e=>{if(!Bbe)return!1;const a=e?e.ownerDocument:0;return e instanceof(a&&a.defaultView?a.defaultView.HTMLElement:HTMLElement)},SSe=e=>"select-multiple"===e.type,ASe=e=>"radio"===e.type,wSe=e=>bSe(e)&&e.isConnected;function MSe(e,a){const n=Array.isArray(a)?a:Hbe(a)?[a]:Ibe(a),t=1===n.length?e:function(e,a){const n=a.slice(0,-1).length;let t=0;for(;t<n;)e=Dbe(e)?t++:e[a[t++]];return e}(e,n),i=n.length-1;return t&&delete t[n[i]],0!==i&&(Pbe(t)&&vSe(t)||Array.isArray(t)&&function(e){for(const a in e)if(e.hasOwnProperty(a)&&!Dbe(e[a]))return!1;return!0}(t))&&MSe(e,n.slice(0,-1)),e}var CSe=e=>{for(const a in e)if(kSe(e[a]))return!0;return!1};function TSe(e,a={}){const n=Array.isArray(e);if(Pbe(e)||n)for(const t in e)Array.isArray(e[t])||Pbe(e[t])&&!CSe(e[t])?(a[t]=Array.isArray(e[t])?[]:{},TSe(e[t],a[t])):Ebe(e[t])||(a[t]=!0);return a}function xSe(e,a,n){const t=Array.isArray(e);if(Pbe(e)||t)for(const i in e)Array.isArray(e[i])||Pbe(e[i])&&!CSe(e[i])?Dbe(a)||sSe(n[i])?n[i]=Array.isArray(e[i])?TSe(e[i],[]):{...TSe(e[i])}:xSe(e[i],Ebe(a)?{}:a[i],n[i]):n[i]=!lSe(e[i],a[i]);return n}var NSe=(e,a)=>xSe(e,a,TSe(a));const ESe={value:!1,isValid:!1},_Se={value:!0,isValid:!0};var PSe=e=>{if(Array.isArray(e)){if(e.length>1){const a=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:a,isValid:!!a.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Dbe(e[0].attributes.value)?Dbe(e[0].value)||""===e[0].value?_Se:{value:e[0].value,isValid:!0}:_Se:ESe}return ESe},jSe=(e,{valueAsNumber:a,valueAsDate:n,setValueAs:t})=>Dbe(e)?e:a?""===e?NaN:e?+e:e:n&&cSe(e)?new Date(e):t?t(e):e;const LSe={isValid:!1,value:null};var BSe=e=>Array.isArray(e)?e.reduce(((e,a)=>a&&a.checked&&!a.disabled?{isValid:!0,value:a.value}:e),LSe):LSe;function RSe(e){const a=e.ref;return ySe(a)?a.files:ASe(a)?BSe(e.refs).value:SSe(a)?[...a.selectedOptions].map((({value:e})=>e)):xbe(a)?PSe(e.refs).value:jSe(Dbe(a.value)?e.ref.value:a.value,e)}var zSe=e=>e instanceof RegExp,DSe=e=>Dbe(e)?e:zSe(e)?e.source:Pbe(e)?zSe(e.value)?e.value.source:e.value:e,OSe=e=>({isOnSubmit:!e||e===qbe,isOnBlur:e===Ube,isOnChange:e===Wbe,isOnAll:e===$be,isOnTouch:e===Zbe});const KSe="AsyncFunction";var HSe=(e,a,n)=>!n&&(a.watchAll||a.watch.has(e)||[...a.watch].some((a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length)))));const ISe=(e,a,n,t)=>{for(const i of n||Object.keys(e)){const n=Obe(e,i);if(n){const{_f:e,...r}=n;if(e){if(e.refs&&e.refs[0]&&a(e.refs[0],i)&&!t)return!0;if(e.ref&&a(e.ref,e.name)&&!t)return!0;if(ISe(r,a))break}else if(Pbe(r)&&ISe(r,a))break}}};function GSe(e,a,n){const t=Obe(e,n);if(t||Hbe(n))return{error:t,name:n};const i=n.split(".");for(;i.length;){const t=i.join("."),r=Obe(a,t),o=Obe(e,t);if(r&&!Array.isArray(r)&&n!==t)return{name:n};if(o&&o.type)return{name:t,error:o};i.pop()}return{name:n}}var FSe=(e,a,n)=>{const t=gSe(Obe(e,n));return Gbe(t,"root",a[n]),Gbe(e,n,t),e},VSe=e=>cSe(e);function JSe(e,a,n="validate"){if(VSe(e)||Array.isArray(e)&&e.every(VSe)||Kbe(e)&&!e)return{type:n,message:VSe(e)?e:"",ref:a}}var USe=e=>Pbe(e)&&!zSe(e)?e:{value:e,message:""},WSe=async(e,a,n,t,i,r)=>{const{ref:o,refs:s,required:l,maxLength:u,minLength:c,min:d,max:m,pattern:h,validate:p,name:g,valueAsNumber:f,mount:v}=e._f,y=Obe(n,g);if(!v||a.has(g))return{};const k=s?s[0]:o,b=e=>{i&&k.reportValidity&&(k.setCustomValidity(Kbe(e)?"":e||""),k.reportValidity())},S={},A=ASe(o),w=xbe(o),M=A||w,C=(f||ySe(o))&&Dbe(o.value)&&Dbe(y)||bSe(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,T=pSe.bind(null,g,t,S),x=(e,a,n,t=Xbe,i=eSe)=>{const r=e?a:n;S[g]={type:e?t:i,message:r,ref:o,...T(e?t:i,r)}};if(r?!Array.isArray(y)||!y.length:l&&(!M&&(C||Ebe(y))||Kbe(y)&&!y||w&&!PSe(s).isValid||A&&!BSe(s).isValid)){const{value:e,message:a}=VSe(l)?{value:!!l,message:l}:USe(l);if(e&&(S[g]={type:nSe,message:a,ref:k,...T(nSe,a)},!t))return b(a),S}if(!(C||Ebe(d)&&Ebe(m))){let e,a;const n=USe(m),i=USe(d);if(Ebe(y)||isNaN(y)){const t=o.valueAsDate||new Date(y),r=e=>new Date((new Date).toDateString()+" "+e),s="time"==o.type,l="week"==o.type;cSe(n.value)&&y&&(e=s?r(y)>r(n.value):l?y>n.value:t>new Date(n.value)),cSe(i.value)&&y&&(a=s?r(y)<r(i.value):l?y<i.value:t<new Date(i.value))}else{const t=o.valueAsNumber||(y?+y:y);Ebe(n.value)||(e=t>n.value),Ebe(i.value)||(a=t<i.value)}if((e||a)&&(x(!!e,n.message,i.message,Ybe,Qbe),!t))return b(S[g].message),S}if((u||c)&&!C&&(cSe(y)||r&&Array.isArray(y))){const e=USe(u),a=USe(c),n=!Ebe(e.value)&&y.length>+e.value,i=!Ebe(a.value)&&y.length<+a.value;if((n||i)&&(x(n,e.message,a.message),!t))return b(S[g].message),S}if(h&&!C&&cSe(y)){const{value:e,message:a}=USe(h);if(zSe(e)&&!y.match(e)&&(S[g]={type:aSe,message:a,ref:o,...T(aSe,a)},!t))return b(a),S}if(p)if(kSe(p)){const e=JSe(await p(y,n),k);if(e&&(S[g]={...e,...T(tSe,e.message)},!t))return b(e.message),S}else if(Pbe(p)){let e={};for(const a in p){if(!vSe(e)&&!t)break;const i=JSe(await p[a](y,n),k,a);i&&(e={...i,...T(a,i.message)},b(i.message),t&&(S[g]=e))}if(!vSe(e)&&(S[g]={ref:k,...e},!t))return S}return b(!0),S};const qSe={mode:qbe,reValidateMode:Wbe,shouldFocusError:!0};function ZSe(e={}){let a={...qSe,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:kSe(a.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:a.errors||{},disabled:a.disabled||!1};const t={};let i,r=(Pbe(a.defaultValues)||Pbe(a.values))&&Rbe(a.values||a.defaultValues)||{},o=a.shouldUnregister?{}:Rbe(r),s={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0;const c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...c};const m={array:fSe(),state:fSe()},h=OSe(a.mode),p=OSe(a.reValidateMode),g=a.criteriaMode===$be,f=async e=>{if(!a.disabled&&(c.isValid||d.isValid||e)){const e=a.resolver?vSe((await S()).errors):await A(t,!0);e!==n.isValid&&m.state.next({isValid:e})}},v=(e,t)=>{!a.disabled&&(c.isValidating||c.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(l.mount)).forEach((e=>{e&&(t?Gbe(n.validatingFields,e,t):MSe(n.validatingFields,e))})),m.state.next({validatingFields:n.validatingFields,isValidating:!vSe(n.validatingFields)}))},y=(e,a,n,i)=>{const l=Obe(t,e);if(l){const t=Obe(o,e,Dbe(n)?Obe(r,e):n);Dbe(t)||i&&i.defaultChecked||a?Gbe(o,e,a?t:RSe(l._f)):C(e,t),s.mount&&f()}},k=(e,t,i,o,s)=>{let l=!1,u=!1;const h={name:e};if(!a.disabled){if(!i||o){(c.isDirty||d.isDirty)&&(u=n.isDirty,n.isDirty=h.isDirty=w(),l=u!==h.isDirty);const a=lSe(Obe(r,e),t);u=!!Obe(n.dirtyFields,e),a?MSe(n.dirtyFields,e):Gbe(n.dirtyFields,e,!0),h.dirtyFields=n.dirtyFields,l=l||(c.dirtyFields||d.dirtyFields)&&u!==!a}if(i){const a=Obe(n.touchedFields,e);a||(Gbe(n.touchedFields,e,i),h.touchedFields=n.touchedFields,l=l||(c.touchedFields||d.touchedFields)&&a!==i)}l&&s&&m.state.next(h)}return l?h:{}},b=(e,t,r,o)=>{const s=Obe(n.errors,e),l=(c.isValid||d.isValid)&&Kbe(t)&&n.isValid!==t;if(a.delayError&&r?(i=(e=>a=>{clearTimeout(u),u=setTimeout(e,a)})((()=>((e,a)=>{Gbe(n.errors,e,a),m.state.next({errors:n.errors})})(e,r))),i(a.delayError)):(clearTimeout(u),i=null,r?Gbe(n.errors,e,r):MSe(n.errors,e)),(r?!lSe(s,r):s)||!vSe(o)||l){const a={...o,...l&&Kbe(t)?{isValid:t}:{},errors:n.errors,name:e};n={...n,...a},m.state.next(a)}},S=async e=>{v(e,!0);const n=await a.resolver(o,a.context,((e,a,n,t)=>{const i={};for(const r of e){const e=Obe(a,r);e&&Gbe(i,r,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:t}})(e||l.mount,t,a.criteriaMode,a.shouldUseNativeValidation));return v(e),n},A=async(e,t,i={valid:!0})=>{for(const s in e){const u=e[s];if(u){const{_f:e,...d}=u;if(e){const d=l.array.has(e.name),m=u._f&&(!!(r=u._f)&&!!r.validate&&!!(kSe(r.validate)&&r.validate.constructor.name===KSe||Pbe(r.validate)&&Object.values(r.validate).find((e=>e.constructor.name===KSe))));m&&c.validatingFields&&v([s],!0);const h=await WSe(u,l.disabled,o,g,a.shouldUseNativeValidation&&!t,d);if(m&&c.validatingFields&&v([s]),h[e.name]&&(i.valid=!1,t))break;!t&&(Obe(h,e.name)?d?FSe(n.errors,h,e.name):Gbe(n.errors,e.name,h[e.name]):MSe(n.errors,e.name))}!vSe(d)&&await A(d,t,i)}}var r;return i.valid},w=(e,n)=>!a.disabled&&(e&&n&&Gbe(o,e,n),!lSe(P(),r)),M=(e,a,n)=>dSe(e,l,{...s.mount?o:Dbe(a)?r:cSe(e)?{[e]:a}:a},n,a),C=(e,a,n={})=>{const i=Obe(t,e);let r=a;if(i){const n=i._f;n&&(!n.disabled&&Gbe(o,e,jSe(a,n)),r=bSe(n.ref)&&Ebe(a)?"":a,SSe(n.ref)?[...n.ref.options].forEach((e=>e.selected=r.includes(e.value))):n.refs?xbe(n.ref)?n.refs.length>1?n.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(r)?!!r.find((a=>a===e.value)):r===e.value))):n.refs[0]&&(n.refs[0].checked=!!r):n.refs.forEach((e=>e.checked=e.value===r)):ySe(n.ref)?n.ref.value="":(n.ref.value=r,n.ref.type||m.state.next({name:e,values:Rbe(o)})))}(n.shouldDirty||n.shouldTouch)&&k(e,r,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&_(e)},T=(e,a,n)=>{for(const i in a){const r=a[i],o=`${e}.${i}`,s=Obe(t,o);(l.array.has(e)||Pbe(r)||s&&!s._f)&&!Nbe(r)?T(o,r,n):C(o,r,n)}},x=(e,a,i={})=>{const u=Obe(t,e),h=l.array.has(e),p=Rbe(a);Gbe(o,e,p),h?(m.array.next({name:e,values:Rbe(o)}),(c.isDirty||c.dirtyFields||d.isDirty||d.dirtyFields)&&i.shouldDirty&&m.state.next({name:e,dirtyFields:NSe(r,o),isDirty:w(e,p)})):!u||u._f||Ebe(p)?C(e,p,i):T(e,p,i),HSe(e,l)&&m.state.next({...n}),m.state.next({name:s.mount?e:void 0,values:Rbe(o)})},N=async e=>{s.mount=!0;const r=e.target;let u=r.name,y=!0;const w=Obe(t,u),M=e=>{y=Number.isNaN(e)||Nbe(e)&&isNaN(e.getTime())||lSe(e,Obe(o,u,e))};if(w){let s,T;const x=r.type?RSe(w._f):jbe(e),N=e.type===Fbe||e.type===Vbe,E=!((C=w._f).mount&&(C.required||C.min||C.max||C.maxLength||C.minLength||C.pattern||C.validate)||a.resolver||Obe(n.errors,u)||w._f.deps)||((e,a,n,t,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(a||e):(n?t.isOnBlur:i.isOnBlur)?!e:!(n?t.isOnChange:i.isOnChange)||e))(N,Obe(n.touchedFields,u),n.isSubmitted,p,h),P=HSe(u,l,N);Gbe(o,u,x),N?(w._f.onBlur&&w._f.onBlur(e),i&&i(0)):w._f.onChange&&w._f.onChange(e);const j=k(u,x,N),L=!vSe(j)||P;if(!N&&m.state.next({name:u,type:e.type,values:Rbe(o)}),E)return(c.isValid||d.isValid)&&("onBlur"===a.mode?N&&f():N||f()),L&&m.state.next({name:u,...P?{}:j});if(!N&&P&&m.state.next({...n}),a.resolver){const{errors:e}=await S([u]);if(M(x),y){const a=GSe(n.errors,t,u),i=GSe(e,t,a.name||u);s=i.error,u=i.name,T=vSe(e)}}else v([u],!0),s=(await WSe(w,l.disabled,o,g,a.shouldUseNativeValidation))[u],v([u]),M(x),y&&(s?T=!1:(c.isValid||d.isValid)&&(T=await A(t,!0)));y&&(w._f.deps&&_(w._f.deps),b(u,T,s,j))}var C},E=(e,a)=>{if(Obe(n.errors,a)&&e.focus)return e.focus(),1},_=async(e,i={})=>{let r,o;const s=gSe(e);if(a.resolver){const a=await(async e=>{const{errors:a}=await S(e);if(e)for(const t of e){const e=Obe(a,t);e?Gbe(n.errors,t,e):MSe(n.errors,t)}else n.errors=a;return a})(Dbe(e)?e:s);r=vSe(a),o=e?!s.some((e=>Obe(a,e))):r}else e?(o=(await Promise.all(s.map((async e=>{const a=Obe(t,e);return await A(a&&a._f?{[e]:a}:a)})))).every(Boolean),(o||n.isValid)&&f()):o=r=await A(t);return m.state.next({...!cSe(e)||(c.isValid||d.isValid)&&r!==n.isValid?{}:{name:e},...a.resolver||!e?{isValid:r}:{},errors:n.errors}),i.shouldFocus&&!o&&ISe(t,E,e?s:l.mount),o},P=e=>{const a={...s.mount?o:r};return Dbe(e)?a:cSe(e)?Obe(a,e):e.map((e=>Obe(a,e)))},j=(e,a)=>({invalid:!!Obe((a||n).errors,e),isDirty:!!Obe((a||n).dirtyFields,e),error:Obe((a||n).errors,e),isValidating:!!Obe(n.validatingFields,e),isTouched:!!Obe((a||n).touchedFields,e)}),L=(e,a,i)=>{const r=(Obe(t,e,{_f:{}})._f||{}).ref,o=Obe(n.errors,e)||{},{ref:s,message:l,type:u,...c}=o;Gbe(n.errors,e,{...c,...a,ref:r}),m.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&r&&r.focus&&r.focus()},B=e=>m.state.subscribe({next:a=>{var t,i,r;i=a.name,r=e.exact,(t=e.name)&&i&&t!==i&&!gSe(t).some((e=>e&&(r?e===i:e.startsWith(i)||i.startsWith(e))))||!((e,a,n,t)=>{n(e);const{name:i,...r}=e;return vSe(r)||Object.keys(r).length>=Object.keys(a).length||Object.keys(r).find((e=>a[e]===(!t||$be)))})(a,e.formState||c,G,e.reRenderRoot)||e.callback({values:{...o},...n,...a})}}).unsubscribe,R=(e,i={})=>{for(const s of e?gSe(e):l.mount)l.mount.delete(s),l.array.delete(s),i.keepValue||(MSe(t,s),MSe(o,s)),!i.keepError&&MSe(n.errors,s),!i.keepDirty&&MSe(n.dirtyFields,s),!i.keepTouched&&MSe(n.touchedFields,s),!i.keepIsValidating&&MSe(n.validatingFields,s),!a.shouldUnregister&&!i.keepDefaultValue&&MSe(r,s);m.state.next({values:Rbe(o)}),m.state.next({...n,...i.keepDirty?{isDirty:w()}:{}}),!i.keepIsValid&&f()},z=({disabled:e,name:a})=>{(Kbe(e)&&s.mount||e||l.disabled.has(a))&&(e?l.disabled.add(a):l.disabled.delete(a))},D=(e,n={})=>{let i=Obe(t,e);const o=Kbe(n.disabled)||Kbe(a.disabled);return Gbe(t,e,{...i||{},_f:{...i&&i._f?i._f:{ref:{name:e}},name:e,mount:!0,...n}}),l.mount.add(e),i?z({disabled:Kbe(n.disabled)?n.disabled:a.disabled,name:e}):y(e,!0,n.value),{...o?{disabled:n.disabled||a.disabled}:{},...a.progressive?{required:!!n.required,min:DSe(n.min),max:DSe(n.max),minLength:DSe(n.minLength),maxLength:DSe(n.maxLength),pattern:DSe(n.pattern)}:{},name:e,onChange:N,onBlur:N,ref:o=>{if(o){D(e,n),i=Obe(t,e);const a=Dbe(o.value)&&o.querySelectorAll&&o.querySelectorAll("input,select,textarea")[0]||o,s=(e=>ASe(e)||xbe(e))(a),l=i._f.refs||[];if(s?l.find((e=>e===a)):a===i._f.ref)return;Gbe(t,e,{_f:{...i._f,...s?{refs:[...l.filter(wSe),a,...Array.isArray(Obe(r,e))?[{}]:[]],ref:{type:a.type,name:e}}:{ref:a}}}),y(e,!1,void 0,a)}else i=Obe(t,e,{}),i._f&&(i._f.mount=!1),(a.shouldUnregister||n.shouldUnregister)&&(!Lbe(l.array,e)||!s.action)&&l.unMount.add(e)}}},O=()=>a.shouldFocusError&&ISe(t,E,l.mount),K=(e,i)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let u=Rbe(o);if(m.state.next({isSubmitting:!0}),a.resolver){const{errors:e,values:a}=await S();n.errors=e,u=a}else await A(t);if(l.disabled.size)for(const e of l.disabled)Gbe(u,e,void 0);if(MSe(n.errors,"root"),vSe(n.errors)){m.state.next({errors:{}});try{await e(u,r)}catch(c){s=c}}else i&&await i({...n.errors},r),O(),setTimeout(O);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:vSe(n.errors)&&!s,submitCount:n.submitCount+1,errors:n.errors}),s)throw s},H=(e,i={})=>{const u=e?Rbe(e):r,d=Rbe(u),h=vSe(e),p=h?r:d;if(i.keepDefaultValues||(r=u),!i.keepValues){if(i.keepDirtyValues){const e=new Set([...l.mount,...Object.keys(NSe(r,o))]);for(const a of Array.from(e))Obe(n.dirtyFields,a)?Gbe(p,a,Obe(o,a)):x(a,Obe(p,a))}else{if(Bbe&&Dbe(e))for(const e of l.mount){const a=Obe(t,e);if(a&&a._f){const e=Array.isArray(a._f.refs)?a._f.refs[0]:a._f.ref;if(bSe(e)){const a=e.closest("form");if(a){a.reset();break}}}}for(const e of l.mount)x(e,Obe(p,e))}o=Rbe(p),m.array.next({values:{...p}}),m.state.next({values:{...p}})}l={mount:i.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!c.isValid||!!i.keepIsValid||!!i.keepDirtyValues,s.watch=!!a.shouldUnregister,m.state.next({submitCount:i.keepSubmitCount?n.submitCount:0,isDirty:!h&&(i.keepDirty?n.isDirty:!(!i.keepDefaultValues||lSe(e,r))),isSubmitted:!!i.keepIsSubmitted&&n.isSubmitted,dirtyFields:h?{}:i.keepDirtyValues?i.keepDefaultValues&&o?NSe(r,o):n.dirtyFields:i.keepDefaultValues&&e?NSe(r,e):i.keepDirty?n.dirtyFields:{},touchedFields:i.keepTouched?n.touchedFields:{},errors:i.keepErrors?n.errors:{},isSubmitSuccessful:!!i.keepIsSubmitSuccessful&&n.isSubmitSuccessful,isSubmitting:!1})},I=(e,a)=>H(kSe(e)?e(o):e,a),G=e=>{n={...n,...e}},F={control:{register:D,unregister:R,getFieldState:j,handleSubmit:K,setError:L,_subscribe:B,_runSchema:S,_getWatch:M,_getDirty:w,_setValid:f,_setFieldArray:(e,i=[],l,u,h=!0,p=!0)=>{if(u&&l&&!a.disabled){if(s.action=!0,p&&Array.isArray(Obe(t,e))){const a=l(Obe(t,e),u.argA,u.argB);h&&Gbe(t,e,a)}if(p&&Array.isArray(Obe(n.errors,e))){const a=l(Obe(n.errors,e),u.argA,u.argB);h&&Gbe(n.errors,e,a),((e,a)=>{!zbe(Obe(e,a)).length&&MSe(e,a)})(n.errors,e)}if((c.touchedFields||d.touchedFields)&&p&&Array.isArray(Obe(n.touchedFields,e))){const a=l(Obe(n.touchedFields,e),u.argA,u.argB);h&&Gbe(n.touchedFields,e,a)}(c.dirtyFields||d.dirtyFields)&&(n.dirtyFields=NSe(r,o)),m.state.next({name:e,isDirty:w(e,i),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Gbe(o,e,i)},_setDisabledField:z,_setErrors:e=>{n.errors=e,m.state.next({errors:n.errors,isValid:!1})},_getFieldArray:e=>zbe(Obe(s.mount?o:r,e,a.shouldUnregister?Obe(r,e,[]):[])),_reset:H,_resetDefaultValues:()=>kSe(a.defaultValues)&&a.defaultValues().then((e=>{I(e,a.resetOptions),m.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of l.unMount){const a=Obe(t,e);a&&(a._f.refs?a._f.refs.every((e=>!wSe(e))):!wSe(a._f.ref))&&R(e)}l.unMount=new Set},_disableForm:e=>{Kbe(e)&&(m.state.next({disabled:e}),ISe(t,((a,n)=>{const i=Obe(t,n);i&&(a.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach((a=>{a.disabled=i._f.disabled||e})))}),0,!1))},_subjects:m,_proxyFormState:c,get _fields(){return t},get _formValues(){return o},get _state(){return s},set _state(e){s=e},get _defaultValues(){return r},get _names(){return l},set _names(e){l=e},get _formState(){return n},get _options(){return a},set _options(e){a={...a,...e}}},subscribe:e=>(s.mount=!0,d={...d,...e.formState},B({...e,formState:d})),trigger:_,register:D,handleSubmit:K,watch:(e,a)=>kSe(e)?m.state.subscribe({next:n=>e(M(void 0,a),n)}):M(e,a,!0),setValue:x,getValues:P,reset:I,resetField:(e,a={})=>{Obe(t,e)&&(Dbe(a.defaultValue)?x(e,Rbe(Obe(r,e))):(x(e,a.defaultValue),Gbe(r,e,Rbe(a.defaultValue))),a.keepTouched||MSe(n.touchedFields,e),a.keepDirty||(MSe(n.dirtyFields,e),n.isDirty=a.defaultValue?w(e,Rbe(Obe(r,e))):w()),a.keepError||(MSe(n.errors,e),c.isValid&&f()),m.state.next({...n}))},clearErrors:e=>{e&&gSe(e).forEach((e=>MSe(n.errors,e))),m.state.next({errors:e?n.errors:{}})},unregister:R,setError:L,setFocus:(e,a={})=>{const n=Obe(t,e),i=n&&n._f;if(i){const e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),a.shouldSelect&&kSe(e.select)&&e.select())}},getFieldState:j};return{...F,formControl:F}}const $Se="undefined"!=typeof window?a.useLayoutEffect:a.useEffect;function YSe(e={}){const n=a.useRef(void 0),t=a.useRef(void 0),[i,r]=a.useState({isDirty:!1,isValidating:!1,isLoading:kSe(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:kSe(e.defaultValues)?void 0:e.defaultValues});n.current||(n.current={...e.formControl?e.formControl:ZSe(e),formState:i},e.formControl&&e.defaultValues&&!kSe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));const o=n.current.control;return o._options=e,$Se((()=>{const e=o._subscribe({formState:o._proxyFormState,callback:()=>r({...o._formState}),reRenderRoot:!0});return r((e=>({...e,isReady:!0}))),e}),[o]),a.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),a.useEffect((()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode),e.errors&&!vSe(e.errors)&&o._setErrors(e.errors)}),[o,e.errors,e.mode,e.reValidateMode]),a.useEffect((()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})}),[o,e.shouldUnregister]),a.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==i.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,i.isDirty]),a.useEffect((()=>{e.values&&!lSe(e.values,t.current)?(o._reset(e.values,o._options.resetOptions),t.current=e.values,r((e=>({...e})))):o._resetDefaultValues()}),[o,e.values]),a.useEffect((()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),n.current.formState=oSe(i,o),n.current}const QSe=e=>{const{children:n,...t}=e;return a.createElement(iSe.Provider,{value:t},n)},XSe=r.createContext({}),eAe=({...e})=>n.jsx(XSe.Provider,{value:{name:e.name},children:n.jsx(hSe,{...e})}),aAe=()=>{const e=r.useContext(XSe),a=r.useContext(nAe),{getFieldState:n,formState:t}=rSe(),i=n(e.name,t);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:o}=a;return{id:o,name:e.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...i}},nAe=r.createContext({}),tAe=r.forwardRef((({className:e,...a},t)=>{const i=r.useId();return n.jsx(nAe.Provider,{value:{id:i},children:n.jsx("div",{ref:t,className:mz("space-y-2",e),...a})})}));tAe.displayName="FormItem";const iAe=r.forwardRef((({className:e,...a},t)=>{const{error:i,formItemId:r}=aAe();return n.jsx(bve,{ref:t,className:mz(i&&"text-destructive",e),htmlFor:r,...a})}));iAe.displayName="FormLabel";const rAe=r.forwardRef((({...e},a)=>{const{error:t,formItemId:i,formDescriptionId:r,formMessageId:o}=aAe();return n.jsx(yq,{ref:a,id:i,"aria-describedby":t?`${r} ${o}`:`${r}`,"aria-invalid":!!t,...e})}));rAe.displayName="FormControl";r.forwardRef((({className:e,...a},t)=>{const{formDescriptionId:i}=aAe();return n.jsx("p",{ref:t,id:i,className:mz("text-[0.8rem] text-muted-foreground",e),...a})})).displayName="FormDescription";const oAe=r.forwardRef((({className:e,children:a,...t},i)=>{const{error:r,formMessageId:o}=aAe(),s=r?String(r?.message):a;return s?n.jsx("p",{ref:i,id:o,className:mz("text-[0.8rem] font-medium text-destructive",e),...t,children:s}):null}));oAe.displayName="FormMessage";const sAe="onboarding",lAe="settings",uAe="todo",cAe="active",dAe="done",mAe={[dAe]:{icon:bB,className:"w-5 h-5 fill-green-500 text-background",style:{width:"1.5rem",height:"1.5rem"}},[cAe]:{icon:AB,className:"w-5 h-5 text-primary"},[uAe]:{icon:SB,className:"w-5 h-5 text-muted-foreground/60"}},hAe=a.createContext(null);function pAe({config:e,onStepChange:n,onClose:t}){const i=e.steps.map((e=>e.key)),[r,o]=a.useState(e.initialStep||i[0]),[s,l]=a.useState(new Set),[u,c]=a.useState(new Set([r])),[d,m]=a.useState({}),h=i.indexOf(r),p=0===h,g=h===i.length-1,f=!g,v=!p,y=a.useCallback((e=>{i.includes(e)&&(o(e),c((a=>new Set([...a,e]))),n?.(e))}),[i,n]),k=a.useCallback((()=>{if(f){y(i[h+1])}else g&&t&&t()}),[f,h,i,y,g,t]),b=a.useCallback((()=>{if(v){y(i[h-1])}}),[v,h,i,y]),S=a.useCallback((e=>{l((a=>new Set([...a,e])))}),[]),A=a.useCallback(((e,a)=>{m((n=>({...n,[e]:a}))),S(e)}),[S]),w=a.useCallback((e=>s.has(e)),[s]),M=a.useCallback((e=>u.has(e)),[u]);return{navigation:{currentStep:r,steps:i,goToStep:y,goToNextStep:k,goToPreviousStep:b,canGoNext:f,canGoPrevious:v,currentStepIndex:h,isFirstStep:p,isLastStep:g},state:{completedSteps:Array.from(s),visitedSteps:Array.from(u),formData:d,markStepComplete:S,isStepComplete:w,isStepVisited:M,updateFormData:A}}}const gAe=sq,fAe=lq,vAe=uq,yAe=r.forwardRef((({className:e,...a},t)=>n.jsx(cq,{className:mz("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a,ref:t})));yAe.displayName=cq.displayName;const kAe=XL("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),bAe=r.forwardRef((({side:e="right",className:a,children:t,...i},r)=>n.jsxs(vAe,{children:[n.jsx(yAe,{}),n.jsxs(dq,{ref:r,className:mz(kAe({side:e}),a),"data-reach-root":!0,...i,children:[t,n.jsxs(pq,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[n.jsx(yR,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]})));bAe.displayName=dq.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(mq,{ref:t,className:mz("text-lg font-semibold text-foreground",e),...a}))).displayName=mq.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(hq,{ref:t,className:mz("text-sm text-muted-foreground",e),...a}))).displayName=hq.displayName;const SAe="reach-wizard-sidebar-module__buttonBase___yHuwB",AAe="reach-wizard-sidebar-module__buttonOnboarding___0P7B4",wAe="reach-wizard-sidebar-module__buttonSettings___JKPkG",MAe="reach-wizard-sidebar-module__buttonOnboardingActive___NyRja",CAe="reach-wizard-sidebar-module__buttonSettingsActive___NZlSF",TAe=XL(["reach-wizard-sidebar-module__base___-bfXZ"],{variants:{mode:{onboarding:"reach-wizard-sidebar-module__onboarding___pxUBM",settings:"reach-wizard-sidebar-module__settings___m6NkU"}},defaultVariants:{mode:sAe}}),xAe=XL([SAe],{variants:{mode:{onboarding:AAe,settings:wAe},isActive:{true:"",false:""}},defaultVariants:{mode:sAe,isActive:!1}}),NAe=({status:e})=>{const a=mAe[e]??mAe[uAe];return n.jsx(a.icon,{className:a.className,...a.style&&{style:a.style}})},EAe=({items:e,currentItem:a,onItemChange:t,completedItems:i=[],mode:r=sAe,className:o})=>n.jsx("div",{className:mz(TAe({mode:r}),o,r===sAe?"":"max-w-[22ch]"),children:n.jsx("div",{className:mz(r===sAe?"space-y-1":"space-y-2"),children:e.map((e=>{const o=e.status||((e,a,n=[])=>n.includes(e)?dAe:e===a?cAe:uAe)(e.key,a,i),s=a===e.key,l=e.icon;return n.jsxs(f3,{variant:s?"secondary":"ghost",onClick:()=>t(e.key),className:mz(xAe({mode:r,isActive:s}),"group",r===sAe&&s&&MAe,r===lAe&&s&&CAe),children:[r===sAe&&n.jsx("div",{className:"w-7 h-7 flex items-center justify-center flex-shrink-0",children:n.jsx(NAe,{status:o})}),r===lAe&&l&&n.jsx(l,{className:"w-4 h-4 transition-colors",style:{color:o===cAe?"hsl(var(--reach-foreground))":"hsl(var(--reach-muted-foreground) / 0.5)"}}),n.jsx("span",{className:"text-sm font-medium",children:e.label})]},e.key)}))})}),_Ae=({open:e,onOpenChange:t,title:i,description:r,sidebarItems:o,currentStep:s,onStepChange:l,completedSteps:u=[],mode:c="onboarding",showSidebar:d=!0,showMobileNav:m=!0,children:h,className:p,contentClassName:g})=>{const[f,v]=a.useState(!1);return n.jsx(Cq,{open:e,onOpenChange:t,modal:!0,children:n.jsxs(Eq,{className:mz("@container/wizard w-[90vw] max-h-[90vh] h-full flex flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl p-0",p),onEscapeKeyDown:()=>{t(!1)},onPointerDownOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onInteractOutside:e=>{const a=e.target;(e.composedPath().some((e=>"classList"in e&&Array.from(e.classList).includes("pac-item")))||a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},onFocusOutside:e=>{const a=e.target;(a.closest("[data-radix-toast-viewport]")||a.closest('[role="status"][aria-live="polite"]')||a.closest('[data-state="open"][data-swipe="end"]')||a.closest(".fixed.top-0.z-\\[100\\]"))&&e.preventDefault()},children:[n.jsxs(wq,{children:[n.jsx(jq,{children:i}),n.jsx(Lq,{children:r})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex",children:[d&&n.jsxs(n.Fragment,{children:[n.jsx(EAe,{mode:c,items:o,currentItem:s,onItemChange:l,completedItems:u,className:"hidden @lg/wizard:block"}),m&&n.jsxs(gAe,{open:f,onOpenChange:v,children:[n.jsx(fAe,{asChild:!0,children:n.jsx(f3,{variant:"ghost",size:"icon",className:"flex @lg/wizard:hidden absolute top-4 left-4 z-10",children:n.jsx(KB,{className:"h-4 w-4"})})}),n.jsx(bAe,{side:"left",className:"w-64 p-0",children:n.jsx(EAe,{mode:c,items:o,currentItem:s,onItemChange:e=>{l(e),m&&v(!1)},completedItems:u,className:"border-r-0"})})]})]}),n.jsx("div",{className:mz("flex-1 min-h-0",g),children:h})]})]})})},PAe=({title:e,description:a,className:t})=>n.jsxs("div",{className:mz("px-8",t),children:[n.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:e}),a&&n.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:a})]}),jAe=({control:e,name:a,label:t,placeholder:i,type:r="text",disabled:o})=>n.jsx(eAe,{control:e,name:a,render:({field:e})=>n.jsxs(tAe,{children:[n.jsx(iAe,{children:t}),n.jsx(rAe,{children:n.jsx(U7,{...e,type:r,placeholder:i,disabled:o,className:"bg-background"})}),n.jsx(oAe,{})]})}),LAe=({control:e,name:a,label:t,placeholder:i,options:r,disabled:o})=>n.jsx(eAe,{control:e,name:a,render:({field:e})=>n.jsxs(tAe,{children:[n.jsx(iAe,{children:t}),n.jsxs(Zke,{onValueChange:e.onChange,value:e.value,disabled:o,children:[n.jsx(rAe,{children:n.jsx(Qke,{className:"bg-background",children:n.jsx(Yke,{placeholder:i})})}),n.jsx(abe,{children:r.map((e=>n.jsx(nbe,{value:e.value,children:n.jsxs("div",{className:"flex flex-col text-left",children:[n.jsx("span",{children:e.label}),e.description&&n.jsx("span",{className:"text-xs text-muted-foreground",children:e.description})]})},e.value)))})]}),n.jsx(oAe,{})]})}),BAe=({title:e,description:a,children:t,variant:i="default"})=>n.jsxs("div",{className:"highlighted"===i?"bg-muted/50 p-6 rounded-lg border border-muted space-y-4":"space-y-4",children:[e&&n.jsx("h3",{className:"text-lg font-medium text-foreground",children:e}),a&&n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a}),n.jsx("div",{className:"space-y-4",children:t})]}),RAe=({variant:e="default",onBack:a,onNext:t,onSkip:i,isSubmitting:r=!1,canGoBack:o=!0,canGoNext:s=!0,backLabel:l="Back",nextLabel:u="Next",skipLabel:c="Skip",className:d,mode:m})=>{const h="compact"===e?"sm":"default",p="default"===e?"text-sm":"";return n.jsxs("div",{className:mz("flex items-center","compact"===e?"gap-2":"justify-between gap-4",d),children:[a&&n.jsxs(f3,{variant:"outline",size:h,onClick:a,disabled:r||!o,className:mz("flex items-center gap-2",p),children:[n.jsx(pB,{className:"w-4 h-4"}),l]}),n.jsxs("div",{className:"flex items-center gap-4 ml-auto",children:[i&&n.jsx(f3,{variant:"outline",size:h,onClick:i,disabled:r,className:mz("flex items-center gap-2",p),children:c}),t&&n.jsx(f3,{size:h,onClick:t,disabled:r||!s,className:mz("flex items-center gap-2",p),children:n.jsxs(n.Fragment,r?{children:[n.jsx(RB,{className:"w-4 h-4 animate-spin"}),"Saving..."]}:{children:[u,"onboarding"===m&&n.jsx(oB,{className:"w-4 h-4"})]})})]})]})},zAe=a.forwardRef((({children:e,className:a,showNavigation:t=!0,mode:i="onboarding",...r},o)=>{const s="settings"!==i&&r.onBack;return n.jsxs("div",{ref:o,className:mz("h-full flex flex-col",a),children:[n.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-y-auto pt-10 @lg/onboarding-sidebar:pt-16",children:[n.jsx(PAe,{title:r.title,description:r.description}),n.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e})]}),t&&n.jsx("div",{className:"border-t border-border py-6 px-8 bg-background",children:n.jsx(RAe,{onBack:s?r.onBack:void 0,onNext:r.onNext,onSkip:r.onSkip,isSubmitting:r.isSubmitting,canGoBack:r.canGoBack,canGoNext:r.canGoNext,backLabel:r.backLabel||"Previous Step",nextLabel:r.submitLabel||"Next step",skipLabel:r.skipLabel||"Not now",mode:i})})]})}));zAe.displayName="WizardFormWrapper";const DAe=(e,a,n)=>{if(e&&"reportValidity"in e){const t=Obe(n,a);e.setCustomValidity(t&&t.message||""),e.reportValidity()}},OAe=(e,a)=>{for(const n in a.fields){const t=a.fields[n];t&&t.ref&&"reportValidity"in t.ref?DAe(t.ref,n,e):t.refs&&t.refs.forEach((a=>DAe(a,n,e)))}},KAe=(e,a)=>{a.shouldUseNativeValidation&&OAe(e,a);const n={};for(const t in e){const i=Obe(a.fields,t),r=Object.assign(e[t]||{},{ref:i&&i.ref});if(HAe(a.names||Object.keys(e),t)){const e=Object.assign({},Obe(n,t));Gbe(e,"root",r),Gbe(n,t,e)}else Gbe(n,t,r)}return n},HAe=(e,a)=>e.some((e=>e.startsWith(a+".")));var IAe=function(e,a){for(var n={};e.length;){var t=e[0],i=t.code,r=t.message,o=t.path.join(".");if(!n[o])if("unionErrors"in t){var s=t.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:r,type:i};if("unionErrors"in t&&t.unionErrors.forEach((function(a){return a.errors.forEach((function(a){return e.push(a)}))})),a){var l=n[o].types,u=l&&l[t.code];n[o]=pSe(o,a,n,i,u?[].concat(u,t.message):t.message)}e.shift()}return n},GAe=function(e,a,n){return void 0===n&&(n={}),function(t,i,r){try{return Promise.resolve(function(i,o){try{var s=Promise.resolve(e["sync"===n.mode?"parse":"parseAsync"](t,a)).then((function(e){return r.shouldUseNativeValidation&&OAe({},r),{errors:{},values:n.raw?t:e}}))}catch(jHe){return o(jHe)}return s&&s.then?s.then(void 0,o):s}(0,(function(e){if(a=e,Array.isArray(null==a?void 0:a.errors))return{values:{},errors:KAe(IAe(e.errors,!r.shouldUseNativeValidation&&"all"===r.criteriaMode),r)};var a;throw e})))}catch(jHe){return Promise.reject(jHe)}}};const FAe=[{code:"US",name:"United States"},{code:"AE",name:"United Arab Emirates"},{code:"AF",name:"Afghanistan"},{code:"AM",name:"Armenia"},{code:"AR",name:"Argentina"},{code:"AT",name:"Austria"},{code:"AU",name:"Australia"},{code:"AZ",name:"Azerbaijan"},{code:"BD",name:"Bangladesh"},{code:"BE",name:"Belgium"},{code:"BF",name:"Burkina Faso"},{code:"BG",name:"Bulgaria"},{code:"BH",name:"Bahrain"},{code:"BI",name:"Burundi"},{code:"BJ",name:"Benin"},{code:"BO",name:"Bolivia"},{code:"BR",name:"Brazil"},{code:"BT",name:"Bhutan"},{code:"BW",name:"Botswana"},{code:"BY",name:"Belarus"},{code:"CA",name:"Canada"},{code:"CD",name:"Democratic Republic of the Congo"},{code:"CF",name:"Central African Republic"},{code:"CG",name:"Republic of the Congo"},{code:"CH",name:"Switzerland"},{code:"CI",name:"Ivory Coast"},{code:"CL",name:"Chile"},{code:"CM",name:"Cameroon"},{code:"CN",name:"China"},{code:"CO",name:"Colombia"},{code:"CV",name:"Cape Verde"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DE",name:"Germany"},{code:"DJ",name:"Djibouti"},{code:"DK",name:"Denmark"},{code:"DZ",name:"Algeria"},{code:"EC",name:"Ecuador"},{code:"EE",name:"Estonia"},{code:"EG",name:"Egypt"},{code:"ER",name:"Eritrea"},{code:"ES",name:"Spain"},{code:"ET",name:"Ethiopia"},{code:"FI",name:"Finland"},{code:"FJ",name:"Fiji"},{code:"FK",name:"Falkland Islands"},{code:"FR",name:"France"},{code:"GA",name:"Gabon"},{code:"GB",name:"United Kingdom"},{code:"GE",name:"Georgia"},{code:"GF",name:"French Guiana"},{code:"GH",name:"Ghana"},{code:"GM",name:"Gambia"},{code:"GN",name:"Guinea"},{code:"GQ",name:"Equatorial Guinea"},{code:"GR",name:"Greece"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HK",name:"Hong Kong"},{code:"HR",name:"Croatia"},{code:"HU",name:"Hungary"},{code:"ID",name:"Indonesia"},{code:"IE",name:"Ireland"},{code:"IL",name:"Israel"},{code:"IN",name:"India"},{code:"IQ",name:"Iraq"},{code:"IR",name:"Iran"},{code:"IS",name:"Iceland"},{code:"IT",name:"Italy"},{code:"JO",name:"Jordan"},{code:"JP",name:"Japan"},{code:"KE",name:"Kenya"},{code:"KG",name:"Kyrgyzstan"},{code:"KM",name:"Comoros"},{code:"KR",name:"South Korea"},{code:"KW",name:"Kuwait"},{code:"KZ",name:"Kazakhstan"},{code:"LB",name:"Lebanon"},{code:"LK",name:"Sri Lanka"},{code:"LR",name:"Liberia"},{code:"LS",name:"Lesotho"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"LV",name:"Latvia"},{code:"LY",name:"Libya"},{code:"MA",name:"Morocco"},{code:"MD",name:"Moldova"},{code:"MG",name:"Madagascar"},{code:"ML",name:"Mali"},{code:"MO",name:"Macau"},{code:"MR",name:"Mauritania"},{code:"MT",name:"Malta"},{code:"MU",name:"Mauritius"},{code:"MV",name:"Maldives"},{code:"MW",name:"Malawi"},{code:"MX",name:"Mexico"},{code:"MY",name:"Malaysia"},{code:"MZ",name:"Mozambique"},{code:"NA",name:"Namibia"},{code:"NC",name:"New Caledonia"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NL",name:"Netherlands"},{code:"NO",name:"Norway"},{code:"NP",name:"Nepal"},{code:"NZ",name:"New Zealand"},{code:"OM",name:"Oman"},{code:"PE",name:"Peru"},{code:"PF",name:"French Polynesia"},{code:"PG",name:"Papua New Guinea"},{code:"PH",name:"Philippines"},{code:"PK",name:"Pakistan"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PY",name:"Paraguay"},{code:"QA",name:"Qatar"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"SA",name:"Saudi Arabia"},{code:"SC",name:"Seychelles"},{code:"SD",name:"Sudan"},{code:"SE",name:"Sweden"},{code:"SG",name:"Singapore"},{code:"SI",name:"Slovenia"},{code:"SK",name:"Slovakia"},{code:"SL",name:"Sierra Leone"},{code:"SN",name:"Senegal"},{code:"SO",name:"Somalia"},{code:"SR",name:"Suriname"},{code:"SS",name:"South Sudan"},{code:"ST",name:"São Tomé and Príncipe"},{code:"SY",name:"Syria"},{code:"SZ",name:"Eswatini"},{code:"TD",name:"Chad"},{code:"TG",name:"Togo"},{code:"TH",name:"Thailand"},{code:"TJ",name:"Tajikistan"},{code:"TM",name:"Turkmenistan"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TW",name:"Taiwan"},{code:"TZ",name:"Tanzania"},{code:"UA",name:"Ukraine"},{code:"UG",name:"Uganda"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"YE",name:"Yemen"},{code:"ZA",name:"South Africa"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}];var VAe=(e=>(e.BRAND="brand",e.BUSINESS="business",e.EMAIL="email",e.SMS="sms",e.MERGE_FIELDS="merge-fields",e.SPLASH="splash",e.BUSINESS_SKIP_INTERSTITIAL="business-skip-interstitial",e.SMS_INTERSTITIAL="sms-interstitial",e.COMPLETION="completion",e))(VAe||{});const JAe="Engage Settings",UAe="Configure your brand, business, and channel settings",WAe="Engage Setup",qAe="Set up your brand and channels for email and SMS marketing",ZAe="Brand Settings",$Ae="Business Information",YAe="Email Channel",QAe="SMS Channel",XAe="Merge Fields",ewe="Customize Your Brand",awe="Business Settings",nwe="Email Channel Settings",twe="Connect Your SMS",iwe="DBA legal name",rwe="ZIP Code",owe="ZIP code",swe="Select country",lwe="First Name",uwe="First name",cwe="Last Name",dwe="Last name",mwe="Email address",hwe="Contact Phone",pwe="Auto Parse",gwe={brand:{label:ZAe},business:{label:$Ae},email:{label:YAe},sms:{label:QAe},"merge-fields":{label:XAe}},fwe=[{key:"brand",label:gwe.brand.label},{key:"business",label:gwe.business.label},{key:"email",label:gwe.email.label},{key:"sms",label:gwe.sms.label},{key:"merge-fields",label:gwe["merge-fields"].label}],vwe=[{key:"brand",label:gwe.brand.label},{key:"email",label:gwe.email.label},{key:"business",label:gwe.business.label},{key:"sms",label:gwe.sms.label},{key:"merge-fields",label:gwe["merge-fields"].label},{key:"completion",label:"Completion"}],ywe=({control:e,disabled:a=!1,namePrefix:t="company",context:i="email"})=>{const r="email"===i,o=FAe.map((e=>({value:e.code,label:e.name})));return n.jsxs(n.Fragment,{children:[r&&n.jsx("div",{className:"rounded-lg border border-blue-100 bg-blue-50 p-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-blue-100",children:n.jsx(DB,{className:"w-4 h-4 text-blue-600"})})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h4",{className:"text-sm font-medium text-blue-900 mb-1",children:"Email Footer Information"}),n.jsx("p",{className:"text-sm text-blue-700",children:"Your business address will be included in email footers as required by law. This ensures compliance with email marketing regulations and provides recipients with your business contact information."})]})]})}),n.jsx(jAe,{control:e,name:`${t}.name`,label:iwe,placeholder:"Enter your DBA or legal business name",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.address1`,label:"Business Address",placeholder:"Street address",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.address2`,label:"Business Address Line 2",placeholder:"Apartment, suite, unit, etc. (optional)",disabled:a}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsx(jAe,{control:e,name:`${t}.city`,label:"City",placeholder:"City",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.stateProvince`,label:"State/Province",placeholder:"State/Province",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.zipCode`,label:rwe,placeholder:owe,disabled:a})]}),n.jsx(LAe,{control:e,name:`${t}.country`,label:"Country",placeholder:swe,options:o,disabled:a})]})},kwe=({control:e,disabled:a=!1,namePrefix:t="contact"})=>n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsx(jAe,{control:e,name:`${t}.firstName`,label:lwe,placeholder:uwe,disabled:a}),n.jsx(jAe,{control:e,name:`${t}.lastName`,label:cwe,placeholder:dwe,disabled:a})]}),n.jsx(jAe,{control:e,name:`${t}.email`,label:"Email",placeholder:mwe,type:"email",disabled:a}),n.jsx(jAe,{control:e,name:`${t}.phoneNumber`,label:hwe,placeholder:"+1234567890",description:"Must start with + and country code",type:"tel",disabled:a})]}),bwe=$re,Swe=a.forwardRef((({isSubmitting:e,onSubmit:t,hideSubmitButton:i=!1},r)=>{const o=YSe({resolver:GAe(bwe),defaultValues:{type:Wre.TWILIO_TOLL_FREE_NUMBER,tollFreeNumber:"",company:{name:"",address1:"",address2:"",city:"",stateProvince:"",zipCode:"",country:""},contact:{firstName:"",lastName:"",email:"",phoneNumber:""},messagingUseCase:{monthlyVolume:0,category:qre.PROMOTIONS_MARKETING,useCaseDetails:""},messageSamples:[""]},values:void 0}),s=o.watch("messageSamples");a.useImperativeHandle(r,(()=>({submit:()=>{o.handleSubmit(l)()}})));const l=async e=>{const a={...e,messagingUseCase:{...e.messagingUseCase,monthlyVolume:Number(e.messagingUseCase.monthlyVolume)}};await t(a)};return n.jsx("div",{className:"w-full max-w-4xl text-left",children:n.jsx(QSe,{...o,children:n.jsxs("form",{onSubmit:o.handleSubmit(l),className:"space-y-6",children:[n.jsx(BAe,{title:"Legal Business Settings",description:"Provide your legal business information required for SMS channel verification and future communications.",children:n.jsx(ywe,{control:o.control,disabled:e,context:"sms"})}),n.jsx(BAe,{title:"Contact Information",description:"Provide the contact information of the person authorized to represent your business.",children:n.jsx(kwe,{control:o.control,disabled:e})}),n.jsxs(BAe,{title:"Messaging Use Case",description:"Tell us about how you plan to use SMS messaging.",children:[n.jsx(jAe,{control:o.control,name:"messagingUseCase.monthlyVolume",label:"Expected Monthly Volume",placeholder:"1000",type:"number",disabled:e}),n.jsx(jAe,{control:o.control,name:"messagingUseCase.useCaseDetails",label:"Use Case Details",placeholder:"Describe your use case in detail",disabled:e})]}),n.jsxs(BAe,{title:"Message Samples",description:"Provide examples of messages you plan to send (up to 3 samples).",children:[n.jsx(Yq,{children:s.map(((a,t)=>n.jsxs(R2.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"relative",children:[n.jsx(jAe,{control:o.control,name:`messageSamples.${t}`,label:`Sample Message ${t+1}`,placeholder:"Enter a sample message",disabled:e}),s.length>1&&n.jsx(R2.button,{type:"button",onClick:()=>(e=>{if(s.length>1){const a=s.filter(((a,n)=>n!==e));o.setValue("messageSamples",a)}})(t),className:"absolute -right-2 -top-2 rounded-full bg-destructive/10 p-1 text-destructive hover:bg-destructive/20",whileHover:{scale:1.1},whileTap:{scale:.9},children:n.jsx(b3.CloseButton,{className:"h-4 w-4"})})]},t)))}),s.length<3&&n.jsxs(R2.button,{type:"button",onClick:()=>{s.length<3&&o.setValue("messageSamples",[...s,""])},className:"mt-4 flex items-center gap-2 rounded-lg border border-dashed border-border px-4 py-2 text-sm text-muted-foreground hover:border-border/80 hover:text-foreground",whileHover:{scale:1.02},whileTap:{scale:.98},children:[n.jsx(b3.PlusIcon,{className:"h-4 w-4"}),"Add another sample"]})]}),!i&&n.jsx("div",{className:"flex gap-3 pt-4 justify-end",children:n.jsx(f3,{type:"submit",disabled:e,children:e?"Submitting...":"Submit for approval"})})]})})})})),Awe=({onSubmit:e,onApplicationSubmit:t,hideSubmitButton:i=!1,formRef:r,onFormVisibilityChange:o})=>{const[s,l]=a.useState(!1),{data:u,isLoading:c}=yte(),{createSmsRegistrationApplication:d,isCreating:m}=kte();a.useEffect((()=>{o?.(s)}),[s,o]);if(!u||c)return n.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:n.jsx(Dq,{text:["Loading business information..."]})});const h={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}},p=u&&u.status===Yre.PENDING;return n.jsxs(R2.div,{initial:"hidden",animate:"visible",exit:"exit",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1],staggerChildren:.1}},exit:{opacity:0,y:-20,transition:{duration:.3,ease:[.4,0,1,1]}}},className:mz("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto","bg-background"),children:[n.jsx(R2.div,{variants:h,className:"w-16 h-16 rounded-xl flex items-center justify-center",children:n.jsx(b3.SmsIcon,{})}),n.jsx(R2.h2,{variants:h,className:"text-sm font-medium text-foreground",children:"Request your SMS sending number"}),n.jsxs(R2.div,{variants:h,className:"max-w-xl mx-auto",children:[n.jsx("p",{className:"text-sm font-normal text-muted-foreground mb-2",children:"Before you can send messages, we need to verify your business info with our SMS provider. Once approved, we'll assign you a phone number to send SMS campaigns."}),n.jsx("p",{className:"text-sm font-normal text-muted-foreground",children:"This usually takes 3-7 business days."})]}),n.jsx(Yq,{mode:"wait",children:s?n.jsx(R2.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3,ease:[.4,0,.2,1]},className:"w-full",children:n.jsx(Swe,{isSubmitting:m,onSubmit:async a=>{if(t)await t(a);else try{d({application:a,onSuccess:()=>{l(!1),e?.()}})}catch(n){}},hideSubmitButton:i,ref:r})},"form"):p?n.jsxs(R2.div,{variants:h,className:"flex items-center gap-2 px-3 py-1.5 bg-orange-50 border border-orange-200 rounded-full",children:[n.jsx(R2.div,{animate:{scale:[1,1.2,1],opacity:[1,.8,1]},transition:{duration:2,repeat:Number.POSITIVE_INFINITY,ease:"easeInOut"},className:"w-2 h-2 bg-orange-500 rounded-full"}),n.jsx("span",{className:"text-sm font-medium text-orange-800",children:"Pending approval"})]},"pending"):n.jsx(R2.div,{variants:h,children:n.jsx(f3,{variant:"outline",className:"bg-background",onClick:()=>l(!0),children:"Request approval"})},"button")})]})},wwe=e=>{const{companyName:a,smsBody:n}=e;return a&&n?`${a}:\n${n}`:n??""},Mwe="undefined"!=typeof window&&"undefined"!=typeof document;function Cwe(e){if(!e.startsWith("data:"))throw new Error('Invalid data URL: must start with "data:"');const a=e.split(",");if(2!==a.length)throw new Error("Invalid data URL format: missing base64 data");if(!a[0].includes(";base64"))throw new Error("Invalid data URL format: missing base64 encoding");return a[1]}const Twe=(e,a)=>{if(!e||!a)return[];return[...e.matchAll(/\{\{([^}]+)\}\}/g)].map((e=>{const n=e[1],t=a.mergeFields?.flatMap((e=>e.entries)).find((e=>e.value===`{{${n}}}`));return t?t.label:n})).filter(Boolean)},xwe=e=>{switch(e){case"default":default:return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200";case"subtle":return"inline-flex items-center font-medium mx-[1px] leading-none align-middle px-1 py-0.5 rounded-md bg-white/30 text-inherit shadow-[0_0_0_1px_rgba(0,0,0,0.05)]";case"minimal":return"inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-gray-50 text-gray-700 font-medium border border-gray-200";case"inline":return"inline-flex items-center px-1 py-0.5 rounded text-xs bg-gray-100 text-gray-800 font-medium";case"badge":return"inline-flex items-center px-2 py-1 rounded-full text-xs bg-indigo-100 text-indigo-800 font-medium border border-indigo-200"}},Nwe=({content:e,mergeFieldsResponse:t,variant:i="default",className:r="",asHtml:o=!0})=>{const s=a.useMemo((()=>t?.mergeFields?.flatMap((e=>e.entries))??[]),[t]),l=a.useMemo((()=>((e,a,n)=>e?e.replace(/\{\{.*?\}\}/g,(e=>{const t=a.find((a=>a.value===e));return t?`<span class="${xwe(n)}" data-merge-field="true" data-template-name="${t.value}" data-display-name="${t.label}">${t.label}</span>`:e})):"")(e,s,i)),[e,s,i]);if(!o){const a=e?.replace(/\{\{.*?\}\}/g,(e=>{const a=s.find((a=>a.value===e));return a?a.label:e}))||"";return n.jsx("span",{className:r,children:a})}return n.jsx("span",{className:r,dangerouslySetInnerHTML:{__html:l}})},Ewe=({body:e,imageUrls:t})=>{const i=d3(),{getMergeFields:r,isGetting:o}=la(i?.id??void 0),s=a.useCallback((e=>/\{\{[^}]+\}\}/.test(e)),[]);return o||void 0===r?null:n.jsx("div",{className:"sms-preview-outer @container",children:n.jsxs("div",{className:"sms-phone-mockup",children:[n.jsx("div",{className:"sms-phone-notch"}),n.jsxs("div",{className:"sms-phone-inner",children:[t&&t.length>0&&t.map(((e,a)=>n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:s(e)?n.jsx("div",{className:"sms-message-image-placeholder",children:n.jsxs("div",{className:"text-center text-white text-[10px] leading-tight",children:[n.jsx("div",{className:"font-medium mb-1",children:"Image will be populated at send time based on the following merge fields:"}),n.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:Twe(e,r).map(((e,a)=>n.jsx("span",{className:"inline-flex items-center px-1 py-0.5 rounded text-[10px] bg-green-500/30 text-white font-medium border border-green-400/40",children:e},a)))})]})}):n.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:n.jsx(Nwe,{content:e,mergeFieldsResponse:r,variant:"subtle",className:"text-white"})})})]}),n.jsx("div",{className:"sms-phone-home-indicator"})]})})};function _we(e){const a=r.useRef({value:e,previous:e});return r.useMemo((()=>(a.current.value!==e&&(a.current.previous=a.current.value,a.current.value=e),a.current.previous)),[e])}var Pwe="Checkbox",[jwe,Lwe]=H4(Pwe),[Bwe,Rwe]=jwe(Pwe),zwe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:t,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),f=vq(a,(e=>g(e))),v=r.useRef(!1),y=!p||(m||!!p.closest("form")),[k=!1,b]=F4({prop:o,defaultProp:s,onChange:d}),S=r.useRef(k);return r.useEffect((()=>{const e=p?.form;if(e){const a=()=>b(S.current);return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)}}),[p,b]),n.jsxs(Bwe,{scope:t,state:k,disabled:u,children:[n.jsx(Z4.button,{type:"button",role:"checkbox","aria-checked":Hwe(k)?"mixed":k,"aria-required":l,"data-state":Iwe(k),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:f,onKeyDown:K4(e.onKeyDown,(e=>{"Enter"===e.key&&e.preventDefault()})),onClick:K4(e.onClick,(e=>{b((e=>!!Hwe(e)||!e)),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())}))}),y&&n.jsx(Kwe,{control:p,bubbles:!v.current,name:i,value:c,checked:k,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"},defaultChecked:!Hwe(s)&&s})]})}));zwe.displayName=Pwe;var Dwe="CheckboxIndicator",Owe=r.forwardRef(((e,a)=>{const{__scopeCheckbox:t,forceMount:i,...r}=e,o=Rwe(Dwe,t);return n.jsx(T8,{present:i||Hwe(o.state)||!0===o.state,children:n.jsx(Z4.span,{"data-state":Iwe(o.state),"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{pointerEvents:"none",...e.style}})})}));Owe.displayName=Dwe;var Kwe=e=>{const{control:a,checked:t,bubbles:i=!0,defaultChecked:o,...s}=e,l=r.useRef(null),u=_we(t),c=n8(a);r.useEffect((()=>{const e=l.current,a=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(a,"checked").set;if(u!==t&&n){const a=new Event("click",{bubbles:i});e.indeterminate=Hwe(t),n.call(e,!Hwe(t)&&t),e.dispatchEvent(a)}}),[u,t,i]);const d=r.useRef(!Hwe(t)&&t);return n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??d.current,...s,tabIndex:-1,ref:l,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Hwe(e){return"indeterminate"===e}function Iwe(e){return Hwe(e)?"indeterminate":e?"checked":"unchecked"}var Gwe=zwe,Fwe=Owe;const Vwe=r.forwardRef((({className:e,...a},t)=>n.jsx(Gwe,{ref:t,className:mz("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...a,children:n.jsx(Fwe,{className:mz("flex items-center justify-center text-current"),children:n.jsx(mB,{className:"h-4 w-4"})})})));Vwe.displayName=Gwe.displayName;var Jwe=.999,Uwe=/[\\\/_+.#"@\[\(\{&]/,Wwe=/[\\\/_+.#"@\[\(\{&]/g,qwe=/[\s-]/,Zwe=/[\s-]/g;function $we(e,a,n,t,i,r,o){if(r===a.length)return i===e.length?1:.99;var s=`${i},${r}`;if(void 0!==o[s])return o[s];for(var l,u,c,d,m=t.charAt(r),h=n.indexOf(m,i),p=0;h>=0;)(l=$we(e,a,n,t,h+1,r+1,o))>p&&(h===i?l*=1:Uwe.test(e.charAt(h-1))?(l*=.8,(c=e.slice(i,h-1).match(Wwe))&&i>0&&(l*=Math.pow(Jwe,c.length))):qwe.test(e.charAt(h-1))?(l*=.9,(d=e.slice(i,h-1).match(Zwe))&&i>0&&(l*=Math.pow(Jwe,d.length))):(l*=.17,i>0&&(l*=Math.pow(Jwe,h-i))),e.charAt(h)!==a.charAt(r)&&(l*=.9999)),(l<.1&&n.charAt(h-1)===t.charAt(r+1)||t.charAt(r+1)===t.charAt(r)&&n.charAt(h-1)!==t.charAt(r))&&(.1*(u=$we(e,a,n,t,h+1,r+2,o))>l&&(l=.1*u)),l>p&&(p=l),h=n.indexOf(m,h+1);return o[s]=p,p}function Ywe(e){return e.toLowerCase().replace(Zwe," ")}function Qwe(e,a,n){return $we(e=n&&n.length>0?""+(e+" "+n.join(" ")):e,a,Ywe(e),Ywe(a),0,0,{})}var Xwe,eMe={exports:{}},aMe={};var nMe,tMe={};
84
84
  /**
85
85
  * @license React
86
86
  * use-sync-external-store-shim.development.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedreach/components",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",