import{R as A,_ as _e,b as Q,g as D,d as Se,f as j,C as De,K as ge,J as Ke,e as je,M as He,N as We,h as Ve,O as Ge,r as m,l as Ne,p as le,i as Ue,m as qe,k as L,P as Xe,j as Ye,Q as Qe,n as Je,T as Ze,U as Ce,V as ea,W as aa,X as be,Y as de,q as t,s as o,Z as te,H as J,v as he,A as V,E as ae,L as Y,G as ue,$ as me,w as ne,a0 as K,a1 as ta,I as Pe,a2 as Ae,S as pe,a3 as Ee,a4 as Re,a5 as na,a6 as ye,a7 as ra,a8 as ia,a9 as sa,aa as la,x as oa,ab as ca,ac as da,ad as ha,ae as ua,af as xe,ag as $e,ah as Ie,ai as we,aj as ma,ak as pa,al as va,am as fa}from"./index-c51caa49.js";import{P as Z,c as Me,t as ga,S as re,D as Ca,p as ba,g as ya,a as xa,B as $a,b as Ia,V as wa,T as W,E as ka,d as _a,e as Sa}from"./PrivateIndicator-3ba4829d.js";import{C as Te,a as Na}from"./CharacterForm-502b4158.js";import{T as G}from"./index-d69c6bc3.js";import{a as Pa,u as Aa,R as B,C as Ea,B as Ra,T as Ma}from"./useTags-e7bab752.js";import{c as Ta}from"./chat-service-5449e6a5.js";import{F as T,I as ve,L as ie,R as Oa,C as ke,M as Ba}from"./MultiLineMarkdown-cd643b01.js";import{E as Fa}from"./EyeFilled-7123e83b.js";import{E as La,H as za}from"./HeartFilled-bac8f4a1.js";import{D as Da,I as Ka,L as ja}from"./LoadingOutlined-a6a50384.js";import{D as X}from"./index-39a5272c.js";import"./index-0b77d27e.js";import"./isString-acff3167.js";import"./_baseIteratee-fd661219.js";var Oe=A.forwardRef(function(e,a){var r=e.prefixCls,l=e.forceRender,i=e.className,h=e.style,u=e.children,c=e.isActive,f=e.role,C=e.classNames,s=e.styles,p=A.useState(c||l),n=_e(p,2),d=n[0],v=n[1];return A.useEffect(function(){(l||c)&&v(!0)},[l,c]),d?A.createElement("div",{ref:a,className:Q("".concat(r,"-content"),D(D({},"".concat(r,"-content-active"),c),"".concat(r,"-content-inactive"),!c),i),style:h,role:f},A.createElement("div",{className:Q("".concat(r,"-content-box"),C==null?void 0:C.body),style:s==null?void 0:s.body},u)):null});Oe.displayName="PanelContent";var Ha=["showArrow","headerClass","isActive","onItemClick","forceRender","className","classNames","styles","prefixCls","collapsible","accordion","panelKey","extra","header","expandIcon","openMotion","destroyInactivePanel","children"],Be=A.forwardRef(function(e,a){var r=e.showArrow,l=r===void 0?!0:r,i=e.headerClass,h=e.isActive,u=e.onItemClick,c=e.forceRender,f=e.className,C=e.classNames,s=C===void 0?{}:C,p=e.styles,n=p===void 0?{}:p,d=e.prefixCls,v=e.collapsible,k=e.accordion,b=e.panelKey,I=e.extra,S=e.header,N=e.expandIcon,y=e.openMotion,E=e.destroyInactivePanel,$=e.children,R=Se(e,Ha),_=v==="disabled",P=v==="header",M=v==="icon",x=I!=null&&typeof I!="boolean",w=function(){u==null||u(b)},F=function(q){(q.key==="Enter"||q.keyCode===ge.ENTER||q.which===ge.ENTER)&&w()},g=typeof N=="function"?N(e):A.createElement("i",{className:"arrow"});g&&(g=A.createElement("div",{className:"".concat(d,"-expand-icon"),onClick:["header","icon"].includes(v)?w:void 0},g));var O=Q(D(D(D({},"".concat(d,"-item"),!0),"".concat(d,"-item-active"),h),"".concat(d,"-item-disabled"),_),f),U=Q(i,D(D(D({},"".concat(d,"-header"),!0),"".concat(d,"-header-collapsible-only"),P),"".concat(d,"-icon-collapsible-only"),M),s.header),z={className:U,"aria-expanded":h,"aria-disabled":_,onKeyDown:F,style:n.header};return!P&&!M&&(z.onClick=w,z.role=k?"tab":"button",z.tabIndex=_?-1:0),A.createElement("div",j({},R,{ref:a,className:O}),A.createElement("div",z,l&&g,A.createElement("span",{className:"".concat(d,"-header-text"),onClick:v==="header"?w:void 0},S),x&&A.createElement("div",{className:"".concat(d,"-extra")},I)),A.createElement(De,j({visible:h,leavedClassName:"".concat(d,"-content-hidden")},y,{forceRender:c,removeOnLeave:E}),function(H,q){var Le=H.className,ze=H.style;return A.createElement(Oe,{ref:q,prefixCls:d,className:Le,classNames:s,style:ze,styles:n,isActive:h,forceRender:c,role:k?"tabpanel":void 0},$)}))}),Wa=["children","label","key","collapsible","onItemClick","destroyInactivePanel"],Va=function(a,r){var l=r.prefixCls,i=r.accordion,h=r.collapsible,u=r.destroyInactivePanel,c=r.onItemClick,f=r.activeKey,C=r.openMotion,s=r.expandIcon;return a.map(function(p,n){var d=p.children,v=p.label,k=p.key,b=p.collapsible,I=p.onItemClick,S=p.destroyInactivePanel,N=Se(p,Wa),y=String(k??n),E=b??h,$=S??u,R=function(M){E!=="disabled"&&(c(M),I==null||I(M))},_=!1;return i?_=f[0]===y:_=f.indexOf(y)>-1,A.createElement(Be,j({},N,{prefixCls:l,key:y,panelKey:y,isActive:_,accordion:i,openMotion:C,expandIcon:s,header:v,collapsible:E,onItemClick:R,destroyInactivePanel:$}),d)})},Ga=function(a,r,l){if(!a)return null;var i=l.prefixCls,h=l.accordion,u=l.collapsible,c=l.destroyInactivePanel,f=l.onItemClick,C=l.activeKey,s=l.openMotion,p=l.expandIcon,n=a.key||String(r),d=a.props,v=d.header,k=d.headerClass,b=d.destroyInactivePanel,I=d.collapsible,S=d.onItemClick,N=!1;h?N=C[0]===n:N=C.indexOf(n)>-1;var y=I??u,E=function(_){y!=="disabled"&&(f(_),S==null||S(_))},$={key:n,panelKey:n,header:v,headerClass:k,isActive:N,prefixCls:i,destroyInactivePanel:b??c,openMotion:s,accordion:h,children:a.props.children,onItemClick:E,expandIcon:p,collapsible:y};return typeof a.type=="string"?a:(Object.keys($).forEach(function(R){typeof $[R]>"u"&&delete $[R]}),A.cloneElement(a,$))};function Ua(e,a,r){return Array.isArray(e)?Va(e,r):Ke(a).map(function(l,i){return Ga(l,i,r)})}function qa(e){var a=e;if(!Array.isArray(a)){var r=Ve(a);a=r==="number"||r==="string"?[a]:[]}return a.map(function(l){return String(l)})}var Xa=A.forwardRef(function(e,a){var r=e.prefixCls,l=r===void 0?"rc-collapse":r,i=e.destroyInactivePanel,h=i===void 0?!1:i,u=e.style,c=e.accordion,f=e.className,C=e.children,s=e.collapsible,p=e.openMotion,n=e.expandIcon,d=e.activeKey,v=e.defaultActiveKey,k=e.onChange,b=e.items,I=Q(l,f),S=je([],{value:d,onChange:function(P){return k==null?void 0:k(P)},defaultValue:v,postState:qa}),N=_e(S,2),y=N[0],E=N[1],$=function(P){return E(function(){if(c)return y[0]===P?[]:[P];var M=y.indexOf(P),x=M>-1;return x?y.filter(function(w){return w!==P}):[].concat(Ge(y),[P])})};He(!C,"[rc-collapse] `children` will be removed in next major version. Please use `items` instead.");var R=Ua(b,C,{prefixCls:l,accordion:c,openMotion:p,expandIcon:n,collapsible:s,destroyInactivePanel:h,onItemClick:$,activeKey:y});return A.createElement("div",j({ref:a,className:I,style:u,role:c?"tablist":void 0},We(e,{aria:!0,data:!0})),R)});const fe=Object.assign(Xa,{Panel:Be});fe.Panel;const Ya=m.forwardRef((e,a)=>{const{getPrefixCls:r}=m.useContext(Ne),{prefixCls:l,className:i,showArrow:h=!0}=e,u=r("collapse",l),c=le({[`${u}-no-arrow`]:!h},i);return m.createElement(fe.Panel,Object.assign({ref:a},e,{prefixCls:u,className:c}))}),Qa=Ya,Ja=e=>{const{componentCls:a,contentBg:r,padding:l,headerBg:i,headerPadding:h,collapseHeaderPaddingSM:u,collapseHeaderPaddingLG:c,collapsePanelBorderRadius:f,lineWidth:C,lineType:s,colorBorder:p,colorText:n,colorTextHeading:d,colorTextDisabled:v,fontSizeLG:k,lineHeight:b,lineHeightLG:I,marginSM:S,paddingSM:N,paddingLG:y,paddingXS:E,motionDurationSlow:$,fontSizeIcon:R,contentPadding:_,fontHeight:P,fontHeightLG:M}=e,x=`${L(C)} ${s} ${p}`;return{[a]:Object.assign(Object.assign({},Ye(e)),{backgroundColor:i,border:x,borderRadius:f,"&-rtl":{direction:"rtl"},[`& > ${a}-item`]:{borderBottom:x,"&:last-child":{[`
            &,
            & > ${a}-header`]:{borderRadius:`0 0 ${L(f)} ${L(f)}`}},[`> ${a}-header`]:{position:"relative",display:"flex",flexWrap:"nowrap",alignItems:"flex-start",padding:h,color:d,lineHeight:b,cursor:"pointer",transition:`all ${$}, visibility 0s`,[`> ${a}-header-text`]:{flex:"auto"},"&:focus":{outline:"none"},[`${a}-expand-icon`]:{height:P,display:"flex",alignItems:"center",paddingInlineEnd:S},[`${a}-arrow`]:Object.assign(Object.assign({},Qe()),{fontSize:R,transition:`transform ${$}`,svg:{transition:`transform ${$}`}}),[`${a}-header-text`]:{marginInlineEnd:"auto"}},[`${a}-icon-collapsible-only`]:{cursor:"unset",[`${a}-expand-icon`]:{cursor:"pointer"}}},[`${a}-content`]:{color:n,backgroundColor:r,borderTop:x,[`& > ${a}-content-box`]:{padding:_},"&-hidden":{display:"none"}},"&-small":{[`> ${a}-item`]:{[`> ${a}-header`]:{padding:u,paddingInlineStart:E,[`> ${a}-expand-icon`]:{marginInlineStart:e.calc(N).sub(E).equal()}},[`> ${a}-content > ${a}-content-box`]:{padding:N}}},"&-large":{[`> ${a}-item`]:{fontSize:k,lineHeight:I,[`> ${a}-header`]:{padding:c,paddingInlineStart:l,[`> ${a}-expand-icon`]:{height:M,marginInlineStart:e.calc(y).sub(l).equal()}},[`> ${a}-content > ${a}-content-box`]:{padding:y}}},[`${a}-item:last-child`]:{borderBottom:0,[`> ${a}-content`]:{borderRadius:`0 0 ${L(f)} ${L(f)}`}},[`& ${a}-item-disabled > ${a}-header`]:{"\n          &,\n          & > .arrow\n        ":{color:v,cursor:"not-allowed"}},[`&${a}-icon-position-end`]:{[`& > ${a}-item`]:{[`> ${a}-header`]:{[`${a}-expand-icon`]:{order:1,paddingInlineEnd:0,paddingInlineStart:S}}}}})}},Za=e=>{const{componentCls:a}=e,r=`> ${a}-item > ${a}-header ${a}-arrow`;return{[`${a}-rtl`]:{[r]:{transform:"rotate(180deg)"}}}},et=e=>{const{componentCls:a,headerBg:r,paddingXXS:l,colorBorder:i}=e;return{[`${a}-borderless`]:{backgroundColor:r,border:0,[`> ${a}-item`]:{borderBottom:`1px solid ${i}`},[`
        > ${a}-item:last-child,
        > ${a}-item:last-child ${a}-header
      `]:{borderRadius:0},[`> ${a}-item:last-child`]:{borderBottom:0},[`> ${a}-item > ${a}-content`]:{backgroundColor:"transparent",borderTop:0},[`> ${a}-item > ${a}-content > ${a}-content-box`]:{paddingTop:l}}}},at=e=>{const{componentCls:a,paddingSM:r}=e;return{[`${a}-ghost`]:{backgroundColor:"transparent",border:0,[`> ${a}-item`]:{borderBottom:0,[`> ${a}-content`]:{backgroundColor:"transparent",border:0,[`> ${a}-content-box`]:{paddingBlock:r}}}}}},tt=e=>({headerPadding:`${e.paddingSM}px ${e.padding}px`,headerBg:e.colorFillAlter,contentPadding:`${e.padding}px 16px`,contentBg:e.colorBgContainer}),nt=Ue("Collapse",e=>{const a=qe(e,{collapseHeaderPaddingSM:`${L(e.paddingXS)} ${L(e.paddingSM)}`,collapseHeaderPaddingLG:`${L(e.padding)} ${L(e.paddingLG)}`,collapsePanelBorderRadius:e.borderRadiusLG});return[Ja(a),et(a),at(a),Za(a),Xe(a)]},tt),rt=m.forwardRef((e,a)=>{const{getPrefixCls:r,direction:l,collapse:i}=m.useContext(Ne),{prefixCls:h,className:u,rootClassName:c,style:f,bordered:C=!0,ghost:s,size:p,expandIconPosition:n="start",children:d,expandIcon:v}=e,k=Je(x=>{var w;return(w=p??x)!==null&&w!==void 0?w:"middle"}),b=r("collapse",h),I=r(),[S,N,y]=nt(b),E=m.useMemo(()=>n==="left"?"start":n==="right"?"end":n,[n]),$=v??(i==null?void 0:i.expandIcon),R=m.useCallback(function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const w=typeof $=="function"?$(x):m.createElement(Ze,{rotate:x.isActive?90:void 0,"aria-label":x.isActive?"expanded":"collapsed"});return Ce(w,()=>{var F;return{className:le((F=w==null?void 0:w.props)===null||F===void 0?void 0:F.className,`${b}-arrow`)}})},[$,b]),_=le(`${b}-icon-position-${E}`,{[`${b}-borderless`]:!C,[`${b}-rtl`]:l==="rtl",[`${b}-ghost`]:!!s,[`${b}-${k}`]:k!=="middle"},i==null?void 0:i.className,u,c,N,y),P=Object.assign(Object.assign({},ea(I)),{motionAppear:!1,leavedClassName:`${b}-content-hidden`}),M=m.useMemo(()=>d?aa(d).map((x,w)=>{var F,g;if(!((F=x.props)===null||F===void 0)&&F.disabled){const O=(g=x.key)!==null&&g!==void 0?g:String(w),{disabled:U,collapsible:z}=x.props,H=Object.assign(Object.assign({},be(x.props,["disabled"])),{key:O,collapsible:z??(U?"disabled":void 0)});return Ce(x,H)}return x}):null,[d]);return S(m.createElement(fe,Object.assign({ref:a,openMotion:P},be(e,["rootClassName"]),{expandIcon:R,prefixCls:b,className:_,style:Object.assign(Object.assign({},i==null?void 0:i.style),f)}),M))}),se=Object.assign(rt,{Panel:Qa});var it={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M885.9 490.3c3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-51.6-30.7-98.1-78.3-118.4a66.1 66.1 0 00-26.5-5.4H273v428h.3l85.8 310.8C372.9 889 418.9 924 470.9 924c29.7 0 57.4-11.8 77.9-33.4 20.5-21.5 31-49.7 29.5-79.4l-6-122.9h239.9c12.1 0 23.9-3.2 34.3-9.3 40.4-23.5 65.5-66.1 65.5-111 0-28.3-9.3-55.5-26.1-77.7zM112 132v364c0 17.7 14.3 32 32 32h65V100h-65c-17.7 0-32 14.3-32 32z"}}]},name:"dislike",theme:"filled"};const st=it;var lt=function(a,r){return m.createElement(de,j({},a,{ref:r,icon:st}))};const ot=m.forwardRef(lt);var ct={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M885.9 533.7c16.8-22.2 26.1-49.4 26.1-77.7 0-44.9-25.1-87.4-65.5-111.1a67.67 67.67 0 00-34.3-9.3H572.4l6-122.9c1.4-29.7-9.1-57.9-29.5-79.4A106.62 106.62 0 00471 99.9c-52 0-98 35-111.8 85.1l-85.9 311h-.3v428h472.3c9.2 0 18.2-1.8 26.5-5.4 47.6-20.3 78.3-66.8 78.3-118.4 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7-.2-12.6-2-25.1-5.6-37.1zM112 528v364c0 17.7 14.3 32 32 32h65V496h-65c-17.7 0-32 14.3-32 32z"}}]},name:"like",theme:"filled"};const dt=ct;var ht=function(a,r){return m.createElement(de,j({},a,{ref:r,icon:dt}))};const ut=m.forwardRef(ht);var mt={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"}}]},name:"warning",theme:"outlined"};const pt=mt;var vt=function(a,r){return m.createElement(de,j({},a,{ref:r,icon:pt}))};const Fe=m.forwardRef(vt),ee=({children:e})=>t("div",{children:e.split(`
`).map((a,r)=>t("p",{style:{wordWrap:"break-word"},children:a},r))}),{Title:ft}=G,Lt=()=>o(Z,{children:[t(J,{children:o("title",{children:["AI Character Generator - ",te]})}),t(ft,{level:2,children:"AI Character Generator"}),t(Te,{values:{is_nsfw:!1,is_public:!0,description:"",scenario:"",example_dialogs:"",first_message:"",tag_ids:[]}})]}),{Title:gt}=G,zt=()=>{const{characterId:e}=he(),{profile:a}=m.useContext(V),{data:r,isLoading:l}=ae(["character",e],async()=>await me.from("characters").select("*, tags(id)").eq("id",e).limit(1).single(),{enabled:!!e}),i=m.useMemo(()=>{if(r!=null&&r.data&&r.data.creator_id===(a==null?void 0:a.id)){const h=Array.isArray(r.data.tags)?r.data.tags:[];return{...r.data,tag_ids:h.map(c=>c.id)}}},[r]);return o(Z,{children:[t(J,{children:o("title",{children:[te," - Edit character"]})}),o(gt,{level:2,children:["Edit Character ",t(Y,{to:i?Me(i==null?void 0:i.id,i==null?void 0:i.name):"/",children:"(View Character)"})]}),l&&t(ue,{}),i&&t(Te,{id:i.id,values:i})]})},{Title:Ct}=G,Dt=()=>{const{profile:e}=m.useContext(V),{message:a}=ne.useApp(),{data:r,isLoading:l,refetch:i}=ae(["characters",e==null?void 0:e.id],async()=>{const{data:{data:h}}=await Pe.get("/characters/user");return h?h.map(c=>{const{tags:f}=c;return{...c,creator_id:e.id,creator_name:e.user_name||e.name,creator_verified:e.is_verified||!1,tags:f}}):[]},{enabled:!!e});return o(Z,{align:"left",children:[t(J,{children:o("title",{children:[te," - My characters"]})}),o(Ct,{level:2,children:["My Characters"," ",r&&o("span",{children:["(Total: ",r.filter(h=>h.is_public).length," public,"," ",r.filter(h=>!h.is_public).length," private)"]})]}),t(Y,{to:"/create_character",children:o(K,{type:"primary",size:"large",children:[t(ta,{})," Create Character"]})}),o("div",{className:"mt-4",children:[l&&t(ue,{}),r&&t(Pa,{characters:r,editable:!0,onCharacterDeleted:()=>{a.success("Character deleted!"),i()}})]})]})},{Title:bt}=G,Kt=()=>{const{tagId:e}=he(),a=Ae(e),r=Aa(),{localData:l}=m.useContext(V),[i,h]=m.useState({search:"",mode:l.character_view||"sfw",sort:"latest",tag_id:a?parseInt(a,10):void 0}),u=s=>{h({...i,...s})},[c,f]=m.useState("");let C="Search For Character AI Chat";if(r&&a){const s=r.find(p=>p.id===parseInt(a,10));C=`Characters with tag ${s==null?void 0:s.name}`,`${location.origin}${ga(parseInt(a,10),(s==null?void 0:s.name)||"")}`}return o(Z,{align:"left",children:[t(J,{children:o("title",{children:[C," - ",te]})}),t(bt,{level:3,className:"mb-4",children:C}),o(T,{layout:"inline",children:[t(T.Item,{children:o(B.Group,{defaultValue:i.mode,onChange:s=>u({mode:s.target.value}),children:[o(B.Button,{value:"all",children:[t(Fa,{})," All"]}),o(B.Button,{value:"sfw",children:[t(La,{})," SFW Only"]}),o(B.Button,{value:"nsfw",children:[t(za,{})," NSFW Only"]})]})}),t(T.Item,{className:"mb-xs-py",style:{flexGrow:3},children:t(ve.Search,{defaultValue:"",value:c,placeholder:"Enter or click to search",onChange:s=>f(s.target.value),onSearch:s=>u({search:s})})}),t(T.Item,{className:"flex-grow-1",children:o(re,{style:{width:"100%",minWidth:"10rem"},value:i.sort,onChange:s=>u({sort:s}),children:[t(re.Option,{value:"latest",children:"Sort by latest"}),t(re.Option,{value:"popular",children:"Sort by most popular"})]})})]}),r&&t("div",{className:"tag-container",children:t(pe,{className:"mt-4 ",size:[2,8],wrap:!0,children:r==null?void 0:r.map(s=>t(Ee,{title:s.description,children:t(Re.CheckableTag,{checked:s.id===i.tag_id,onChange:()=>{s.id===i.tag_id?u({tag_id:void 0}):u({tag_id:s.id})},children:s.name},s.id)},s.id))})}),t(Ea,{size:"small",cacheKey:"search",additionalParams:i})]})},yt={is_like:!0,content:""},oe=t(ut,{style:{color:"#2ecc71"}}),ce=t(ot,{style:{color:"#e74c3c"}}),xt=({reviews:e,characterId:a,refetch:r})=>{const{message:l}=ne.useApp(),{profile:i}=m.useContext(V),[h]=T.useForm(),[u,c]=m.useState(!1),f=!!(i&&e&&(e.length===0||e.every(n=>n.user_id!==i.id))),C=async()=>{!i||!a||(await me.from("reviews").delete().match({user_id:i.id,character_id:a}),l.success("Review deleted!"),r())};function s(n,d=10){if(!n)return;let v=n.length>d?n.substring(0,d):n;return v.length>2?v.substring(0,2)+"*".repeat(v.length-2):"*".repeat(v.length)}const p=async n=>{if(!(!i||!a))try{c(!0);const d=await ba({...n,character_id:a});d.character_id===a&&d.user_id===i.id&&(l.success("Review posted!"),r())}catch(d){l.error("Fail to post review, try again later!"),console.error(d)}finally{c(!1)}};return o("div",{children:[f&&o("div",{className:"mb-4",children:[t(G.Title,{level:5,children:"Leave a review or feedback for the creator ❤️"}),o(T,{form:h,layout:"inline",initialValues:yt,onFinish:p,children:[t(T.Item,{className:"flex-grow-1",name:"content",children:t(ve,{onBlur:n=>{na(n,h)},placeholder:"Write something (optional)"})}),t(T.Item,{className:"mb-xs-py",name:"is_like",children:o(B.Group,{children:[o(B.Button,{value:!0,children:[oe," Like"]}),o(B.Button,{value:!1,children:[ce," Dislike"]})]})}),t(T.Item,{className:"mr-0 mb-xs-py",children:t(K,{type:"primary",block:!0,htmlType:"submit",loading:u,disabled:u,children:"Post review"})})]})]}),t(Da,{className:"my-0"}),t(ie,{itemLayout:"horizontal",dataSource:e||[],renderItem:n=>t(ie.Item,{actions:i&&n.user_id===i.id?[t(K,{danger:!0,icon:t(Ca,{}),onClick:C})]:void 0,children:t(ie.Item.Meta,{avatar:n.user_profiles.avatar?t(ye,{src:ra(n.user_profiles.avatar)}):t(ye,{icon:t(ia,{})}),title:o("span",{children:[t("strong",{children:s(n.user_profiles.user_name)||s(n.user_profiles.name)||"Anon"})," ",n.is_like?oe:ce," this characters"]}),description:""})})})]})},$t=({open:e,characterId:a,onModalClose:r})=>{const{profile:l}=m.useContext(V),{message:i}=ne.useApp(),[h,u]=m.useState(!1),[c]=T.useForm(),f=T.useWatch("reason",c);return t(sa,{title:"Report this bot",open:e,okText:o("span",{children:[t(Fe,{})," Report"]}),okButtonProps:{danger:!0,disabled:h,loading:h},onOk:()=>{c.submit()},onCancel:r,children:t("div",{className:"pt-2",children:o(T,{form:c,onFinish:async p=>{try{if((await me.from("user_reports").insert({reason:p.reason,other:p.other,url:location.href,character_id:a,profile_id:l?l.id:null})).error){i.error("Fail to submit report, please try again later!");return}i.success("Your report had been submitted successfully!"),r()}finally{u(!1)}},initialValues:{reason:"stolen",other:""},children:[t(T.Item,{name:"reason",children:t(B.Group,{children:o(pe,{direction:"vertical",children:[t(B,{value:"stolen",children:"This bot is mine. It's posted here without my permission."}),t(B,{value:"wrong_tag",children:"This bot's tag is wrong. (Missing NSFW, missing tags)"}),t(B,{value:"spam",children:"This bot is a spam, low-quality, or duplicated one."}),t(B,{value:"illegal",children:"This bot or its content is illegal or harmful."}),t(B,{value:"other",children:"Others (Please specify)"})]})})}),t(T.Item,{name:"other",help:f==="stolen"&&o("div",{className:"pt-2",children:[t("span",{children:"Please include the link to original bot on booru/discord/charhub."}),t("br",{}),o("span",{children:["You can also include your nsfwcharai.com profile, the mods will"," ",t("strong",{children:"transfer the bot to your accounts"})," and help you monitor for duplicated/stolen bots."]})]}),children:t(ve.TextArea,{placeholder:"Enter more details here."})})]})})})},{Title:It}=G,jt=()=>{var y,E,$,R,_,P,M,x,w,F;const{profile:e,localData:a}=m.useContext(V),r=la(),{characterId:l}=he(),i=Ae(l),{modal:h,message:u}=ne.useApp(),c=oa(),[f,C]=m.useState(!1),[s,p]=m.useState(!1),{data:n,isLoading:d}=ae(["view_character",i],async()=>await Sa(i),{enabled:!!i,retry:1,onSuccess(g){g&&fa()}}),{data:v,refetch:k}=ae(["view_character_reviews",i],async()=>await ya(i),{enabled:!!(i&&n&&n.is_public)}),b=!!(e&&e.id===(n==null?void 0:n.creator_id));m.useEffect(()=>{e!=null&&e.id&&i?ca("character_detail",i):a.visitorId&&i&&da(a.visitorId,"character_detail",i)},[i,a.visitorId,e==null?void 0:e.id]),m.useEffect(()=>{ha()},[]);const I=m.useCallback(async()=>{if(!e){c(`/visitor-chats/${i}`);return}try{p(!0);const{data:g}=await Pe.get(`/chats/exist/${i}`);if(g.error&&g.error.code==ua.NOT_FOUND)return h.info({title:"Can not find this character!",content:t("p",{children:"Can not find this character. It might be deleted or set to private."})});if(g.data)c(`/chats/${g.data.id}`);else{const O=await Ta.createChat(i);O&&c(`/chats/${O.id}`)}}catch(g){u.error(JSON.stringify(g,null,2))}finally{p(!1)}},[e]),S=m.useCallback(async g=>{const O=(e==null?void 0:e.block_list)||xe;O.bots.push(g),await $e(O,r),u.success("Character has been blocked!")},[e]),N=m.useCallback(async g=>{const O=(e==null?void 0:e.block_list)||xe;O.bots=O.bots.filter(U=>U!==g),await $e(O,r),u.success("Character has been unblocked!")},[e]);return o(Z,{children:[d&&t(ue,{}),!d&&!n&&t("p",{children:"Can not find this character. It might be deleted or set to private."}),n&&o(J,{children:[t("title",{children:`Chat with ${n.name} - Total: ${(y=n.stats)==null?void 0:y.chat} chats, ${(E=n.stats)==null?void 0:E.message} messages`}),t("meta",{property:"og:title",content:`Chat with ${n.name} - Total: ${($=n.stats)==null?void 0:$.chat} chats, ${(R=n.stats)==null?void 0:R.message} messages`}),t("meta",{property:"og:description",content:`Chat with ${n.name} - ${n.description}`}),t("meta",{property:"og:image",content:Ie(n.avatar)}),t("meta",{name:"description",content:`Chat with ${n.name} - ${n.description}`}),t("link",{rel:"canonical",href:`${location.origin}${Me(n.id,n.name)}`})]}),n&&o(Oa,{gutter:16,children:[o(ke,{lg:6,xs:24,className:"pt-2 pb-2 mb-2 text-left",children:[o(It,{level:3,children:[t(xa,{isPublic:n.is_public})," ",n.name]}),t(Ra.Ribbon,{text:n.stats&&t(Ee,{title:`Total: ${(_=n.stats)==null?void 0:_.chat} chats, ${(P=n.stats)==null?void 0:P.message} messages`,children:o("span",{children:[t($a,{}),(M=n.stats)==null?void 0:M.chat," ",t(we,{}),(x=n.stats)==null?void 0:x.message]})}),children:t(Ka,{src:Ie(n.avatar)})}),o("div",{className:"mt-2",children:[t(Y,{target:"_blank",to:Ia(n.creator_id,n.creator_name),children:o("p",{children:["@",n.creator_name," ",n.creator_verified&&t(wa,{size:"medium"})]})}),t(Ba,{children:n.description})]}),n.is_nsfw||(w=n.tags)!=null&&w.length?o(pe,{size:[0,8],wrap:!0,children:[n.is_nsfw?t(Re,{color:"error",children:"🔞 NSFW"}):"",(F=n.tags)==null?void 0:F.map(g=>t(Ma,{tag:g}))]}):null,t("div",{className:"mt-4",children:o(K,{type:"primary",block:!0,onClick:()=>{I(),ma()},style:{whiteSpace:"normal",height:"auto"},disabled:s,children:[s?t(ja,{}):t(we,{})," Chat with ",n.name," 🔒"]})})]}),o(ke,{lg:18,xs:24,className:"text-left",children:[o(se,{defaultActiveKey:["reviews","chats"],children:[e&&t(se.Panel,{header:`Character definition - May contains spoiler (Total ${W.tokenCountFormat(n.personality+n.first_message+n.scenario+n.example_dialogs)}. Permanent: ${W.tokenCountFormat(n.personality+n.scenario)})`,children:o(X,{bordered:!0,size:"small",layout:"vertical",children:[t(X.Item,{label:`Personality (${W.tokenCountFormat(n.personality)})`,span:3,children:t(ee,{children:n.personality})}),t(X.Item,{label:`First Message (${W.tokenCountFormat(n.first_message)})`,span:3,children:t(ee,{children:n.first_message})}),t(X.Item,{label:`Scenario (${W.tokenCountFormat(n.scenario)})`,span:3,children:t(ee,{children:n.scenario})}),t(X.Item,{label:`Example Dialogs (${W.tokenCountFormat(n.example_dialogs)})`,span:3,children:t(ee,{children:n.example_dialogs})})]})},"definition"),t(se.Panel,{header:v?o("span",{children:[v.length," reviews (",v.filter(g=>g.is_like).length," ",oe,","," ",v.filter(g=>!g.is_like).length," ",ce,")"]}):t("span",{children:"0 review"}),children:t(xt,{reviews:v,characterId:i,refetch:()=>k()})},"reviews")]}),t("div",{className:"mt-4 text-right",children:b?t(Y,{to:`/edit_character/${n.id}`,children:t(K,{size:"large",icon:t(ka,{}),children:"Edit character"})}):o("div",{children:[pa(e==null?void 0:e.block_list,"bots",n.id)?t(K,{icon:t(Na,{}),onClick:()=>N(n.id),children:"Unblock"}):t(_a,{title:o("div",{children:["You will not see this character anymore! ",t("br",{})," You can unblock it later in ",t(Y,{to:"/blocks",children:"Blocks"})," menu."]}),onConfirm:()=>S(n.id),children:t(K,{icon:t(va,{}),children:"Block"})}),t(K,{className:"ml-2",icon:t(Fe,{}),onClick:()=>C(!0),danger:!0,children:"Report this!"}),i&&f&&t($t,{characterId:i,open:f,onModalClose:()=>C(!1)})]})})]})]})]})};export{Lt as CreateCharacter,zt as EditCharacter,Dt as MyCharacters,Kt as SearchCharacter,jt as ViewCharacter};