(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[233],{10363:function(e,t,n){"use strict";n.d(t,{Z:function(){return gx}});var s,r,a,i,o,l,c,d,u,m,p,h,g,f,x=n(50029),b=n(59499),v=n(90116),y=n(17674),w=n(64687),j=n.n(w),A=n(4361),k=n(4298),N=n.n(k),C=n(28344),q=n(67294),I=n(31955),S=n(85893);function E(){return(0,S.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,S.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,S.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var O=n(19261),V="Something went wrong. Please try again.";function P(e){var t,n,s=e.onLoggedIn,r=e.defaultEmail,a=e.allowChangeEmail,i=void 0===a||a,o=e.customLabel,l=(0,q.useState)(null),c=l[0],d=l[1],u=(0,q.useState)(r),m=u[0],p=u[1],h=(0,q.useState)(!1),g=h[0],f=h[1],b=(0,q.useState)(""),v=b[0],y=b[1],w=(0,q.useState)(!1),k=w[0],N=w[1],C=(0,q.useRef)(null),P=(0,q.useRef)(null);(0,q.useEffect)(function(){p(r)},[r]),(0,q.useEffect)(function(){p(r),f(!1),y(""),d(null),setTimeout(function(){var e;null===(e=C.current)||void 0===e||e.focus()},300)},[]);var T=(t=(0,x.Z)(j().mark(function e(){var t;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,N(!0),d(""),e.next=5,fetch((0,O.wV)()+"/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:m})});case 5:if(!((t=e.sent).status>=400)){e.next=13;break}return e.next=9,t.json();case 9:return d(e.sent.userMessage||V),N(!1),e.abrupt("return");case 13:if(t.ok){e.next=17;break}return d(V),N(!1),e.abrupt("return");case 17:return e.next=19,t.json();case 19:e.sent,f(!0),setTimeout(function(){P.current.focus()},100),e.next=28;break;case 24:e.prev=24,e.t0=e.catch(0),console.error(e.t0),d(V);case 28:N(!1);case 29:case"end":return e.stop()}},e,null,[[0,24]])})),function(){return t.apply(this,arguments)}),M=(n=(0,x.Z)(j().mark(function e(){var t,n;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,N(!0),d(""),e.next=5,fetch((0,O.wV)()+"/api/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:m,code:v})});case 5:if(!((t=e.sent).status>=400)){e.next=13;break}return e.next=9,t.json();case 9:return d(e.sent.userMessage||V),N(!1),e.abrupt("return");case 13:if(t.ok){e.next=17;break}return d(V),N(!1),e.abrupt("return");case 17:return e.next=19,t.json();case 19:n=e.sent,I.Z.set("typingmindcloud_token",n.token,{expires:180,sameSite:"none",secure:!0}),null==s||s(),e.next=28;break;case 24:e.prev=24,e.t0=e.catch(0),console.error(e.t0),d(V);case 28:N(!1);case 29:case"end":return e.stop()}},e,null,[[0,24]])})),function(){return n.apply(this,arguments)});return(0,S.jsx)("div",{children:g?(0,S.jsxs)("div",{children:[(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"oVltH4"})}),(0,S.jsx)("div",{className:"font-semibold text-lg p-2 text-center bg-gray-100 my-2 rounded-md dark:bg-gray-700",children:m}),(0,S.jsx)("div",{className:"my-1 font-semibold",children:(0,S.jsx)(A.cC,{id:"B9mcRt"})}),(0,S.jsx)("input",{ref:P,type:"text",disabled:k,placeholder:"XXXXXX",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-zinc-700 text-xl text-center",value:v,onChange:function(e){return y(e.target.value)},onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),M())}})]}),c&&(0,S.jsx)("div",{className:"text-center text-red-500 text-sm font-semibold my-2",children:c}),(0,S.jsxs)("div",{className:"my-4 flex items-center justify-center gap-2",children:[(0,S.jsxs)("button",{onClick:M,disabled:k||!v,className:"flex items-center justify-center px-3 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors gap-2",children:[k?(0,S.jsx)(E,{}):null,(0,S.jsx)(A.cC,{id:"hQRttt"})]}),(0,S.jsx)("button",{onClick:function(){return f(!1)},disabled:k,className:"flex items-center justify-center px-3 py-2 border border-transparent text-sm font-medium rounded-md text-black bg-white-600 hover:bg-white-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-white-500 disabled:bg-gray-400 disabled:cursor-default transition-colors gap-2 disabled:text-white dark:text-white",children:(0,S.jsx)(A.cC,{id:"dEgA5A"})})]})]}):(0,S.jsxs)("div",{children:[(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsx)("div",{className:"my-1 font-semibold",children:o||(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"vUqMKV"})})}),(0,S.jsx)("input",{ref:C,type:"email",disabled:k||!i,placeholder:"example@gmail.com",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 disabled:text-gray-500",value:m,onChange:function(e){return p(e.target.value)},onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),T())}}),i?(0,S.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:(0,S.jsx)(A.cC,{id:"sJ6OIn"})}):null]}),c&&(0,S.jsx)("div",{className:"text-center text-red-500 text-sm font-semibold my-2",children:c}),(0,S.jsx)("div",{className:"my-4 flex items-center justify-center gap-2",children:(0,S.jsxs)("button",{onClick:T,disabled:k||!m,className:"flex items-center justify-center px-3 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors gap-2",children:[k?(0,S.jsx)(E,{}):null,(0,S.jsx)(A.cC,{id:"7xHXyX"})]})})]})})}var T=n(89555),M=n(22552),D=n(21227),B=n(27478);function L(e){var t,n=e.licensePayload,s=e.savedLicenseKey,r=e.onCloudSyncDone,a=e.onLocalOnlyModeConfirmed,i=[{id:"cloud",title:T.ag._({id:"Bp/aCq"}),description:T.ag._({id:"nd5PZx"}),recommended:!0,icon:function(){return(0,S.jsx)(C.H_w,{className:"h-6 w-6 text-blue-500"})}},{id:"local",title:T.ag._({id:"dTa89z"}),description:T.ag._({id:"cf3IX1"}),icon:function(){return(0,S.jsx)(M.R8I,{className:"h-6 w-6 text-red-500"})}}],o=(0,q.useState)(i[0]),l=o[0],c=o[1],d=(0,q.useState)(!1),u=d[0];d[1];var m=(0,q.useState)(!1),p=m[0],h=m[1];return(0,S.jsxs)("div",{children:[(0,S.jsxs)("fieldset",{children:[(0,S.jsx)("legend",{className:"text-lg font-bold text-center",children:(0,S.jsx)(A.cC,{id:"KrokRF"})}),(0,S.jsx)("legend",{className:"text-sm max-w-xs mx-auto text-gray-500 text-center",children:(0,S.jsx)(A.cC,{id:"cHR7zG"})}),(0,S.jsx)(D.Ee,{value:l,onChange:c,className:"mt-6 grid grid-cols-1 gap-y-6 sm:grid-cols-2 sm:gap-x-4",children:i.map(function(e){return(0,S.jsxs)(D.Y8,{value:e,"aria-label":e.title,"aria-description":"".concat(e.description),className:"group relative flex cursor-pointer rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 p-4 shadow-sm focus:outline-none data-[focus]:border-blue-600 data-[focus]:ring-2 data-[focus]:ring-blue-600",children:[(0,S.jsx)("span",{className:"flex flex-1",children:(0,S.jsxs)("span",{className:"flex flex-col",children:[(0,S.jsxs)("span",{className:" flex items-center justify-start gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.icon(),(0,S.jsx)("span",{children:e.title})]}),(0,S.jsx)("span",{className:"mt-1 flex items-center text-sm text-gray-500",children:e.description}),e.recommended?(0,S.jsxs)("span",{className:"text-xs font-semibold mt-1 text-blue-500",children:[(0,S.jsx)(A.cC,{id:"WEYdDv"})," ⋅ ",(0,S.jsx)(A.cC,{id:"GKWMv+"})]}):null]})}),(0,S.jsx)(B.Z,{"aria-hidden":"true",className:"h-5 w-5 text-blue-500 [.group:not([data-checked])_&]:invisible"}),(0,S.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute -inset-px rounded-lg border-2 border-transparent group-data-[focus]:border group-data-[checked]:border-blue-600"})]},e.id)})})]}),(null==l?void 0:l.id)==="cloud"?(0,S.jsxs)("div",{className:"p-4 ",children:[(0,S.jsx)("div",{className:"font-semibold my-2",children:(0,S.jsx)(A.cC,{id:"RK1xy9"})}),(0,S.jsxs)("ul",{className:"pl-4 list-disc space-y-2",children:[(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"6wedmD",components:{0:(0,S.jsx)("b",{})}})}),(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"oJ7rYu",components:{0:(0,S.jsx)("b",{})}})}),(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"JDdS6f",components:{0:(0,S.jsx)("b",{})}})})]}),(0,S.jsx)("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),(0,S.jsx)(P,{defaultEmail:null==n||null===(t=n.payload)||void 0===t?void 0:t.email,customLabel:T.ag._({id:"Xyoped"}),onLoggedIn:function(){r()}})]}):(null==l?void 0:l.id)==="local"?(0,S.jsxs)("div",{className:"p-4 ",children:[(0,S.jsx)("div",{className:"font-semibold my-2",children:(0,S.jsx)(A.cC,{id:"rXS98F"})}),(0,S.jsxs)("ul",{className:"pl-4 list-disc space-y-2",children:[(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"ib3/yS",components:{0:(0,S.jsx)("b",{})}})}),(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"G8VkJu",components:{0:(0,S.jsx)("b",{})}})}),(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"reZ4Yn",components:{0:(0,S.jsx)("b",{})}})}),(0,S.jsx)("li",{children:(0,S.jsx)(A.cC,{id:"REMo8V",components:{0:(0,S.jsx)("b",{className:"text-red-500"})}})})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)("div",{className:"my-2",children:(0,S.jsx)(A.cC,{id:"LFGDRf",components:{0:(0,S.jsx)("b",{}),1:(0,S.jsx)("b",{className:"text-red-500"})}})}),(0,S.jsx)("div",{className:"text-center text-lg font-bold bg-gray-100 p-2 rounded-md dark:bg-gray-700",onClick:function(){return navigator.clipboard.writeText(s)},children:s}),(0,S.jsx)("div",{className:"my-2",children:(0,S.jsx)(A.cC,{id:"d/uOLs",components:{0:(0,S.jsx)("b",{})}})})]}),(0,S.jsx)("div",{className:"my-4",children:(0,S.jsxs)("label",{className:"flex items-center justify-start gap-1 text-red-500",children:[(0,S.jsx)("input",{type:"checkbox",className:"mr-2",checked:p,onChange:function(e){h(e.target.checked)}}),(0,S.jsx)("span",{className:"text-sm",children:(0,S.jsx)(A.cC,{id:"5LtjYx"})})]})}),(0,S.jsx)("div",{className:"my-2 text-center",children:(0,S.jsxs)("button",{onClick:function(){return a()},type:"submit",className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 gap-2",disabled:!p,children:[u?(0,S.jsx)(E,{}):"→",(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"xGVfLh"})})]})})]}):(0,S.jsx)("div",{className:"p-4 text-center text-gray-500",children:(0,S.jsx)(A.cC,{id:"uvUq+/"})})]})}var R=(0,q.createContext)(),_=function(){return(0,q.useContext)(R)||{}};function Z(e){var t=e.value,n=e.children;return(0,S.jsx)(R.Provider,{value:t,children:n})}var K=n(24855),G=(0,K.eK)("useLicenseKey");function F(){var e,t=(0,q.useState)(!1),n=t[0],s=t[1],r=(0,q.useState)(!1),a=r[0],i=r[1],o=(0,q.useState)(!1),l=o[0],c=o[1],d=G(""),u=(0,y.Z)(d,2),m=u[0],p=u[1],h=(e=(0,x.Z)(j().mark(function e(){var t,n;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,i(!0),c(""),t="https://www.typingmind.com",e.next=6,(0,K.CQ)().get("INSTANCE_ID");case 6:return n=e.sent,e.next=9,fetch(t+"/api/unlink-license",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:m,instanceID:n})});case 9:return e.sent.ok,e.next=13,(0,K.CQ)().del("INSTANCE_ID");case 13:p(""),window.location.reload(),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(0),console.error(e.t0),c("Something went wrong. Please try again.");case 21:i(!1);case 22:case"end":return e.stop()}},e,null,[[0,17]])})),function(){return e.apply(this,arguments)});return m?(0,S.jsxs)("div",{className:"text-center",children:[(0,S.jsx)("div",{children:(0,S.jsx)("button",{onClick:function(){return s(!0)},className:"text-red-500 hover:underline text-sm font-semibold",children:(0,S.jsx)(A.cC,{id:"W2RH+r"})})}),n?(0,S.jsxs)("div",{children:[(0,S.jsx)("div",{className:"text-sm text-orange-500 my-2",children:(0,S.jsx)(A.cC,{id:"qZyW8X"})}),l&&(0,S.jsx)("div",{className:"text-red-500 my-2 font-semibold",children:l}),(0,S.jsx)("div",{children:(0,S.jsx)("button",{onClick:h,type:"submit",className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 disabled:bg-gray-400 gap-2",disabled:a,children:(0,S.jsx)(A.cC,{id:"Kb4R2a"})})}),(0,S.jsx)("div",{children:(0,S.jsx)("button",{onClick:function(){return s(!1)},className:"text-gray-500 hover:underline text-sm font-semibold p-4",children:(0,S.jsx)(A.cC,{id:"dEgA5A"})})})]}):null]}):null}var Y=n(79804),U=n(41257),H=n(48832),z=n(61193),W=n.n(z),Q=n(71501);function J(){for(var e=arguments.length,t=Array(e),n=0;n=500)){e.next=17;break}return e.next=13,t.text();case 13:return e.sent,V(D._({id:"0O2epA"})),k(!1),e.abrupt("return");case 17:if(!(t.status>=400)){e.next=32;break}return e.next=20,t.json();case 20:if(!(n=e.sent).deviceUnlinked){e.next=25;break}return V(D._({id:"XvQUAU"})),k(!1),e.abrupt("return");case 25:if(!n.limitReached){e.next=29;break}return V((0,S.jsxs)("div",{className:"text-left flex flex-col gap-2",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"cTdBYz"})}),(0,S.jsxs)("div",{children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"XNLbke",values:{0:n.activationLimit}})}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"gj6qzs",values:{0:n.activationUsage}})})]}),(0,S.jsx)("div",{className:"text-center",children:(0,S.jsx)("a",{href:"https://www.typingmind.com/license",target:"_blank",className:"font-semibold hover:underline p-2 rounded border-red-500 inline-block border",children:(0,S.jsx)(A.cC,{id:"lcFzRd"})})}),(0,S.jsxs)("div",{children:[(0,S.jsx)(A.cC,{id:"xDic64"})," "]}),(0,S.jsx)("div",{children:(0,S.jsx)("a",{className:"hover:underline",href:"https://www.typingmind.com/faqs",children:(0,S.jsx)(A.cC,{id:"vXqHoZ"})})})]})),k(!1),e.abrupt("return");case 29:return V(n.userMessage||D._(ee)),k(!1),e.abrupt("return");case 32:if(t.ok){e.next=36;break}return V(D._(ee)),k(!1),e.abrupt("return");case 36:return e.next=38,t.json();case 38:if(!(s=e.sent).instanceID){e.next=42;break}return e.next=42,(0,K.CQ)().set("INSTANCE_ID",s.instanceID);case 42:return e.next=44,i(f);case 44:h(f),null==c||c(),null==l||l(),e.next=53;break;case 49:e.prev=49,e.t0=e.catch(4),console.error(e.t0),V(D._(ee));case 53:k(!1);case 54:case"end":return e.stop()}},e,null,[[4,49]])})),function(){return t.apply(this,arguments)});return(0,S.jsxs)("div",{className:"max-w-lg",children:[(0,S.jsx)("p",{className:"my-2 text-sm",children:(0,S.jsx)(A.cC,{id:"5trAhQ",components:{0:(0,S.jsx)("b",{})}})}),a?(0,S.jsx)("div",{className:"text-sm font-semibold text-red-500",children:a.limitReached?(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"0EmptK",components:{0:(0,S.jsx)("br",{}),1:(0,S.jsx)("b",{})}})}):a.deviceUnlinked?(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"6QICdW"})}):a.userMessage?(0,S.jsx)("div",{children:a.userMessage}):null}):null,(0,S.jsx)("div",{className:"my-4 z-100 relative",children:T?(0,S.jsxs)("div",{className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 text-right flex items-center justify-end gap-4",children:[(0,S.jsxs)("span",{children:["**************************",p.slice(-4)]}),(0,S.jsx)("button",{onClick:function(){M(!1),b(""),setTimeout(function(){var e;null===(e=L.current)||void 0===e||e.focus()},100)},className:"text-blue-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"rZf6Qw"})})]}):(0,S.jsx)("input",{type:"text",ref:L,disabled:w,placeholder:D._({id:"j/jUA8"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",value:f,onChange:function(e){return b(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||f&&f.startsWith("sk-")||(e.preventDefault(),R())}})}),I&&(0,S.jsx)("div",{className:"my-2 text-sm text-red-500 text-center",children:I}),f&&f.startsWith("sk-")?(0,S.jsx)("p",{className:"my-2 text-sm text-red-500",children:(0,S.jsx)(A.cC,{id:"vVD6Dy"})}):null,T?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("p",{className:"my-2 text-sm",children:(0,S.jsx)(A.cC,{id:"gvy3rp",components:{0:(0,S.jsx)("button",{onClick:function(){null==d||d()},className:"text-blue-500 hover:underline"})}})}),(0,S.jsxs)("p",{className:"my-2 text-sm",children:[(0,S.jsx)(A.cC,{id:"4TQrIR"})," →"," ",(0,S.jsx)("a",{className:"text-blue-500 hover:underline",href:(null===(n=B.serverHostConfig)||void 0===n||null===(n=n.licenseServerConfig)||void 0===n?void 0:n.recoverLink)||"https://app.lemonsqueezy.com/my-orders/",target:"_blank",rel:"noopener noreferrer",children:(0,S.jsx)(A.cC,{id:"9kEKKZ"})})]}),(0,S.jsx)("div",{className:"my-4 text-center flex items-center justify-center space-x-2",children:(0,S.jsxs)("button",{disabled:w||!f||f&&f.startsWith("sk-"),onClick:R,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 space-x-1 disabled:bg-gray-500",children:[w?(0,S.jsx)(E,{}):(0,S.jsx)(Y.bzc,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"VzNizi"})})]})}),(0,S.jsx)("p",{className:"my-2 text-xs",children:(0,S.jsx)(A.cC,{id:"153KVj"})})]}),o?(0,S.jsx)("div",{className:"text-center",children:(0,S.jsx)(A.cC,{id:"2LLYJB",values:{0:(0,O.fm)((null==o||null===(s=o.payload)||void 0===s?void 0:s.plan)||"?")},components:{0:(0,S.jsx)("b",{className:"text-green-500"})}})}):null,(0,S.jsxs)("div",{className:"text-center mt-4",children:[(0,S.jsx)("div",{className:"my-2 text-center",children:(0,S.jsxs)("button",{onClick:function(){null==d||d()},className:"text-blue-500 hover:underline inline-flex items-center justify-center gap-2 font-semibold",children:[(0,S.jsx)(C.PcH,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"ldcOo7"})})]})}),(0,S.jsx)("div",{className:"my-2",children:(0,S.jsxs)("a",{target:"_blank",rel:"noopener noreferrer",href:(null===(r=B.serverHostConfig)||void 0===r||null===(r=r.licenseServerConfig)||void 0===r?void 0:r.manageLink)||"https://www.typingmind.com/license",className:"text-blue-500 hover:underline inline-flex items-center justify-center gap-2 font-semibold",children:[(0,S.jsx)(C.q2z,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"HjdyXC"})})]})}),(0,S.jsx)("div",{className:"mt-2",children:(0,S.jsx)(F,{})})]})]})}var en=n(81354),es=n.n(en);function er(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function ea(e){for(var t=1;t0,z=[].concat((0,v.Z)(G),(0,v.Z)(F)).filter(function(e){return e.isEncrypted}).length>0;return H?0===U?(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsxs)("div",{className:"text-sm font-semibold text-green-500 text-center",children:["\uD83D\uDD12 ",(0,S.jsx)(A.cC,{id:"uxcgu1"})]}),(0,S.jsx)("div",{className:"text-xs text-gray-500 text-center",children:(0,S.jsx)(A.cC,{id:"iK/LRS"})})]}):(0,S.jsxs)("div",{children:[z&&U>0?(0,S.jsx)("div",{className:"my-4 text-xs text-orange-500",children:(0,S.jsx)(A.cC,{id:"Ud2w4n",values:{unencryptedKeys:U}})}):null,z?null:(0,S.jsxs)("label",{className:"flex items-center justify-center gap-2",children:[(0,S.jsx)("input",{type:"checkbox",className:"form-checkbox h-5 w-5 text-blue-600",checked:N,onChange:function(e){return I(e.target.checked)}}),(0,S.jsxs)("span",{children:["\uD83D\uDD10 ",(0,S.jsx)(A.cC,{id:"6NbliF"})]})]}),N?(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsxs)("div",{className:"text-sm font-semibold my-1",children:[(0,S.jsx)(A.cC,{id:"JxXP1G"}),":"]}),(0,S.jsx)("div",{className:"text-xs text-gray-500 my-1",children:(0,S.jsx)(A.cC,{id:"OnFMha"})}),(0,S.jsx)("div",{children:(0,S.jsx)("input",{type:"password",placeholder:T.ag._({id:"f7sXvi"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",value:O,autoComplete:"off",onChange:function(e){return V(e.target.value)},onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),K())}})}),b?(0,S.jsx)("div",{className:"text-red-500 text-sm my-1",children:b}):null,(0,S.jsx)("div",{className:"my-2 text-center",children:(0,S.jsxs)("button",{onClick:K,disabled:!O,type:"submit",className:"inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 disabled:bg-gray-400 gap-2",children:[(0,S.jsx)(C.kUi,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"HD2Tiz"})})]})})]}):null]}):null}function eu(e){var t=e.size;return(0,S.jsx)("img",{src:"/assets/setapp-144x144.png",className:function(){for(var e=arguments.length,t=Array(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.type,s=t.onConfirmed,r=t.children,a=t.className,i=t.disabled,o=t.defaultText,l=t.confirmText,c=t.loading,d=(0,q.useState)(!1),u=d[0],m=d[1];return(0,q.useEffect)(function(){return function(){return clearTimeout(e)}},[]),(0,q.useEffect)(function(){return u&&(clearTimeout(e),e=setTimeout(function(){m(!1)},2e3)),function(){return clearTimeout(e)}},[u]),(0,S.jsxs)("button",{type:n,disabled:i,onClick:function(e){e.stopPropagation(),!i&&(u?s&&s():m(!0))},className:a,children:[u?(void 0===l?function(){return(0,S.jsx)("span",{"data-tooltip-id":"global","data-tooltip-content":T.ag._({id:"GdhD7H"}),className:"text-red-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"Aqw8Kb"})})}:l)({disabled:i}):r||(void 0===o?function(){return"Delete"}:o)({disabled:i}),c&&(0,S.jsx)(E,{})]})}var eE=n(27891),eO={id:"fWsBTs"};function eV(e){var t,n,s,r,a,i,o,l,c,d,u,m,p=e.subscription,h=(0,q.useState)(p),g=h[0],f=h[1],b=(0,q.useState)(!1),v=b[0],y=b[1],w=(0,q.useState)(null),k=w[0],N=w[1],C=(0,A.mV)().i18n,I=(t=(0,x.Z)(j().mark(function e(t){var n,s,r,a;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("cancel"!==t||window.confirm(C._({id:"/ns5IT"}))){e.next=3;break}return e.abrupt("return");case 3:return y(!0),N(""),e.prev=5,e.next=8,fetch("/api/cloud/subscriptions/"+p.id,{headers:{"Content-Type":"application/json"},method:"PUT",body:JSON.stringify({action:t})});case 8:if(!((s=e.sent).status>=400)){e.next=16;break}return e.next=12,s.json();case 12:return N(e.sent.userMessage||C._(eO)),y(!1),e.abrupt("return");case 16:if(s.ok){e.next=20;break}return N(C._(eO)),y(!1),e.abrupt("return");case 20:return e.next=22,s.json();case 22:f((r=e.sent).subscription),"update"===t&&null!=r&&null!==(n=r.subscription)&&void 0!==n&&null!==(n=n.data)&&void 0!==n&&null!==(n=n.attributes)&&void 0!==n&&null!==(n=n.urls)&&void 0!==n&&n.update_payment_method&&window.open(null==r||null===(a=r.subscription)||void 0===a||null===(a=a.data)||void 0===a||null===(a=a.attributes)||void 0===a||null===(a=a.urls)||void 0===a?void 0:a.update_payment_method,"_blank"),e.next=31;break;case 27:e.prev=27,e.t0=e.catch(5),N(C._(eO)),console.error(e.t0);case 31:y(!1);case 32:case"end":return e.stop()}},e,null,[[5,27]])})),function(e){return t.apply(this,arguments)});return(0,S.jsx)("div",{className:"flex items-center justify-between py-2",children:(0,S.jsx)("div",{className:"flex items-center",children:(0,S.jsxs)("details",{children:[(0,S.jsx)("summary",{children:(0,S.jsxs)("div",{className:"text-base font-medium inline-flex items-center justify-start gap-2 cursor-pointer",children:[(0,S.jsx)("span",{className:"hover:underline",children:eE.T.includes(null==g||null===(n=g.data)||void 0===n||null===(n=n.attributes)||void 0===n?void 0:n.variant_id)?"1GB Storage":eE.tW.includes(null==g||null===(s=g.data)||void 0===s||null===(s=s.attributes)||void 0===s?void 0:s.variant_id)?"5GB Storage":null==g||null===(r=g.data)||void 0===r||null===(r=r.attributes)||void 0===r?void 0:r.product_name}),(null==g||null===(a=g.data)||void 0===a||null===(a=a.attributes)||void 0===a?void 0:a.status)==="active"?(0,S.jsx)("div",{className:"text-xs text-white px-2 py-1 bg-green-500 rounded-md inline-block",children:(0,S.jsx)(A.cC,{id:"F6pfE9"})}):(null==g||null===(i=g.data)||void 0===i||null===(i=i.attributes)||void 0===i?void 0:i.status)==="cancelled"?(0,S.jsx)("div",{className:"text-xs text-white px-2 py-1 bg-red-500 rounded-md inline-block",children:(0,S.jsx)(A.cC,{id:"vv7kpg"})}):(0,S.jsx)("div",{className:"text-xs text-white px-2 py-1 bg-gray-500 rounded-md inline-block",children:null==g||null===(o=g.data)||void 0===o||null===(o=o.attributes)||void 0===o?void 0:o.status_formatted})]})}),(null==g||null===(l=g.data)||void 0===l||null===(l=l.attributes)||void 0===l?void 0:l.status)==="cancelled"?(0,S.jsxs)("div",{className:"text-xs text-gray-500 my-1",children:[(0,S.jsx)(A.cC,{id:"FP9FYD"}),":"," ",new Date(null==g||null===(c=g.data)||void 0===c||null===(c=c.attributes)||void 0===c?void 0:c.ends_at).toLocaleString()]}):null,(0,S.jsx)("div",{className:"flex items-center justify-start gap-2 my-2",children:(null==g||null===(d=g.data)||void 0===d||null===(d=d.attributes)||void 0===d?void 0:d.status)==="active"?(0,S.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[(0,S.jsx)("button",{onClick:function(){return I("update")},disabled:v,className:"px-4 py-2 bg-blue-500 rounded-md text-sm font-medium text-white hover:bg-blue-600 disabled:bg-gray-400 flex items-center justify-center gap-2",children:(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"XymtD/"})})}),(0,S.jsx)("button",{onClick:function(){return I("cancel")},disabled:v,className:"px-4 py-2 bg-red-500 rounded-md text-sm font-medium text-white hover:bg-red-600 disabled:bg-gray-400 flex items-center justify-center gap-2",children:(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"dEgA5A"})})})]}):(null==g||null===(u=g.data)||void 0===u||null===(u=u.attributes)||void 0===u?void 0:u.status)==="cancelled"&&new Date(null==g||null===(m=g.data)||void 0===m||null===(m=m.attributes)||void 0===m?void 0:m.ends_at)>new Date?(0,S.jsx)("div",{className:"flex items-center justify-start gap-2",children:(0,S.jsx)("button",{onClick:function(){return I("resume")},disabled:v,className:"px-4 py-2 bg-blue-500 rounded-md text-sm font-medium text-white hover:bg-blue-600 disabled:bg-gray-400 flex items-center justify-center gap-2",children:(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"v39wLo"})})})}):null}),v?(0,S.jsxs)("div",{className:"text-xs text-gray-500 my-1 flex items-center justify-start my-2 gap-2",children:[(0,S.jsx)(E,{}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"rYG2u6"})})]}):null,k&&(0,S.jsx)("div",{className:"text-center text-red-500 text-sm font-semibold my-2",children:k})]})})})}var eP=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function eT(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=e.getDate(),r=eP[e.getMonth()],a=e.getFullYear(),i=e.getHours(),o=e.getMinutes();return(o<10&&(o="0".concat(o)),t)?"".concat(t," at ").concat(i,":").concat(o):n?"".concat(s," ").concat(r," at ").concat(i,":").concat(o):"".concat(s," ").concat(r," ").concat(a,". at ").concat(i,":").concat(o)}function eM(e,t){if(!e)return null;var n=null==t?void 0:t.format,s="object"==typeof e?e:new Date(e),r=new Date,a=new Date(r-864e5),i=Math.round((r-s)/1e3),o=Math.round(i/60),l=Math.floor(o/60),c=Math.floor(l/24),d=Math.floor(c/7),u=Math.floor(d/52),m=r.toDateString()===s.toDateString(),p=a.toDateString()===s.toDateString(),h=r.getFullYear()===s.getFullYear();if("short"===n){if(i<=60)return"1m";if(o<60)return"".concat(o,"m");if(l<24)return"".concat(l,"h");if(c<7)return"".concat(c,"d");else if(c<14)return"1w";else if(c<21)return"".concat(d,"w");else if(d<52)return"".concat(d,"w");else if(u<2)return"1y";else return"".concat(u,"y")}if(i<5)return"now";if(i<60)return"".concat(i," seconds ago");if(i<90)return"about a minute ago";if(o<60)return"".concat(o," minutes ago");if(m)return eT(s,"Today");if(p)return eT(s,"Yesterday");if(h)return eT(s,!1,!0);return eT(s)}var eD=n(10245);function eB(e,t){var n=(0,q.useState)(e),s=n[0],r=n[1];return(0,q.useEffect)(function(){var n=setTimeout(function(){r(e)},t);return function(){clearTimeout(n)}},[e,t]),s}var eL=function(){var e=(0,q.useRef)(!0);return(0,q.useEffect)(function(){e.current=!1},[]),e.current};function eR(e,t){(0,q.useEffect)(function(){var n=function(n){!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),function(){document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}function e_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function eZ(e){for(var t=1;t=400)){e.next=30;break}return e.next=24,c.json();case 24:return N((h=e.sent).userMessage||(null===(p=h.error)||void 0===p?void 0:p.message)||tt),m(!1),g(URL.createObjectURL(t)),e.abrupt("return");case 30:if(c.ok){e.next=36;break}return N(tt),m(!1),g(URL.createObjectURL(t)),e.abrupt("return");case 36:return e.next=38,c.json();case 38:f=e.sent,s?s(f.text,r):(v(f.text),m(!1)),e.next=49;break;case 42:e.prev=42,e.t0=e.catch(5),console.error(e.t0),N(tt),m(!1),g(URL.createObjectURL(t));case 49:case"end":return e.stop()}},e,null,[[5,42]])}))).apply(this,arguments)}return(0,S.jsxs)("div",{className:"p-2 w-full flex items-center justify-center flex-col gap-4",children:[u||b?null:l?(0,S.jsxs)("div",{className:"text-gray-500 text-lg font-light p-4",children:[(0,S.jsxs)("div",{className:"text-center my-2 relative isolate p-1",children:[(0,S.jsx)("svg",{viewBox:"0 0 100 100",className:"w-full h-full absolute top-0 left-0 z-[-1] text-red-500",children:(0,S.jsx)("circle",{cx:50,cy:50,r:45,fill:"none",stroke:"currentColor",strokeWidth:5,strokeDashoffset:"282.6",transform:"rotate(-90 50 50)",children:(0,S.jsx)("animate",{attributeName:"stroke-dasharray",values:"0,282.6;282.6,0",dur:"120s",repeatCount:1})})}),(0,S.jsx)("div",{className:"rounded-full bg-gray-300 dark:bg-zinc-600 dark:hover:bg-zinc-500 p-6 inline-flex items-center justify-center transition-all hover:bg-gray-200 space-x-2",children:(0,S.jsx)(C.uYL,{className:"w-8 h-8 animate-listening"})})]}),(0,S.jsx)("div",{className:" animate-listening",children:(0,S.jsx)(A.cC,{id:"95r17U"})}),(0,S.jsx)(ts,{})]}):(0,S.jsx)("div",{className:"text-gray-500 text-sm p-4 text-center",children:(0,S.jsx)(A.cC,{id:"mWkeNy"})}),u?(0,S.jsxs)("div",{className:"text-gray-500 text-lg font-light p-4 flex items-center justify-center gap-2",children:[(0,S.jsx)(E,{}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"fp5rKh"})})]}):null,b?(0,S.jsx)("div",{className:"text-left py-2 px-4 bg-gray-100 rounded-md max-w-lg",children:b}):null,k?(0,S.jsx)("div",{className:"text-red-500 text-sm",children:k}):null,h&&(0,S.jsxs)("a",{href:h,download:!0,className:"text-blue-500 cursor-pointer hover:underline disabled:no-underline disabled:cursor-default flex items-center space-x-1",children:[(0,S.jsx)(M.uKn,{size:16}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"uOcnoU"})})]}),(0,S.jsx)("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("button",{className:"inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 disabled:bg-gray-400 gap-2",onClick:function(){U()},children:[(0,S.jsx)(C.u9M,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"JmZ/+d"})})]}),(0,S.jsxs)("button",{className:"inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 disabled:bg-gray-400 gap-2",onClick:r,children:[(0,S.jsx)(C.Xm5,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"dEgA5A"})})]})]}):u?null:(0,S.jsxs)("button",{className:"inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 gap-2",onClick:function(){v(""),g(null),Y()},children:[(0,S.jsx)(C.gbA,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:b||h?T.ag._({id:"GyaNUA"}):T.ag._({id:"w80YWM"})})]})}),!u&&!l&&(0,S.jsxs)("div",{children:[(0,S.jsx)(A.cC,{id:"mp5yqd",components:{0:(0,S.jsx)("button",{className:"text-blue-500 cursor-pointer hover:underline disabled:no-underline disabled:cursor-default",onClick:function(){var e;return null===(e=D.current)||void 0===e?void 0:e.click()},disabled:l||u})}}),(0,S.jsx)("input",{ref:D,type:"file",accept:".flac,.mp3,.mp4,.mpeg,.mpga,.m4a,.ogg,.wav,.webm",className:"hidden",onChange:function(e){N("");try{var t=e.target.files[0];H(t,null,{preventAutoSend:!0})}catch(e){console.error(e),N(tt)}}})]})]})}var ta=(0,K.eK)("useTranscribeService"),ti=(0,K.eK)("useVoiceAutoSend"),to=(0,K.eK)("useAutoStartRecord"),tl=(0,K.eK)("useWhisperPrompt");function tc(e){var t,n,s=e.openAIAPIKey,r=e.onTextAvailable,a=e.onCancel,i=e.showRecord,o=e.showTitle,l=ta("browser"),c=(0,y.Z)(l,2),d=c[0],u=c[1],m=ti(!1),p=(0,y.Z)(m,2),h=p[0],g=p[1],f=to(!1),x=(0,y.Z)(f,2),b=x[0],v=x[1],w=_(),j=(0,q.useState)(!1),k=j[0],N=j[1],C=tl(""),I=(0,y.Z)(C,2),E=I[0],V=I[1];return(0,q.useEffect)(function(){var e,t;"whisper"===d&&null!==(e=w.serverHostConfig)&&void 0!==e&&e.managed&&!(0,O.N7)("useOpenAIWhisper",null===(t=w.serverHostConfig)||void 0===t?void 0:t.chatFeatures)&&u("browser")},[]),(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsxs)("div",{children:[void 0===o||o?(0,S.jsx)("div",{className:"text-xl font-bold text-center mb-2",children:(0,S.jsx)(A.cC,{id:"JGrfzE"})}):null,(0,S.jsx)("div",{className:"text-sm font-semibold my-2",children:(0,S.jsx)(A.cC,{id:"MbTAbA"})}),(0,S.jsxs)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:d,onChange:function(e){return u(e.target.value)},children:[(0,S.jsx)("option",{value:"browser",children:(0,S.jsx)(A.cC,{id:"9kNmZU"})}),!(null!==(t=w.serverHostConfig)&&void 0!==t&&t.managed)||(0,O.N7)("useOpenAIWhisper",null===(n=w.serverHostConfig)||void 0===n?void 0:n.chatFeatures)?(0,S.jsx)("option",{value:"whisper",children:(0,S.jsx)(A.cC,{id:"I3d9HX"})}):null]})]}),"whisper"===d&&(0,S.jsx)("button",{className:"text-blue-500 ml-auto block",onClick:function(){return N(!k)},children:k?(0,S.jsx)(A.cC,{id:"9aHqty"}):(0,S.jsx)(A.cC,{id:"PUO6ed"})}),"whisper"===d&&k&&(0,S.jsxs)("div",{className:"space-y-2 pb-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"gxYlbr"})}),(0,S.jsx)("input",{type:"text",placeholder:T.ag._({id:"ZMHXQC"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",autoComplete:"off",value:E,onChange:function(e){return V(e.target.value)}}),(0,S.jsx)("p",{className:"text-xs text-gray-500",children:(0,S.jsx)(A.cC,{id:"+VVCL3",components:{0:(0,S.jsx)("a",{href:"https://platform.openai.com/docs/guides/speech-to-text/prompting",className:"text-blue-500 hover:underline",target:"_blank"})}})})]}),(0,S.jsxs)("div",{className:"my-4 flex items-start justify-center flex-col gap-2",children:[(0,S.jsx)(eJ,{enabled:b,setEnabled:v,label:T.ag._({id:"4ryaAZ"})}),(0,S.jsx)(eJ,{enabled:h,setEnabled:g,label:T.ag._({id:"bE4siw"})})]}),void 0===i||i?(0,S.jsx)(S.Fragment,{children:"whisper"===d?(0,S.jsx)(tr,{openAIAPIKey:s,onTextAvailable:r,startRecordOnMount:b,onCancel:a}):"browser"===d?(0,S.jsx)(e8,{onTextAvailable:r,startRecordOnMount:b,onCancel:a}):null}):null]})}var td=n(32832);function tu(e){var t=e.name,n=e.betaOnly;return(0,S.jsxs)("div",{className:"font-semibold text-red-500 rounded-md py-2 px-4 text-xs border border-red-500",children:[(0,S.jsx)(A.cC,{id:"Dyot+U",values:{0:t||T.ag._({id:"FHVG+T"}),1:void 0!==n&&n?T.ag._({id:"AeMmrL"}):""}}),"."," ",(0,S.jsx)("button",{onClick:function(){return document.getElementById("nav-buy-button").click()},className:"underline",children:(0,S.jsx)(A.cC,{id:"HPC6Gz"})}),"."]})}var tm=new(n(40272)).Z({concurrency:1}),tp={id:"fWsBTs"};function th(e){var t,n,s=e.onCancelled,r=e.fetchAudio,a=e.allowDownload,i=void 0===a||a,o=(0,q.useState)(!1),l=o[0],c=o[1],d=(0,q.useState)(null),u=d[0],m=d[1],p=(0,A.mV)().i18n,h=(0,q.useState)(!1),g=h[0],f=h[1],b=(0,q.useRef)(null),v=(0,q.useRef)(null);(0,q.useEffect)(function(){y()},[]);var y=(t=(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:var t;c(!0),v.current=!1,t=function(){if(!v.current)return c(!1),k()},tm.add(t,void 0);case 3:case"end":return e.stop()}},e)})),function(){return t.apply(this,arguments)}),w=(n=(0,x.Z)(j().mark(function e(){var t,n,s,a;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,f(!0),e.next=6,r();case 6:return t=e.sent,e.next=9,t.blob();case 9:n=e.sent,s=window.URL.createObjectURL(n),(a=document.createElement("a")).setAttribute("href",s),a.setAttribute("download","audio-".concat(Date.now(),".mp3")),document.body.appendChild(a),a.click(),a.remove(),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(2),console.error(e.t0);case 22:f(!1);case 23:case"end":return e.stop()}},e,null,[[2,19]])})),function(){return n.apply(this,arguments)}),k=function(){var e;return new Promise((e=(0,x.Z)(j().mark(function e(t,n){var s,a,i,o,l,c,d,u;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r();case 3:if((s=e.sent).ok){e.next=21;break}if(!s.errorMessage){e.next=9;break}m(s.errorMessage),e.next=19;break;case 9:return e.prev=9,e.next=12,s.json();case 12:i=e.sent,m(p._({id:"FzlEPS"})+" "+((null==i?void 0:i.userMessage)||(null==i||null===(a=i.detail)||void 0===a?void 0:a.message)||JSON.stringify(i))),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(9),m(p._(tp));case 19:return t(),e.abrupt("return");case 21:if(o="audio/mpeg",!(window.MediaSource&&MediaSource.isTypeSupported(o))){e.next=33;break}return l=s.body.getReader(),c=new MediaSource,b.current.src=URL.createObjectURL(c),b.current.addEventListener("ended",function(){t()}),b.current.addEventListener("pause",function(){t()}),c.addEventListener("sourceopen",function(){var e=c.addSourceBuffer(o);(function(){var t=(0,x.Z)(j().mark(function t(){var s,r,a;return j().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l.read();case 3:if(r=(s=t.sent).done,a=s.value,!r){t.next=9;break}return c.endOfStream(),t.abrupt("return");case 9:e.appendBuffer(a),e.addEventListener("updateend",n,{once:!0}),t.next=17;break;case 13:t.prev=13,t.t0=t.catch(0),m(p._(tp)+" "+t.t0.message),console.error("Error reading from stream:",t.t0);case 17:case"end":return t.stop()}},t,null,[[0,13]])}));function n(){return t.apply(this,arguments)}return n})()()}),e.next=31,b.current.play();case 31:case 43:e.next=53;break;case 33:return e.prev=33,e.next=36,s.blob();case 36:return d=e.sent,u=URL.createObjectURL(d),b.current.addEventListener("ended",function(){t()}),b.current.addEventListener("pause",function(){t()}),b.current.src=u,e.next=43,b.current.play();case 45:if(e.prev=45,e.t1=e.catch(33),!(e.t1 instanceof DOMException&&"NotAllowedError"===e.t1.name)){e.next=51;break}return m(p._({id:"UrPLkb"})),t(),e.abrupt("return");case 51:m(p._(tp)+" "+e.t1.message),t();case 53:e.next=59;break;case 55:e.prev=55,e.t2=e.catch(0),console.error(e.t2),t();case 59:case"end":return e.stop()}},e,null,[[0,55],[9,16],[33,45]])})),function(t,n){return e.apply(this,arguments)}))};return l?(0,S.jsxs)("div",{className:"text-xs font-semibold text-gray-500 flex items-center justify-center gap-2 p-2",children:[(0,S.jsx)(E,{}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"kWu0yk"})}),(0,S.jsx)("button",{onClick:s,className:"text-red-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"dEgA5A"})})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("audio",{ref:b,preload:"none",controls:!0}),i?g?(0,S.jsx)(E,{}):(0,S.jsx)("button",{onClick:w,children:(0,S.jsx)(C.aBF,{className:"w-4 h-4"})}):null,u?(0,S.jsx)("div",{className:"text-xs font-semibold text-red-500",children:u}):null]})}var tg=(0,K.eK)("useElevenStability"),tf=(0,K.eK)("useElevenClarity"),tx=(0,K.eK)("useElevenVoice"),tb=(0,K.eK)("useElevenAPIKey"),tv=(0,K.eK)("useElevenModelID");function ty(e){var t=e.content,n=e.onCancelled,s=e.speechSettings,r=e.orgElevenLabsAPIKey,a=tg(.75),i=(0,y.Z)(a,2),o=i[0];i[1];var l=tf(.75),c=(0,y.Z)(l,2),d=c[0];c[1];var u=tx("EXAVITQu4vr4xnSDxMaL"),m=(0,y.Z)(u,2),p=m[0];m[1];var h=tv("eleven_monolingual_v1"),g=(0,y.Z)(h,1)[0],f=tb(""),x=(0,y.Z)(f,2),b=x[0];x[1];var v=_(),w=v.serverHostConfig.chatFeatures;return(0,S.jsx)(th,{onCancelled:n,fetchAudio:function(){var e,n,a,i,l,c=null!==(e=null==s?void 0:s.elevenVoice)&&void 0!==e?e:p;return fetch(null!==(n=v.serverHostConfig)&&void 0!==n&&n.hasElevenLabsAPIKey&&!r?"/api/hosted/voice/elevenlabs?voiceID=".concat(c,"&stream=true"):"https://api.elevenlabs.io/v1/text-to-speech/".concat(c,"/stream"),{headers:{"Content-Type":"application/json","xi-api-key":r||b},method:"POST",body:JSON.stringify({text:t,model_id:null!==(a=null==s?void 0:s.elevenModelID)&&void 0!==a?a:g,voice_settings:{stability:Number(null!==(i=null==s?void 0:s.elevenStability)&&void 0!==i?i:o),similarity_boost:Number(null!==(l=null==s?void 0:s.elevenClarity)&&void 0!==l?l:d)}})})},allowDownload:(0,O.N7)("downloadTextToSpeech",w)})}var tw=(0,K.eK)("useBrowserVoice"),tj=(0,K.eK)("useBrowserVoiceRate"),tA=(0,K.eK)("useBrowserVoicePitch");function tk(e){var t,n=e.content,s=e.onStopped,r=e.speechSettings,a=tw(),i=(0,y.Z)(a,2),o=i[0];i[1];var l=tj(1),c=(0,y.Z)(l,2),d=c[0];c[1];var u=tA(1),m=(0,y.Z)(u,2),p=m[0];m[1];var h=(0,q.useState)({paused:!1,pending:!1,speaking:!1}),g=h[0],f=h[1],b=(0,q.useRef)(null),v=(0,q.useRef)(null);(0,q.useEffect)(function(){w()},[]),(0,q.useEffect)(function(){return k(),b.current=setInterval(function(){window.speechSynthesis.speaking||s(),k()},500),function(){clearInterval(b.current),window.speechSynthesis.cancel()}},[]);var w=(t=(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.abrupt("return",new Promise(function(e,t){v.current=new window.SpeechSynthesisUtterance,v.current.text=n;var s,a,i=null!==(s=null==r?void 0:r.browserVoiceRate)&&void 0!==s?s:d,l=null!==(a=null==r?void 0:r.browserVoicePitch)&&void 0!==a?a:p;v.current.volume=1,v.current.rate=i<.1?.1:i,v.current.pitch=l<.1?.1:l,v.current.voice=window.speechSynthesis.getVoices().filter(function(e){var t;return e.voiceURI===(null!==(t=null==r?void 0:r.browserVoice)&&void 0!==t?t:o)})[0],v.current.addEventListener("end",function(t){e()}),window.speechSynthesis.cancel(),window.speechSynthesis.speak(v.current)}));case 4:e.prev=4,e.t0=e.catch(0),console.error(e.t0);case 7:case"end":return e.stop()}},e,null,[[0,4]])})),function(){return t.apply(this,arguments)}),k=function(){f({paused:window.speechSynthesis.paused,pending:window.speechSynthesis.pending,speaking:window.speechSynthesis.speaking})};return(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[g.speaking&&!g.paused&&(0,S.jsxs)("button",{onClick:function(){window.speechSynthesis.pause(),k()},type:"submit",className:"px-4 py-2 rounded-full border border-gray-200 shadow-sm text-sm font-semibold text-gray-500 flex items-center justify-center gap-2 hover:text-black hover:shadow-md transition-all dark:bg-zinc-800 dark:border-zinc-600 dark:hover:text-white bg-white",children:[(0,S.jsx)(C.Wh,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"IgrLD/"})})]}),g.paused&&(0,S.jsxs)("button",{onClick:function(){window.speechSynthesis.resume(),k()},type:"submit",className:"px-4 py-2 rounded-full border border-gray-200 shadow-sm text-sm font-semibold text-gray-500 flex items-center justify-center gap-2 hover:text-black hover:shadow-md transition-all dark:bg-zinc-800 dark:border-zinc-600 dark:hover:text-white bg-white",children:[(0,S.jsx)(C.gmG,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"v39wLo"})})]}),g.speaking&&(0,S.jsxs)("button",{onClick:function(){window.speechSynthesis.cancel(),k()},type:"submit",className:"px-4 py-2 rounded-full border border-gray-200 shadow-sm text-sm font-semibold text-gray-500 flex items-center justify-center gap-2 hover:text-black hover:shadow-md transition-all dark:bg-zinc-800 dark:border-zinc-600 dark:hover:text-white bg-white",children:[(0,S.jsx)(C.JuG,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"ygCKqB"})})]})]})}var tN=(0,K.eK)("useOpenAISpeechVoice"),tC=(0,K.eK)("useOpenAISpeechModel"),tq=(0,K.eK)("useOpenAISpeechSpeed");function tI(e){var t=e.content,n=e.onCancelled,s=e.speechSettings,r=e.orgOpenAIAPIKey,a=tN(O.ZD[0]),i=(0,y.Z)(a,2),o=i[0];i[1];var l=tC("tts-1"),c=(0,y.Z)(l,2),d=c[0];c[1];var u=tq(1),m=(0,y.Z)(u,2),p=m[0];m[1];var h=_(),g=h.serverHostConfig.chatFeatures,f=null==h?void 0:h.decryptedApiKey;return(0,S.jsx)(th,{onCancelled:n,fetchAudio:function(){var e,n,a,i,l,c,u,m={model:null!==(e=null==s?void 0:s.openAISpeechModel)&&void 0!==e?e:d,input:t,voice:null!==(n=null==s?void 0:s.openAISpeechVoice)&&void 0!==n?n:o,speed:Number(null!==(a=null==s?void 0:s.openAISpeechSpeed)&&void 0!==a?a:p)};return null!==(i=h.serverHostConfig)&&void 0!==i&&i.managed&&null!==(l=h.serverHostConfig)&&void 0!==l&&l.hasOpenAIAPIKey&&(0,O.N7)("useOpenAITextToSpeech",null===(c=h.serverHostConfig)||void 0===c?void 0:c.chatFeatures)&&!(null!==(u=h.serverHostConfig)&&void 0!==u&&u.requireLicenseKey)?fetch("/api/hosted/voice/openai",{method:"POST",body:JSON.stringify(m)}):f||r?fetch("https://api.openai.com/v1/audio/speech",{method:"POST",headers:{Authorization:"Bearer ".concat(r||f),"Content-Type":"application/json"},body:JSON.stringify(m)}):{errorMessage:T.ag._({id:"BLqwK7"})}},allowDownload:(0,O.N7)("downloadTextToSpeech",g)})}var tS=function(e){if("string"!=typeof e)return e;var t=e.replace(/^#+\s(.*)/gm,"$1");return(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\*\*(.*)\*\*/g,"$1")).replace(/__(.*)__/g,"$1")).replace(/\*(.*?)\*/g,"$1")).replace(/_(.*?)_/g,"$1")).replace(/~~(.*?)~~/g,"$1")).replace(/^[ \t]*>+(\s>+)*\s?/gm,"")).replace(/^[ \t]*[*\-+]\s+/gm,"")).replace(/^[ \t]*(\d+)\.\s+/gm,"$1 ")).replace(/`(.+?)`/g,"$1")},tE=(0,K.eK)("useSpeechSource"),tO=(0,K.eK)("useElevenAPIKey"),tV=(0,K.eK)("useOpenAISpeechVoice"),tP=(0,K.eK)("useOpenAISpeechModel"),tT=(0,K.eK)("useOpenAISpeechSpeed"),tM=(0,K.eK)("useElevenStability"),tD=(0,K.eK)("useElevenClarity"),tB=(0,K.eK)("useElevenVoice"),tL=(0,K.eK)("useElevenModelID"),tR=(0,q.forwardRef)(function(e,t){var n,s,r=e.content,a=e.onSettingClick,i=e.playOnMount,o=e.speechSettings,l=e.orgElevenLabsAPIKey,c=e.orgOpenAIAPIKey,d=(0,q.useMemo)(function(){return tS(r)},[r]),u=tE("disabled"),m=(0,y.Z)(u,2),p=m[0];m[1];var h=(0,q.useState)(!1),g=h[0],f=h[1],b=(0,q.useState)(null),v=b[0],w=b[1],k=tO(""),N=(0,y.Z)(k,1)[0],I=tM(),E=(0,y.Z)(I,1)[0],O=tD(),V=(0,y.Z)(O,1)[0],P=tB(),M=(0,y.Z)(P,1)[0],D=tL(),B=(0,y.Z)(D,1)[0],L=tV(),R=(0,y.Z)(L,1)[0],Z=tP(),K=(0,y.Z)(Z,1)[0],G=tT(),F=(0,y.Z)(G,1)[0],Y=_(),U=null!==(s=null==o?void 0:o.speechSource)&&void 0!==s?s:p;(0,q.useEffect)(function(){i&&!g&&H(),"browser"===U&&window.speechSynthesis&&window.speechSynthesis.getVoices()},[]),(0,q.useEffect)(function(){f(!1)},[U,R,K,F,M,E,V,B,o]);var H=(n=(0,x.Z)(j().mark(function e(){var t;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(w(null),Y.userCanUse("textToSpeech")){e.next=4;break}return w((0,S.jsx)(tu,{name:"Text-to-Speech"})),e.abrupt("return");case 4:if(!(!U||"disabled"===U)){e.next=7;break}return a&&a(),e.abrupt("return");case 7:if(!("browser"===U&&!window.speechSynthesis)){e.next=10;break}return w(T.ag._({id:"Wzyks2"})),e.abrupt("return");case 10:if(!("elevenlabs"===U&&!N&&!(null!==(t=Y.serverHostConfig)&&void 0!==t&&t.hasElevenLabsAPIKey)&&!l)){e.next=13;break}return o?w(T.ag._({id:"u2ugP9"})):a&&a(),e.abrupt("return");case 13:f(!0);case 14:case"end":return e.stop()}},e)})),function(){return n.apply(this,arguments)});return(0,q.useImperativeHandle)(t,function(){return{play:H}}),(0,S.jsxs)("div",{className:" flex items-center justify-center sm:justify-start gap-2 flex-wrap w-full group",children:[g?null:(0,S.jsxs)("button",{"data-element-id":"in-message-play-button",onClick:H,type:"submit",className:"tts-play-button px-4 py-2 rounded-full border border-gray-200 shadow-sm text-sm font-semibold text-gray-500 flex items-center justify-center gap-2 hover:text-black hover:shadow-md transition-all dark:bg-zinc-800 dark:border-zinc-600 dark:hover:text-white bg-white",children:[(0,S.jsx)(C.gmG,{className:"w-4 h-4"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"T91vKp"})})]}),"browser"===U?g?(0,S.jsx)(tk,{content:d,onStopped:function(){f(!1)},playOnMount:!0,speechSettings:o}):null:"openai-text-to-speech"===U?g?(0,S.jsx)(tI,{content:d,onStopped:function(){f(!1)},speechSettings:o,orgOpenAIAPIKey:c}):null:g?(0,S.jsx)(ty,{content:d,onCancelled:function(){f(!1)},speechSettings:o,orgElevenLabsAPIKey:l}):null,v?(0,S.jsx)("div",{className:"text-red-500",children:v}):null,a?(0,S.jsx)("button",{onClick:a,className:"group-hover:inline-block sm:hidden font-semibold text-gray-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"Tz0i8g"})}):null]})}),t_=(0,K.eK)("useBrowserVoice"),tZ=(0,K.eK)("useBrowserVoiceRate"),tK=(0,K.eK)("useBrowserVoicePitch");function tG(e){var t,n,s,r,a,i=e.speechSettings,o=e.handleChangeSpeechSetting,l=(0,q.useState)(!1),c=l[0],d=l[1],u=(0,q.useState)([]),m=u[0],p=u[1],h=t_(),g=(0,y.Z)(h,2),f=g[0],x=g[1],b=tZ(1),v=(0,y.Z)(b,2),w=v[0],j=v[1],k=tK(1),N=(0,y.Z)(k,2),C=N[0],I=N[1];(0,q.useEffect)(function(){if("speechSynthesis"in window)return d(!0),E(),window.speechSynthesis&&window.speechSynthesis.addEventListener&&window.speechSynthesis.addEventListener("voiceschanged",E),function(){window.speechSynthesis&&window.speechSynthesis.removeEventListener&&window.speechSynthesis.removeEventListener("voiceschanged",E)}},[]);var E=function(){p(speechSynthesis.getVoices().map(function(e){return{voiceURI:e.voiceURI,name:e.name,lang:e.lang}}))};return c?(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsxs)("div",{className:" flex items-center justify-center gap-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"cKuv8v"})}),(0,S.jsx)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:null!==(t=null==i?void 0:i.browserVoice)&&void 0!==t?t:f,onChange:function(e){return o?o({browserVoice:e.target.value}):x(e.target.value)},children:m.map(function(e){return(0,S.jsxs)("option",{value:e.voiceURI,children:[e.name," (",e.lang,")"]},e.voiceURI)})})]}),(0,S.jsx)("div",{className:"text-xs",children:(0,S.jsx)(A.cC,{id:"CvvaRA"})})]}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsxs)("label",{className:"font-semibold shrink-0 flex items-center justify-between gap-2",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"TAocpQ",values:{0:null!==(n=null==i?void 0:i.browserVoiceRate)&&void 0!==n?n:w}})}),(0,S.jsx)("button",{onClick:function(){return o?o({browserVoiceRate:1}):j(1)},className:"text-blue-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"qRsPIT"})})]}),(0,S.jsxs)("div",{className:"w-full",children:[(0,S.jsx)("input",{type:"range",className:"transparent h-1.5 w-full cursor-pointer appearance-none rounded-lg border-transparent bg-neutral-200",min:0,max:2,step:.1,value:null!==(s=null==i?void 0:i.browserVoiceRate)&&void 0!==s?s:w,onChange:function(e){return o?o({browserVoiceRate:e.target.value}):j(e.target.value)}}),(0,S.jsxs)("div",{className:"text-gray-500 text-xs flex items-center justify-between",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"w625t8"})}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"qmIOJX"})})]})]})]}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsxs)("label",{className:"font-semibold shrink-0 flex items-center justify-between gap-2",children:[(0,S.jsx)(A.cC,{id:"PBh8Vb",values:{0:null!==(r=null==i?void 0:i.browserVoicePitch)&&void 0!==r?r:C}}),(0,S.jsx)("button",{onClick:function(){return o?o({browserVoicePitch:1}):I(1)},className:"text-blue-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"qRsPIT"})})]}),(0,S.jsxs)("div",{className:"w-full",children:[(0,S.jsx)("input",{type:"range",className:"transparent h-1.5 w-full cursor-pointer appearance-none rounded-lg border-transparent bg-neutral-200",min:0,max:2,step:.1,value:null!==(a=null==i?void 0:i.browserVoicePitch)&&void 0!==a?a:C,onChange:function(e){return o?o({browserVoicePitch:e.target.value}):I(e.target.value)}}),(0,S.jsxs)("div",{className:"text-gray-500 text-xs flex items-center justify-between",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"pdO539"})}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"bgYTxy"})})]})]})]})]}):(0,S.jsx)("div",{className:"text-gray-500 p-4 text-center text-red-500",children:(0,S.jsx)(A.cC,{id:"Wzyks2"})})}var tF=n(96486),tY=n.n(tF),tU=(0,K.eK)("useOpenAISpeechVoice"),tH=(0,K.eK)("useOpenAISpeechModel"),tz=(0,K.eK)("useOpenAISpeechSpeed");function tW(e){var t,n,s,r,a=e.showAdvanced,i=e.setShowAdvanced,o=e.speechSettings,l=e.handleChangeSpeechSetting,c=tU(),d=(0,y.Z)(c,2),u=d[0],m=d[1],p=tH(),h=(0,y.Z)(p,2),g=h[0],f=h[1],x=tz(1),b=(0,y.Z)(x,2),v=b[0],w=b[1];return(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsxs)("div",{className:" flex items-center justify-center gap-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"cKuv8v"})}),(0,S.jsx)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:null!==(t=null==o?void 0:o.openAISpeechVoice)&&void 0!==t?t:u,onChange:function(e){return l?l({openAISpeechVoice:e.target.value}):m(e.target.value)},children:O.ZD.map(function(e){return(0,S.jsx)("option",{value:e,className:"capitalize",children:(0,tF.capitalize)(e)},e)})}),a?(0,S.jsx)("button",{className:"text-blue-500 flex-shrink-0",onClick:function(){return i(!1)},children:(0,S.jsx)(A.cC,{id:"A+GCyx"})}):(0,S.jsx)("button",{className:"text-blue-500 flex-shrink-0",onClick:function(){return i(!0)},children:(0,S.jsx)(A.cC,{id:"NFIOKv"})})]}),a?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"hDkkvu"})}),(0,S.jsxs)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:null!==(n=null==o?void 0:o.openAISpeechModel)&&void 0!==n?n:g,onChange:function(e){return l?l({openAISpeechModel:e.target.value}):f(e.target.value)},children:[(0,S.jsx)("option",{value:"tts-1",children:"TTS"}),(0,S.jsx)("option",{value:"tts-1-hd",children:"TTS HD "})]})]}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsxs)("label",{className:"font-semibold shrink-0 flex items-center justify-between gap-2",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"UHgcpG",values:{0:null!==(s=null==o?void 0:o.openAISpeechSpeed)&&void 0!==s?s:v}})}),(0,S.jsx)("button",{onClick:function(){return l?l({openAISpeechSpeed:1}):w(1)},className:"text-blue-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"qRsPIT"})})]}),(0,S.jsxs)("div",{className:"w-full",children:[(0,S.jsx)("input",{type:"range",className:"transparent h-1.5 w-full cursor-pointer appearance-none rounded-lg border-transparent bg-neutral-200",min:.25,max:4,step:.05,value:null!==(r=null==o?void 0:o.openAISpeechSpeed)&&void 0!==r?r:v,onChange:function(e){return l?l({openAISpeechSpeed:e.target.value}):w(e.target.value)}}),(0,S.jsxs)("div",{className:"text-gray-500 text-xs flex items-center justify-between",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"w625t8"})}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"qmIOJX"})})]})]})]})]}):null]})}var tQ=JSON.parse('{"b":[{"voice_id":"21m00Tcm4TlvDq8ikWAM","name":"Rachel","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/21m00Tcm4TlvDq8ikWAM/6edb9076-c3e4-420c-b6ab-11d43fe341c8.mp3","available_for_tiers":[],"settings":null},{"voice_id":"AZnzlk1XvdvUeBnXmlld","name":"Domi","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/AZnzlk1XvdvUeBnXmlld/69c5373f-0dc2-4efd-9232-a0140182c0a9.mp3","available_for_tiers":[],"settings":null},{"voice_id":"EXAVITQu4vr4xnSDxMaL","name":"Sarah","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/EXAVITQu4vr4xnSDxMaL/04365bce-98cc-4e99-9f10-56b60680cda9.mp3","available_for_tiers":[],"settings":null},{"voice_id":"ErXwobaYiN019PkySvjV","name":"Antoni","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/ErXwobaYiN019PkySvjV/38d8f8f0-1122-4333-b323-0b87478d506a.mp3","available_for_tiers":[],"settings":null},{"voice_id":"MF3mGyEYCl7XYWbV9V6O","name":"Elli","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/MF3mGyEYCl7XYWbV9V6O/f9fd64c3-5d62-45cd-b0dc-ad722ee3284e.mp3","available_for_tiers":[],"settings":null},{"voice_id":"TxGEqnHWrfWFTfGW9XjX","name":"Josh","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/TxGEqnHWrfWFTfGW9XjX/c6c80dcd-5fe5-4a4c-a74c-b3fec4c62c67.mp3","available_for_tiers":[],"settings":null},{"voice_id":"VR6AewLTigWG4xSOukaG","name":"Arnold","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/VR6AewLTigWG4xSOukaG/66e83dc2-6543-4897-9283-e028ac5ae4aa.mp3","available_for_tiers":[],"settings":null},{"voice_id":"pNInz6obpgDQGcFmaJgB","name":"Adam","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/pNInz6obpgDQGcFmaJgB/e0b45450-78db-49b9-aaa4-d5358a6871bd.mp3","available_for_tiers":[],"settings":null},{"voice_id":"yoZ06aMxZJJ28mfd3POQ","name":"Sam","samples":null,"category":"premade","fine_tuning":{"model_id":null,"is_allowed_to_fine_tune":false,"fine_tuning_requested":false,"finetuning_state":"not_started","verification_attempts":null,"verification_failures":[],"verification_attempts_count":0,"slice_ids":null},"labels":{},"description":null,"preview_url":"https://storage.googleapis.com/eleven-public-prod/premade/voices/yoZ06aMxZJJ28mfd3POQ/1c4d417c-ba80-4de8-874a-a1c57987ea63.mp3","available_for_tiers":[],"settings":null}]}'),tJ=n(57632),tX={id:"fWsBTs"},t$=(0,K.eK)("useElevenStability"),t0=(0,K.eK)("useElevenClarity"),t1=(0,K.eK)("useElevenVoice"),t2=(0,K.eK)("useElevenAPIKey"),t4=(0,K.eK)("useElevenModelID"),t5=(0,K.eK)("useElevenCustomVoices");function t3(e){var t,n,s,r,a,i,o,l,c=e.showAdvanced,d=e.setShowAdvanced,u=e.speechSettings,m=e.handleChangeSpeechSetting,p=e.orgElevenLabsAPIKey,h=(0,A.mV)().i18n,g=(0,q.useState)(!1),f=g[0],b=g[1],w=(0,q.useState)(null),k=w[0],N=w[1],I=(0,q.useState)(null),E=I[0],O=I[1],V=t$(.75),P=(0,y.Z)(V,2),T=P[0],M=P[1],D=t0(.75),B=(0,y.Z)(D,2),L=B[0],R=B[1],Z=t1("EXAVITQu4vr4xnSDxMaL"),K=(0,y.Z)(Z,2),G=K[0],F=K[1],Y=t4("eleven_monolingual_v1"),U=(0,y.Z)(Y,2),H=U[0],z=U[1],W=t2(""),Q=(0,y.Z)(W,2),J=Q[0],X=Q[1],$=t5([]),ee=(0,y.Z)($,2),et=ee[0],en=ee[1],es=(0,q.useState)(tQ.b),er=es[0],ea=es[1],ei=eB(J,1e3),eo=_(),el=function(e){!u&&([].concat((0,v.Z)(e),(0,v.Z)(et)).map(function(e){return e.voice_id}).includes(G)||en(function(e){return[].concat((0,v.Z)(e),[{id:(0,tJ.Z)(),name:"",voice_id:G}])}))},ec=(t=(0,x.Z)(j().mark(function e(){var t,n,s,r;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(!J&&!(null!==(t=eo.serverHostConfig)&&void 0!==t&&t.hasElevenLabsAPIKey)&&!p)){e.next=4;break}return ea(tQ.b),e.abrupt("return");case 4:return e.next=6,fetch(null!==(n=eo.serverHostConfig)&&void 0!==n&&n.hasElevenLabsAPIKey?"/api/hosted/voice/voices":"https://api.elevenlabs.io/v1/voices",{headers:{"Content-Type":"application/json","xi-api-key":p||J},method:"GET"});case 6:return s=e.sent,e.next=9,s.json();case 9:null!=(r=e.sent)&&r.voices?(ea(r.voices),el(r.voices)):ea(tQ.b),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(0),ea(tQ.b),console.error(e.t0);case 17:case"end":return e.stop()}},e,null,[[0,13]])})),function(){return t.apply(this,arguments)});(0,q.useEffect)(function(){ec()},[ei]);var ed=(n=(0,x.Z)(j().mark(function e(){var t,n;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return b(!0),O(!1),N(""),e.prev=3,e.next=6,fetch("https://api.elevenlabs.io/v1/voices",{headers:{"Content-Type":"application/json","xi-api-key":J},method:"GET"});case 6:if(!((t=e.sent).status>=400)){e.next=14;break}return e.next=10,t.json();case 10:return N((n=e.sent).detail&&n.detail.message||h._(tX)),b(!1),e.abrupt("return");case 14:if(t.ok){e.next=18;break}return N(h._(tX)),b(!1),e.abrupt("return");case 18:O(!0),e.next=25;break;case 21:e.prev=21,e.t0=e.catch(3),N(h._(tX)),console.error(e.t0);case 25:b(!1);case 26:case"end":return e.stop()}},e,null,[[3,21]])})),function(){return n.apply(this,arguments)});return(0,S.jsxs)("div",{className:"space-y-4",children:[J||null!==(s=eo.serverHostConfig)&&void 0!==s&&s.hasElevenLabsAPIKey||u?null:(0,S.jsx)("div",{className:"text-xs text-red-500",children:(0,S.jsx)(A.cC,{id:"jF//iB"})}),!(null!==(r=eo.serverHostConfig)&&void 0!==r&&r.hasElevenLabsAPIKey)&&!u&&(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsxs)("label",{className:"font-semibold shrink-0",children:[(0,S.jsx)("span",{className:J?"":"text-red-500",children:(0,S.jsx)(A.cC,{id:"gJaAE1"})}),": (",(0,S.jsx)("a",{href:"https://beta.elevenlabs.io/",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:(0,S.jsx)(A.cC,{id:"JhXfkQ"})}),")"]}),(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,S.jsx)("input",{type:"password",disabled:f,placeholder:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",autoComplete:"off",value:J,onChange:function(e){return X(e.target.value)}}),(0,S.jsx)("button",{onClick:function(){return ed()},type:"submit",disabled:f,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 gap-2 flex-shrink-0",children:(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"hlKjs/"})})})]}),k?(0,S.jsx)("div",{className:"text-red-500 text-sm",children:k}):null,E?(0,S.jsx)("div",{className:"text-green-500 text-sm",children:(0,S.jsx)(A.cC,{id:"eDPfNj"})}):null,(0,S.jsx)("div",{className:"text-xs text-gray-500 my-4",children:(0,S.jsx)(A.cC,{id:"UIpYys"})})]}),(0,S.jsxs)("div",{className:" flex items-center justify-center gap-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"cKuv8v"})}),(0,S.jsx)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:null!==(a=null==u?void 0:u.elevenVoice)&&void 0!==a?a:G,onChange:function(e){return m?m({elevenVoice:e.target.value}):F(e.target.value)},children:(0,tF.uniqBy)([].concat((0,v.Z)(et),(0,v.Z)(er),[{voice_id:G}]),"voice_id").filter(function(e){return e.voice_id}).map(function(e){return(0,S.jsx)("option",{value:e.voice_id,children:e.name||h._({id:"8Tg/JR"})+" (".concat(e.voice_id,")")},e.voice_id)})}),c?(0,S.jsx)("button",{className:"text-blue-500 flex-shrink-0",onClick:function(){return d(!1)},children:(0,S.jsx)(A.cC,{id:"A+GCyx"})}):(0,S.jsx)("button",{className:"text-blue-500 flex-shrink-0",onClick:function(){return d(!0)},children:(0,S.jsx)(A.cC,{id:"NFIOKv"})})]}),c?(0,S.jsxs)(S.Fragment,{children:[!u&&(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"/xJLUo"})}),et.map(function(e,t){return(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,S.jsx)("input",{type:"text",placeholder:h._({id:"6YtxFj"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",autoComplete:"off",disabled:f,value:e.name,onChange:function(e){var n=(0,v.Z)(et);n[t].name=e.target.value,en(n)}}),(0,S.jsx)("input",{type:"text",placeholder:h._({id:"3BQnyB"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",autoComplete:"off",disabled:f,value:e.voice_id,onChange:function(e){var n=(0,v.Z)(et);n[t].voice_id=e.target.value,en(n)}}),(0,S.jsx)(eS,{className:"text-red-500 font-semibold min-w-[55px]",onConfirmed:function(){var e,n=(0,v.Z)(et);n.splice(t,1),en(n),G===et[t].voice_id&&F(null===(e=er[0])||void 0===e?void 0:e.voice_id)},children:(0,S.jsx)(A.cC,{id:"t/YqKh"})})]},e.id)}),(0,S.jsx)("div",{className:"flex items-center justify-start gap-2 mt-2",children:(0,S.jsxs)("button",{onClick:function(){en(function(e){return[].concat((0,v.Z)(e),[{id:(0,tJ.Z)(),name:"",voice_id:""}])})},className:"flex items-center justify-start gap-2 text-blue-500 font-semibold hover:underline",children:[(0,S.jsx)(C.wEH,{className:"w-4 h-4"})," ",(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"JRnw1i"})})]})})]}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"hDkkvu"})}),(0,S.jsxs)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:null!==(i=null==u?void 0:u.elevenModelID)&&void 0!==i?i:H,onChange:function(e){return m?m({elevenModelID:e.target.value}):z(e.target.value)},children:[(0,S.jsx)("option",{value:"eleven_monolingual_v1",children:"Eleven English v1"}),(0,S.jsx)("option",{value:"eleven_multilingual_v1",children:"Eleven Multilingual v1"}),(0,S.jsx)("option",{value:"eleven_multilingual_v2",children:"Eleven Multilingual v2"})]})]}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"CH0AaX"})}),(0,S.jsxs)("div",{className:"w-full",children:[(0,S.jsx)("input",{type:"range",className:"transparent h-1.5 w-full cursor-pointer appearance-none rounded-lg border-transparent bg-neutral-200",min:0,max:1,step:.05,value:null!==(o=null==u?void 0:u.elevenStability)&&void 0!==o?o:T,onChange:function(e){return m?m({elevenStability:e.target.value}):M(e.target.value)}}),(0,S.jsxs)("div",{className:"text-gray-500 text-xs flex items-center justify-between",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"SjsPQu"})}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"3xm05L"})})]})]}),(0,S.jsx)("div",{className:"text-gray-500 text-xs",children:(0,S.jsx)(A.cC,{id:"6sxUIo"})})]}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"SqIaK+"})}),(0,S.jsxs)("div",{className:"w-full",children:[(0,S.jsx)("input",{type:"range",className:"transparent h-1.5 w-full cursor-pointer appearance-none rounded-lg border-transparent bg-neutral-200",min:0,max:1,step:.05,value:null!==(l=null==u?void 0:u.elevenClarity)&&void 0!==l?l:L,onChange:function(e){return m?m({elevenClarity:e.target.value}):R(e.target.value)}}),(0,S.jsxs)("div",{className:"text-gray-500 text-xs flex items-center justify-between",children:[(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"nTWWCZ"})}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"yx/fMc"})})]})]}),(0,S.jsx)("div",{className:"text-gray-500 text-xs",children:(0,S.jsx)(A.cC,{id:"1RkbIp"})})]})]}):null]})}var t6=(0,K.eK)("useSpeechSource"),t7=(0,K.eK)("useAutoSpeech"),t8=(0,K.eK)("useShowPlayButton");function t9(e){var t=e.showOpenAI,n=void 0===t||t,s=t6("disabled"),r=(0,y.Z)(s,2),a=r[0],i=r[1],o=(0,q.useState)(!1),l=o[0],c=o[1],d=(0,q.useState)(T.ag._({id:"u3pv+W"})),u=d[0],m=d[1],p=t8(!0),h=(0,y.Z)(p,2),g=h[0],f=h[1],x=t7(!1),b=(0,y.Z)(x,2),v=b[0],w=b[1];return(0,q.useEffect)(function(){"openai-text-to-speech"!==a||n||i("disabled")},[]),(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"GPIMoy"})}),(0,S.jsxs)("select",{id:"model",className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:a,onChange:function(e){return i(e.target.value)},children:[(0,S.jsx)("option",{value:"elevenlabs",children:(0,S.jsx)(A.cC,{id:"9r6uEg"})}),n?(0,S.jsx)("option",{value:"openai-text-to-speech",children:(0,S.jsx)(A.cC,{id:"lKxYcA"})}):null,(0,S.jsx)("option",{value:"browser",children:(0,S.jsx)(A.cC,{id:"ZtCLxJ"})}),(0,S.jsx)("option",{value:"disabled",children:(0,S.jsx)(A.cC,{id:"E/QGRL"})})]})]}),(0,S.jsx)("h3",{className:"text-lg font-semibold",children:(0,S.jsx)(A.cC,{id:"M7vN5/"})}),"elevenlabs"===a?(0,S.jsx)(t3,{showAdvanced:l,setShowAdvanced:c}):"openai-text-to-speech"===a?(0,S.jsx)(tW,{showAdvanced:l,setShowAdvanced:c}):"browser"===a?(0,S.jsx)(tG,{}):(0,S.jsx)("div",{className:"space-y-4",children:(0,S.jsx)("div",{className:"text-center text-gray-500 text-orange-500",children:(0,S.jsx)(A.cC,{id:"M+BBlf"})})}),"disabled"===a?null:(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("label",{className:"font-semibold shrink-0",children:(0,S.jsx)(A.cC,{id:"oRX7OJ"})}),(0,S.jsx)("input",{type:"text",placeholder:T.ag._({id:"y8MW1k"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",autoComplete:"off",value:u,onChange:function(e){return m(e.target.value)}}),(0,S.jsx)(tR,{content:u})]}),(0,S.jsx)(eJ,{label:T.ag._({id:"2xLA9y"}),enabled:g,setEnabled:f}),(0,S.jsx)(eJ,{label:T.ag._({id:"rXlXlr"}),enabled:v,setEnabled:w})]})}var ne=n(13083),nt=(0,K.eK)("useThemeMode"),nn=function(){var e=nt("system"),t=(0,y.Z)(e,2),n=t[0],s=t[1],r=(0,q.useState)(window.matchMedia("(prefers-color-scheme: dark)").matches),a=r[0],i=r[1];return(0,q.useEffect)(function(){if("system"===n)try{var e=function(e){i(e.matches)},t=window.matchMedia("(prefers-color-scheme: dark)");if(null!=t&&t.addEventListener)return t.addEventListener("change",e),function(){t.removeEventListener("change",e)};return t.addListener(e),function(){t.removeListener(e)}}catch(e){console.error("Error on listening dark mode change event",e),ne.Tb(e)}},[n]),{isDarkMode:"system"===n?a:"dark"===n,setThemeMode:s,themeMode:n}},ns=(0,K.eK)("useSidebarColorHue"),nr=(0,K.eK)("useCompactSidebarLine"),na=(0,K.eK)("useFontSize"),ni=(0,K.eK)("useSidebarWidth");function no(e){var t=e.showSidebarColor,n=e.onClickChangeSidebarColor,s=nn(),r=s.themeMode,a=s.setThemeMode,i=ns(O.V$),o=(0,y.Z)(i,2),l=o[0];o[1];var c=nr(!1),d=(0,y.Z)(c,2),u=d[0],m=d[1],p=na("small"),h=(0,y.Z)(p,2),g=h[0],f=h[1],x=ni(""),b=(0,y.Z)(x,2);return b[0],b[1],(0,S.jsx)("div",{children:(0,S.jsxs)("div",{className:"grid grid-cols-2 items-center justify-start gap-2",children:[(0,S.jsx)("div",{className:"text-sm font-semibold",children:(0,S.jsx)(A.cC,{id:"FEr96N"})}),(0,S.jsxs)("select",{className:"block w-fit rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:r,onChange:function(e){a(e.target.value)},children:[(0,S.jsx)("option",{value:"light",children:(0,S.jsx)(A.cC,{id:"1njn7W"})}),(0,S.jsx)("option",{value:"dark",children:(0,S.jsx)(A.cC,{id:"pvnfJD"})}),(0,S.jsx)("option",{value:"system",children:(0,S.jsx)(A.cC,{id:"D+NlUC"})})]}),void 0===t||t?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("div",{className:"text-sm font-semibold ",children:(0,S.jsx)(A.cC,{id:"ebEv56"})}),(0,S.jsx)("div",{children:(0,S.jsx)("button",{onClick:function(){n()},style:{backgroundColor:(0,O.dl)(l)},className:"w-20 h-8 block w-fit rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6"})})]}):null,(0,S.jsx)("div",{className:"text-sm font-semibold ",children:(0,S.jsx)(A.cC,{id:"tbgdI4"})}),(0,S.jsxs)("select",{className:"block w-fit rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:u?"1":"",onChange:function(e){m("1"===e.target.value)},children:[(0,S.jsx)("option",{value:"",children:(0,S.jsx)(A.cC,{id:"ovBPCi"})}),(0,S.jsx)("option",{value:"1",children:(0,S.jsx)(A.cC,{id:"9S4Fiy"})})]}),(0,S.jsx)("div",{className:"text-sm font-semibold ",children:(0,S.jsx)(A.cC,{id:"cGeFup"})}),(0,S.jsxs)("select",{className:"block w-fit rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:g,onChange:function(e){f(e.target.value.toLowerCase())},children:[(0,S.jsx)("option",{value:"small",children:(0,S.jsx)(A.cC,{id:"4Revpc"})}),(0,S.jsx)("option",{value:"medium",children:(0,S.jsx)(A.cC,{id:"agPptk"})}),(0,S.jsx)("option",{value:"large",children:(0,S.jsx)(A.cC,{id:"k7rCa/"})}),(0,S.jsx)("option",{value:"extra",children:(0,S.jsx)(A.cC,{id:"vp6Yr4"})}),(0,S.jsx)("option",{value:"2extra",children:(0,S.jsx)(A.cC,{id:"tIa0nY"})})]})]})})}var nl=(0,K.eK)("useStreaming"),nc=(0,K.eK)("useAutomaticTitle"),nd=(0,K.eK)("useSuggestKeywords"),nu=(0,K.eK)("useSearchEngine"),nm=(0,K.eK)("useSoundMode"),np=(0,K.eK)("useReopenPreviousChat"),nh=(0,K.eK)("useAutoArchiveOldChats"),ng=(0,K.eK)("useAutoDeleteArchivedChats");function nf(e){var t=e.showSuggestKeywords,n=nl(!0),s=(0,y.Z)(n,2),r=s[0],a=s[1],i=nc(!0),o=(0,y.Z)(i,2),l=o[0],c=o[1],d=nd(!0),u=(0,y.Z)(d,2),m=u[0],p=u[1],h=nu("google"),g=(0,y.Z)(h,2),f=g[0],x=g[1],b=nm(!0),v=(0,y.Z)(b,2),w=v[0],j=v[1],k=np(!1),N=(0,y.Z)(k,2),C=N[0],I=N[1],E=nh(""),O=(0,y.Z)(E,2),V=O[0],P=O[1],M=ng(""),D=(0,y.Z)(M,2),B=D[0],L=D[1],R=(0,q.useMemo)(function(){return!["google","ddg","bing","brave"].includes(f)},[f]);return(0,S.jsx)("div",{children:(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsx)(eJ,{label:T.ag._({id:"3mDv0d"}),description:T.ag._({id:"bW1s55"}),enabled:r,setEnabled:function(e){a(e)}}),(0,S.jsx)(eJ,{label:T.ag._({id:"2Pa8mz"}),description:T.ag._({id:"BrM1bb"}),enabled:l,setEnabled:function(e){c(e)}}),(void 0===t||t)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(eJ,{label:T.ag._({id:"ZK5+g/"}),description:T.ag._({id:"LqNfc3"}),enabled:m,setEnabled:function(e){p(e)}}),m?(0,S.jsx)("div",{className:"flex justify-center",children:(0,S.jsxs)("div",{className:"flex flex-col",children:[(0,S.jsxs)("div",{className:"grid grid-cols-2 items-center justify-center gap-2",children:[(0,S.jsx)("div",{className:"text-sm text-right",children:(0,S.jsx)(A.cC,{id:"xEEOHj"})}),(0,S.jsxs)("select",{className:"block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:R?"":f,onChange:function(e){x(e.target.value.toLowerCase())},children:[(0,S.jsx)("option",{value:"google",children:"Google"}),(0,S.jsx)("option",{value:"ddg",children:"DuckDuckGo"}),(0,S.jsx)("option",{value:"bing",children:"Bing"}),(0,S.jsx)("option",{value:"brave",children:"Brave"}),(0,S.jsx)("option",{value:"",children:"Kagi"})]})]}),R&&(0,S.jsxs)("div",{className:"mt-2 w-full",children:[(0,S.jsx)("div",{className:"text-sm",children:(0,S.jsx)(A.cC,{id:"aABkGI"})}),(0,S.jsx)("a",{href:"https://kagi.com/settings?p=user_details",target:"_blank",rel:"noopenner noreferer",className:"mt-1 text-blue-500 hover:underline text-xs",children:(0,S.jsx)(A.cC,{id:"zCNvh1"})}),(0,S.jsx)("input",{type:"text",className:"mt-2 block w-full rounded-md border-0 py-1.5 px-3 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:f,onChange:function(e){x(e.target.value.toLowerCase())}})]})]})}):null]}),(0,S.jsx)(eJ,{label:T.ag._({id:"Sb94+G"}),description:T.ag._({id:"47jGM/"}),enabled:w,setEnabled:function(e){j(e)}}),(0,S.jsx)(eJ,{label:T.ag._({id:"yjKqG9"}),description:T.ag._({id:"NL1iX0"}),enabled:C,setEnabled:function(e){I(e)}}),(0,S.jsx)(eJ,{label:T.ag._({id:"Tppod2"}),description:T.ag._({id:"4iqlgG"}),enabled:!!V,setEnabled:function(e){P(e?24:"")}}),V?(0,S.jsxs)("div",{className:"grid grid-cols-2 items-center justify-center gap-2",children:[(0,S.jsx)("div",{className:"text-sm text-right",children:(0,S.jsx)(A.cC,{id:"WAOQ5J"})}),(0,S.jsxs)("select",{className:"block w-fit rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:V,onChange:function(e){P(Number(e.target.value))},children:[(0,S.jsx)("option",{value:24,children:(0,S.jsx)(A.cC,{id:"VaA9mu"})}),(0,S.jsx)("option",{value:48,children:(0,S.jsx)(A.cC,{id:"UtXEjp"})}),(0,S.jsx)("option",{value:72,children:(0,S.jsx)(A.cC,{id:"7ZrpGs"})}),(0,S.jsx)("option",{value:168,children:(0,S.jsx)(A.cC,{id:"3vtzIH"})}),(0,S.jsx)("option",{value:336,children:(0,S.jsx)(A.cC,{id:"O2B4EJ"})}),(0,S.jsx)("option",{value:504,children:(0,S.jsx)(A.cC,{id:"B/1Qzd"})}),(0,S.jsx)("option",{value:720,children:(0,S.jsx)(A.cC,{id:"voMgY+"})}),(0,S.jsx)("option",{value:1440,children:(0,S.jsx)(A.cC,{id:"HCLj1r"})}),(0,S.jsx)("option",{value:2160,children:(0,S.jsx)(A.cC,{id:"x1VeBD"})})]})]}):null,(0,S.jsx)(eJ,{label:T.ag._({id:"+ZWSxY"}),description:T.ag._({id:"OSt5XJ"}),enabled:!!B,setEnabled:function(e){L(e?24:"")}}),B?(0,S.jsxs)("div",{className:"grid grid-cols-2 items-center justify-center gap-2",children:[(0,S.jsx)("div",{className:"text-sm text-right",children:(0,S.jsx)(A.cC,{id:"be4IUs"})}),(0,S.jsxs)("select",{className:"block w-fit rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-zinc-700 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6",value:B,onChange:function(e){L(Number(e.target.value))},children:[(0,S.jsx)("option",{value:24,children:(0,S.jsx)(A.cC,{id:"VaA9mu"})}),(0,S.jsx)("option",{value:48,children:(0,S.jsx)(A.cC,{id:"UtXEjp"})}),(0,S.jsx)("option",{value:72,children:(0,S.jsx)(A.cC,{id:"7ZrpGs"})}),(0,S.jsx)("option",{value:168,children:(0,S.jsx)(A.cC,{id:"3vtzIH"})}),(0,S.jsx)("option",{value:336,children:(0,S.jsx)(A.cC,{id:"O2B4EJ"})}),(0,S.jsx)("option",{value:504,children:(0,S.jsx)(A.cC,{id:"B/1Qzd"})}),(0,S.jsx)("option",{value:720,children:(0,S.jsx)(A.cC,{id:"voMgY+"})}),(0,S.jsx)("option",{value:1440,children:(0,S.jsx)(A.cC,{id:"HCLj1r"})}),(0,S.jsx)("option",{value:2160,children:(0,S.jsx)(A.cC,{id:"x1VeBD"})})]})]}):null]})})}var nx=n(11259),nb=n(57161),nv=n(95346);function ny(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function nw(e){for(var t=1;t0?"mt-4":""),children:e.label},e.label):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("button",{className:(0,O.AK)("w-full p-2 rounded-md transition-colors hover:bg-gray-100 text-left cursor-default flex items-center justify-start gap-2 my-1 dark:text-gray-200 dark:hover:bg-gray-800",e.label===a.label?"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200":"text-gray-800 ",l?"bg-gray-100 dark:bg-gray-800 dark:text-gray-200":""),onClick:function(){l?m(function(t){return nw(nw({},t),{},(0,b.Z)({},e.label,!t[e.label]))}):i(e)},children:[e.icon?(0,S.jsx)(e.icon,{className:"w-4 h-4"}):null,(0,S.jsx)("span",{children:e.label}),l?u[e.label]?(0,S.jsx)(nv.jX5,{className:"w-5 h-5 -ml-2"}):(0,S.jsx)(nv.h2L,{className:"w-5 h-5 -ml-2"}):null]},e.label),l&&u[e.label]?(0,S.jsx)("div",{className:"w-full p-2 mb-4",children:null===(n=e.renderSection)||void 0===n?void 0:n.call(e)}):null]})})}),l?null:(0,S.jsxs)("div",{className:"w-full",children:[(0,S.jsx)("h3",{className:"text-xl font-bold mb-2",children:null==a?void 0:a.label}),(0,S.jsx)("div",{children:null==a||null===(t=a.renderSection)||void 0===t?void 0:t.call(a)})]})]})}var nA=n(59557),nk=(0,K.eK)("useExtensionURLs");function nN(){var e=nk([]),t=(0,y.Z)(e,2),n=t[0],s=t[1],r=(0,q.useState)(""),a=r[0],i=r[1],o=(0,q.useState)(""),l=o[0],c=o[1],d=(0,q.useState)(!1),u=d[0],m=d[1],p=(0,q.useState)(!1),h=p[0],g=p[1];return(0,S.jsxs)("div",{className:"",children:[(0,S.jsxs)("div",{className:"text-xs",children:[(0,S.jsx)(A.cC,{id:"K8lalb"}),(0,S.jsx)("a",{href:"https://docs.typingmind.com/typing-mind-extensions",className:"text-blue-500 font-semibold text-blue-500 text-xs hover:underline ml-1",target:"_blank",rel:"noreferrer noopener",children:(0,S.jsx)(A.cC,{id:"8RknI/"})})]}),(0,S.jsx)("div",{className:"text-xs text-orange-500",children:(0,S.jsx)(A.cC,{id:"2T68PV"})}),(0,S.jsxs)("div",{className:"flex items-stretch justify-center gap-2 my-2",children:[(0,S.jsx)("input",{type:"text",value:a,onChange:function(e){return i(e.target.value)},placeholder:T.ag._({id:"rcyeIO"}),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 disabled:text-gray-500 w-full"}),(0,S.jsxs)("button",{onClick:function(){var e;if(""===a.trim()){c(T.ag._({id:"9Rz3G/"}));return}if(n.includes(a)){c(T.ag._({id:"Mwh/zr"}));return}m(!0),(e=document.createElement("script")).setAttribute("type","text/javascript"),e.src=a,e.onload=function(){s([].concat((0,v.Z)(n),[a])),g(!0),i(""),m(!1),c(""),document.head.removeChild(e),e.onload=function(){}},e.onerror=function(t){console.error("Failed to load extension: ".concat(a)),c(T.ag._({id:"0aIV5B",values:{url:a}})),m(!1),document.head.removeChild(e),e.onerror=function(){}},document.head.appendChild(e)},className:"inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 gap-2",disabled:u,children:[u?(0,S.jsx)(E,{}):null,(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"TKQ7K+"})})]})]}),h?(0,S.jsxs)("div",{className:"text-xs text-orange-500",children:[(0,S.jsx)(A.cC,{id:"ZbQrfp"})," ",(0,S.jsx)("button",{className:"text-blue-500 hover:underline font-semibold text-xs",onClick:function(){window.location.reload()},children:(0,S.jsx)(A.cC,{id:"u6QeR6"})})]}):null,l&&(0,S.jsx)("p",{className:"text-red-500 text-xs mt-2",children:l}),(0,S.jsx)("div",{className:"my-2",children:n.map(function(e,t){return(0,S.jsxs)("div",{className:"mt-1 w-full p-2 bg-gray-100 dark:bg-zinc-800 rounded-md flex items-center justify-center gap-2",children:[(0,S.jsx)("div",{className:"w-full break-all",children:e}),(0,S.jsx)(eS,{onConfirmed:function(){s(n.filter(function(t){return t!==e})),g(!0)},className:"text-red-500 font-semibold hover:underline",children:(0,S.jsx)(A.cC,{id:"fo0VXg"})})]},t)})})]})}function nC(){return(0,S.jsxs)("div",{children:[(0,S.jsx)("a",{href:"/test/simple-web-audio-recorder-demo-master/index.html",children:"Audio Recorder"}),(0,S.jsx)("button",{onClick:function(){throw Error("new crash test")},className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors whitespace-nowrap space-x-1",children:"click to crash"}),(0,S.jsx)("div",{children:(0,S.jsx)(A.cC,{id:"V17zQG"})})]})}var nq=n(77191),nI=n(93422),nS=n(96554),nE=n(54497),nO={id:"M8UX1B"},nV=["https://api.anthropic.com/v1/messages","https://cloud2.typingmind.com/api/claude/v1/messages"],nP=(0,K.eK)("useCurrentCompletionEndpoint"),nT=(0,K.eK)("useCurrentAnthropicEndpoint"),nM=(0,K.eK)("useCurrentWhisperEndpoint"),nD=(0,K.eK)("useOpenAIOrgID");function nB(e){(0,nq.Z)(e);var t,n,s,r,a=nP("https://api.openai.com/v1/chat/completions"),i=(0,y.Z)(a,2),o=i[0],l=i[1],c=nT("https://cloud2.typingmind.com/api/claude/v1/messages"),d=(0,y.Z)(c,2),u=d[0],m=d[1],p=nM("https://api.openai.com/v1/audio/transcriptions"),h=(0,y.Z)(p,2),g=h[0],f=h[1],b=(0,q.useState)(o),w=b[0],k=b[1],N=(0,q.useState)(u),C=N[0],I=N[1],O=(0,q.useState)(g),V=O[0],P=O[1],T=nD(""),M=(0,y.Z)(T,2),D=M[0],B=M[1],L=(0,q.useState)(D),R=L[0],_=L[1],Z=(0,q.useState)(!1),K=Z[0],G=Z[1],F=(0,q.useState)(null),Y=F[0],U=F[1],H=(0,A.mV)().i18n;(0,q.useEffect)(function(){k(o)},[o]),(0,q.useEffect)(function(){I(u)},[u]);var z=(t=(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return U(""),e.prev=1,l(w),window.alert(H._({id:"kGCe95"})),window.location.reload(),e.abrupt("return");case 8:e.prev=8,e.t0=e.catch(1),U(H._(nO)),console.error(e.t0);case 12:G(!1);case 13:case"end":return e.stop()}},e,null,[[1,8]])})),function(){return t.apply(this,arguments)}),W=(n=(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return U(""),e.prev=1,m(C),window.alert(H._({id:"kGCe95"})),window.location.reload(),e.abrupt("return");case 8:e.prev=8,e.t0=e.catch(1),U(H._(nO)),console.error(e.t0);case 12:G(!1);case 13:case"end":return e.stop()}},e,null,[[1,8]])})),function(){return n.apply(this,arguments)}),Q=(s=(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return U(""),e.prev=1,f(V),window.alert(H._({id:"kGCe95"})),window.location.reload(),e.abrupt("return");case 8:e.prev=8,e.t0=e.catch(1),U(H._(nO)),console.error(e.t0);case 12:G(!1);case 13:case"end":return e.stop()}},e,null,[[1,8]])})),function(){return s.apply(this,arguments)}),J=(r=(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return U(""),e.prev=1,B(R),window.alert(H._({id:"kGCe95"})),window.location.reload(),e.abrupt("return");case 8:e.prev=8,e.t0=e.catch(1),U(H._(nO)),console.error(e.t0);case 12:G(!1);case 13:case"end":return e.stop()}},e,null,[[1,8]])})),function(){return r.apply(this,arguments)});return(0,S.jsxs)("div",{className:"my-2 space-y-4",children:[(0,S.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,S.jsxs)("label",{className:"text-sm font-semibold flex items-center justify-center gap-2",children:[(0,S.jsxs)("span",{children:[(0,S.jsx)(A.cC,{id:"Rde+o4"}),":"]}),(0,S.jsxs)("button",{onClick:function(){k("https://api.openai.com/v1/chat/completions")},className:"hover:underline text-blue-500 font-semibold flex-shrink-0",children:["(",(0,S.jsx)(A.cC,{id:"SFteAp"}),")"]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2 w-full",children:[(0,S.jsx)("input",{type:"text",placeholder:"https://...",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 disabled:text-gray-500",autoComplete:"off",value:w,onChange:function(e){return k(e.target.value)},disabled:K,onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),z())}}),(0,S.jsx)("button",{onClick:function(){z()},disabled:K,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors whitespace-nowrap space-x-1",children:K?(0,S.jsx)(E,{}):(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"tfDRzk"})})})]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,S.jsxs)("label",{className:"text-sm font-semibold flex items-center justify-center gap-2",children:[(0,S.jsxs)("span",{children:[(0,S.jsx)(A.cC,{id:"8xI/bl"}),":"]}),(0,S.jsxs)("button",{onClick:function(){I("https://cloud2.typingmind.com/api/claude/v1/messages")},className:"hover:underline text-blue-500 font-semibold flex-shrink-0",children:["(",(0,S.jsx)(A.cC,{id:"SFteAp"}),")"]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2 w-full",children:[(0,S.jsx)(nI.hQ,{value:C,onChange:function(e){return I(e)},immediate:!0,children:(0,S.jsxs)("div",{className:"relative w-full",children:[(0,S.jsx)(nI.gA,{className:"w-full px-3 py-2 pr-8 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 disabled:text-gray-500",onChange:function(e){I(e.target.value)}}),(0,S.jsx)(nI.Q$,{className:"absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none",children:(0,S.jsx)(nS.Z,{className:"h-5 w-5 text-gray-400"})}),(0,S.jsx)(nI.L5,{className:"absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white dark:bg-zinc-700 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm",children:[].concat((0,v.Z)(C&&!nV.includes(C)?[{value:C,label:H._({id:"MYfjvl",values:{newAnthropicEndpoint:C}})}]:[]),(0,v.Z)(nV.map(function(e){return{value:e,label:e}}))).map(function(e){return(0,S.jsxs)(nI.O2,{value:e.value,className:"group relative cursor-default select-none py-2 pl-3 pr-9 text-gray-900 dark:text-white hover:bg-blue-600 hover:text-white",children:[(0,S.jsx)("span",{className:"block truncate group-data-[selected]:font-semibold",children:e.label}),(0,S.jsx)("span",{className:"absolute inset-y-0 right-0 hidden items-center pr-4 text-blue-500 group-data-[selected]:flex group-hover:text-white",children:(0,S.jsx)(nE.Z,{className:"h-5 w-5"})})]},e.value)})})]})}),(0,S.jsx)("button",{onClick:function(){W()},disabled:K,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors whitespace-nowrap space-x-1",children:K?(0,S.jsx)(E,{}):(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"tfDRzk"})})})]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,S.jsxs)("label",{className:"text-sm font-semibold flex items-center justify-center gap-2",children:[(0,S.jsxs)("span",{children:[(0,S.jsx)(A.cC,{id:"dV7X6u"}),":"]}),(0,S.jsxs)("button",{onClick:function(){P("https://api.openai.com/v1/audio/transcriptions")},className:"hover:underline text-blue-500 font-semibold flex-shrink-0",children:["(",(0,S.jsx)(A.cC,{id:"SFteAp"}),")"]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2 w-full",children:[(0,S.jsx)("input",{type:"text",placeholder:"https://...",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 disabled:text-gray-500",autoComplete:"off",value:V,onChange:function(e){return P(e.target.value)},disabled:K,onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),Q())}}),(0,S.jsx)("button",{onClick:function(){Q()},disabled:K,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors whitespace-nowrap space-x-1",children:K?(0,S.jsx)(E,{}):(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"tfDRzk"})})})]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,S.jsxs)("label",{className:"text-sm font-semibold flex items-center justify-center gap-2",children:[(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"rNGD7J"})}),(0,S.jsxs)("button",{onClick:function(){_("")},className:"hover:underline text-blue-500 font-semibold flex-shrink-0",children:["(",(0,S.jsx)(A.cC,{id:"SFteAp"}),")"]})]}),(0,S.jsxs)("div",{className:"flex items-center justify-center gap-2 w-full",children:[(0,S.jsx)("input",{type:"text",placeholder:"org-xxxxxx",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700 disabled:text-gray-500",autoComplete:"off",value:R,onChange:function(e){return _(e.target.value)},disabled:K,onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),J())}}),(0,S.jsx)("button",{onClick:function(){J()},disabled:K,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors whitespace-nowrap space-x-1",children:K?(0,S.jsx)(E,{}):(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"tfDRzk"})})})]})]}),(0,S.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:(0,S.jsx)(A.cC,{id:"NnuIWZ"})}),Y&&(0,S.jsx)("div",{className:"mt-2 text-sm text-red-500",children:Y})]})}function nL(){var e,t=(0,q.useState)(null),n=t[0],s=t[1],r=(0,q.useState)(null),a=r[0],i=r[1];return(0,q.useEffect)(function(){(0,x.Z)(j().mark(function e(){var t,n,s;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=navigator)||void 0===t||null===(t=t.storage)||void 0===t||null===(n=t.estimate)||void 0===n?void 0:n.call(t);case 2:(s=e.sent)&&i(s);case 4:case"end":return e.stop()}},e)}))()},[]),(0,q.useEffect)(function(){var e=0;for(var t in localStorage)localStorage.hasOwnProperty(t)&&(e+=localStorage.getItem(t).length,t.substring(0,5));var n=5242880-e;s({usagePercentage:(e/5242880*100).toFixed(2),usedSpace:e,totalSpace:5242880,availableSpace:n})},[]),(0,S.jsxs)("div",{children:[(0,S.jsx)("h3",{className:"text-xl font-bold",children:(0,S.jsx)(A.cC,{id:"RlyAC4"})}),(0,S.jsx)("div",{className:"text-xs my-2",children:(0,S.jsx)(A.cC,{id:"9jrTB+"})}),n?(0,S.jsxs)("div",{className:"my-4 text-xs",children:[(0,S.jsx)("div",{className:"font-semibold text-sm",children:(0,S.jsx)(A.cC,{id:"0ivkbP"})}),(0,S.jsxs)("div",{children:[(0,S.jsx)("div",{className:"my-2 h-4 w-full bg-green-500 rounded-lg overflow-hidden relative",children:(0,S.jsx)("div",{style:{width:"".concat(n.usedSpace/n.totalSpace*100,"%")},className:"h-4 w-full bg-red-500 absolute top-0 left-0 bottom-0"})}),(0,S.jsxs)("div",{className:"flex items-center justify-between ",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(A.cC,{id:"2iTmdZ"})," ",(0,S.jsx)("b",{children:(n.usedSpace/1024/1024).toFixed(2)+" MB"})," (",n.usagePercentage,"%)"]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(A.cC,{id:"ml4bvW"})," ",(0,S.jsx)("b",{children:(n.totalSpace/1024/1024).toFixed(2)+" MB"})," "]})]})]})]}):null,a?(0,S.jsxs)("div",{className:"my-4 text-xs",children:[(0,S.jsx)("div",{className:"font-semibold text-sm",children:(0,S.jsx)(A.cC,{id:"2tuzFd"})}),(0,S.jsxs)("div",{children:[(0,S.jsx)("div",{className:"my-2 h-4 w-full bg-green-500 rounded-lg overflow-hidden relative",children:(0,S.jsx)("div",{style:{width:"".concat(a.usage/a.quota*100,"%")},className:"h-4 w-full bg-red-500 absolute top-0 left-0 bottom-0"})}),(0,S.jsxs)("div",{className:"flex items-center justify-between ",children:[(0,S.jsxs)("div",{children:["IndexedDB:"," ",(0,S.jsx)("b",{children:(0,O.td)((null==a||null===(e=a.usageDetails)||void 0===e?void 0:e.indexedDB)||(null==a?void 0:a.usage)||0)})," "]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(A.cC,{id:"ml4bvW"})," ",(0,S.jsx)("b",{children:(0,O.td)(a.quota||0)})," "]})]})]})]}):null,(0,S.jsx)("div",{className:"text-xs my-2 text-orange-500",children:(0,S.jsx)(A.cC,{id:"kMEn8S"})})]})}function nR(e){var t=e.setChats,n=e.wait,s=void 0===n?5e3:n,r=e.showCoruptedMessage,a=e.emptyMessage,i=(0,q.useState)([]),o=i[0],l=i[1],c=(0,q.useState)(null),d=c[0],u=c[1],m=_();(0,q.useEffect)(function(){var e=setTimeout((0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("ChatsCoruptCheck"),e.t0=O.FW,e.next=4,(0,K.CQ)().entries();case 4:e.t1=e.sent.filter(function(e){var t=(0,y.Z)(e,2),n=t[0];return t[1],n.startsWith("CHAT_")}).map(function(e){var t=(0,y.Z)(e,2);return t[0],t[1]}).filter(Boolean),l((0,e.t0)(e.t1));case 7:case"end":return e.stop()}},e)})),s);return function(){clearTimeout(e)}},[]);var p=function(){if(!m.licensePayload){u(T.ag._({id:"meXG5q"}));return}t(o)};return o.length?(0,S.jsxs)("div",{className:"m-2 p-2 bg-yellow-500 text-black rounded-lg text-xs space-y-2 max-w-xs mx-auto text-center",children:[(0,S.jsxs)("div",{children:[void 0===r||r?T.ag._({id:"TzBiUJ"}):""," ",(0,S.jsx)(A.cC,{id:"Wtg0tB",values:{0:o.length},components:{0:(0,S.jsx)("b",{})}})]}),d?(0,S.jsx)("div",{className:"text-red-500 font-semibold bg-white",children:d}):null,(0,S.jsx)("div",{className:"text-center",children:(0,S.jsx)("button",{onClick:function(){return p()},type:"button",className:"rounded-full border border-blue-500 px-3 py-1 text-sm my-0 hover:bg-blue-600 transition-all space-x-1 bg-blue-500 text-white",children:(0,S.jsx)(A.cC,{id:"mBkVGB"})})})]}):(void 0===a?function(){return null}:a)()}var n_=n(67266),nZ=n.n(n_),nK=n(78798),nG=n(33129),nF=n(72152),nY=n(68919),nU=n(55433);function nH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function nz(e){for(var t=1;t0&&tx.push("".concat(n._({id:"YVY9Iw",values:{0:a.length}}),"")),(null==v?void 0:v.length)>0&&tx.push("".concat(n._({id:"yxF19Y",values:{0:v.length}}),"")),eS.length>0&&tx.push("".concat(n._({id:"ao4ihU",values:{0:eS.length}}),"")),(null==u?void 0:u.length)>0&&tx.push("".concat(n._({id:"IPXOXm",values:{0:u.length}}),"")),h.length>0&&tx.push("".concat(n._({id:"Ftz/t9",values:{0:h.length}}),"")),tx.push(n._({id:"G7dFid",values:{0:tb.length,messagesCount:tf}})),(0,S.jsxs)("div",{children:[tw?(0,S.jsx)("h3",{className:"text-xl font-bold mb-4",children:tw}):null,(0,S.jsx)("div",{className:"mb-4",dangerouslySetInnerHTML:{__html:n._({id:"tdX+tp"})+" "+tx.join(", ")}}),(0,S.jsxs)("div",{className:"my-4 flex items-center flex-wrap gap-2",children:[(0,S.jsxs)("button",{onClick:function(){return td(function(e){return!e})},type:"button",className:"inline-flex items-center px-2 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors",children:[(0,S.jsx)(Y.r2j,{className:"w-4 h-4 mr-2"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"GS+Mus"})})]}),(0,S.jsxs)("button",{type:"button",onClick:function(){var e=document.createElement("input");e.type="file",e.accept="application/json",e.onchange=function(e){var t=e.target.files[0],s=new FileReader;s.onload=function(e){var t=e.target.result;try{var s=JSON.parse(t);tj({success:s})}catch(e){console.error(e),alert(n._(nW))}},s.readAsText(t)},e.click()},className:"inline-flex items-center px-2 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors",children:[(0,S.jsx)(Y.cX4,{className:"w-4 h-4 mr-2"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"l3s5ri"})})]}),(0,S.jsxs)("button",{type:"button",onClick:function(){return te(!0)},className:"inline-flex items-center px-2 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500 disabled:bg-gray-400 disabled:cursor-default transition-colors",children:[(0,S.jsx)(Y.wg8,{className:"w-4 h-4 mr-2"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"mP/ptm"})})]}),tA?(0,S.jsxs)("div",{className:"w-full flex items-center gap-2 flex-wrap",children:[(0,S.jsxs)("button",{type:"button",onClick:function(){var e=document.createElement("input");e.type="file",e.accept="application/json",e.onchange=function(e){var t=e.target.files[0],n=new FileReader;n.onload=function(e){var t=e.target.result;try{var n=JSON.parse(t),s=sf(n),r=s.failedChats,a=s.validChats;tj({success:{data:{chats:a}},fail:r})}catch(e){console.error(e),alert(nW)}},n.readAsText(t)},e.click()},className:"inline-flex whitespace-nowrap items-center px-2 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors",children:[(0,S.jsx)(Y.cX4,{className:"w-4 h-4 mr-2"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"+wwQdk"})})]}),(0,S.jsx)("button",{onClick:function(){return tp(function(e){return!e})},className:"text-blue-500 hover:text-blue-700 text-center",children:(0,S.jsx)(A.cC,{id:"IHD/ra"})})]}):null]}),tm&&(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsx)("h3",{className:"font-bold",children:(0,S.jsx)(A.cC,{id:"7ONgDR"})}),(0,S.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-6 gap-y-2",children:[(0,S.jsx)("img",{src:"/assets/openai-guide/1.png",width:3136,height:1764}),(0,S.jsx)("img",{src:"/assets/openai-guide/2.png",width:3136,height:1764}),(0,S.jsx)("img",{src:"/assets/openai-guide/3.png",width:3136,height:1764})]})]}),tc&&(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsx)("h3",{className:"font-bold",children:(0,S.jsx)(A.cC,{id:"iTDzyV"})}),(0,S.jsx)("div",{className:"mt-2 w-full grid grid-cols-1 xs:grid-cols-2 gap-x-6 gap-y-2",children:sx.map(function(e){var t;return(0,S.jsxs)("label",{className:"flex items-center space-x-2",children:[(0,S.jsx)("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-600",checked:null===(t=ti[e.id])||void 0===t||t,onChange:function(){return tg(e.id)}}),(0,S.jsx)("span",{children:e.label})]},e.id)})}),(0,S.jsxs)("button",{onClick:function(){var e,s,r,a,i={};if(sb.forEach(function(e){var t;(null===(t=ti[e.section])||void 0===t||t)&&e.data.forEach(function(e){i[e]=o[e]})}),!Object.keys(i).some(function(e){return Array.isArray(i[e])?i[e].length>0:!!i[e]})){window.alert(n._({id:"Amd0C9"}));return}var l=new Date,c=(null===(e=t.serverHostConfig)||void 0===e?void 0:e.displayBrand)==="TypingMind"||(null===(s=t.serverHostConfig)||void 0===s?void 0:s.displayBrand)==="Typing Mind"?"_typingmind":null!==(r=t.serverHostConfig)&&void 0!==r&&r.subdomain?"_"+(null===(a=t.serverHostConfig)||void 0===a?void 0:a.subdomain):"",d="".concat((0,nY.Z)(l,"yyyyMMdd_HHmmss")).concat(c,"_export.json"),u=new Blob([JSON.stringify({data:i})],{type:"application/json"}),m=URL.createObjectURL(u),p=document.createElement("a");p.setAttribute("href",m),p.setAttribute("download",d),document.body.appendChild(p),p.click(),p.remove(),URL.revokeObjectURL(m)},type:"button",className:"mt-3 inline-flex items-center px-2 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-default transition-colors",children:[(0,S.jsx)(Y.RFS,{className:"w-4 h-4 mr-2"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"IFNYKF"})})]})]}),e7?(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsx)("div",{className:"text-xs text-gray-500 my-4",children:(0,S.jsx)(A.cC,{id:"HFASYW"})}),(0,S.jsx)(nR,{wait:0,setChats:function(e){tv(e),window.location.reload()},showCoruptedMessage:!1,emptyMessage:function(){return(0,S.jsx)("div",{className:"text-base font-semibold p-4",children:(0,S.jsx)(A.cC,{id:"gIikXc"})})}})]}):null,e9?(0,S.jsxs)("div",{className:"my-4",children:[(0,S.jsx)("div",{className:"text-sm text-red-500 my-4",children:(0,S.jsx)(A.cC,{id:"u7fI8q"})}),(0,S.jsx)("div",{className:"my-2",children:(0,S.jsx)("input",{type:"text",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm dark:bg-zinc-700",placeholder:n._({id:"O8x+FV"}),value:tn,onChange:function(e){return ts(e.target.value)}})}),(0,S.jsxs)("button",{type:"button",onClick:(0,x.Z)(j().mark(function e(){return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,th();case 2:window.location.reload();case 3:case"end":return e.stop()}},e)})),className:"inline-flex items-center px-2 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 disabled:bg-gray-400 disabled:cursor-default transition-colors",disabled:"delete all"!==tn,children:[(0,S.jsx)(Y.wg8,{className:"w-4 h-4 mr-2"}),(0,S.jsx)("span",{children:(0,S.jsx)(A.cC,{id:"lcqFCW"})})]})]}):null]})};function sy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function sw(e){for(var t=1;t