PageSourceSearch

https://characterhub.com/_nuxt/C2TcZ0K9.js

js characterhub.com collected 2026-10-03 22:01:20 UTC 70,540 bytes, 1 lines download raw bytes

1import dt from"./Bl3pyLPY.js";import{s as oe,u as vt}from"./CSy67qK4.js";import{f as se,i as D,o,a as i,u as e,j as t,x as m,y as M,D as z,k as R,e as x,c as E,a0 as et,Q as Re,v as we,z as ne,B as H,r as mt,t as de,n as ge,J as ie,W as fe,V as Ae,A as Z,b as ye,w as re,ab as pt,l as tt,R as ft,g as Pe,C as $e,T as yt}from"./iJPA3RaR.js";import{i as le,ca as _t,aD as Ce,e3 as gt,cq as Ne,P as qe,aq as bt,mi as ot,U as Me,aO as Le,mq as ht,kR as xe,mr as he,ms as Ve,z as st,m as Ge,b as Fe,Q as ue,b0 as lt,mt as kt,mu as wt,l5 as Ct,t as be,d as St,a as Te,V as He,cn as $t,W as Oe,mv as Ye,mw as Xe,aM as xt,f as Qe,dc as je,mx as It,$ as at,my as Je,mz as Mt,hH as Tt,af as Dt,cM as At,mA as Vt,j as Ue,e5 as Ut,ml as Et,a2 as Lt,cC as Ot,jF as Rt,c6 as Ke,d9 as Ft}from"./eOmGi0ej.js";import{p as Wt}from"./CrzlP7Jn.js";import{M as Kt}from"./fIUFKDeM.js";import{D as Pt}from"./Cwi7nllv.js";import{R as jt}from"./YPEdzzoh.js";import{I as Bt,p as Ie,a as Ee}from"./EwIFVvnR.js";import{C as Ze,a as zt,b as Nt}from"./CS10CGvY.js";import{l as nt}from"./CaoWC3Hv.js";import{a as qt}from"./D1xktYIi.js";import{G as We}from"./CuwsnNma.js";import{C as Be}from"./DYcplK3b.js";import{g as rt}from"./DS1T-2TA.js";import{F as ze}from"./BrKQIbH3.js";import{I as Gt}from"./BKz0zGYm.js";import{V as Ht}from"./2-YFSvAD.js";import{n as Yt}from"./dGOTJYrW.js";import{o as Xt}from"./CxLOejld.js";import{_ as Qt}from"./VcySoWWp.js";import{V as Jt}from"./B7Df3chc.js";import{u as Zt}from"./CQgRrPbW.js";import{_ as eo}from"./C1A1LZsz.js";import"./C5wJEVHP.js";import"./BwkyRxai.js";import"./CbKJWkGN.js";import"./BGFf6D91.js";import"./UFwaZaEC.js";import"./YPk0DKNd.js";import"./D11-qrxw.js";import"./ICFm9OWy.js";import"./DQzPIviB.js";import"./Bx2m9KTX.js";import"./8YOiTwFB.js";import"./DCHQ9cAN.js";import"./BSlbnkrT.js";import"./7o9BIHTR.js";import"./yrM3Hul3.js";import"./Dt71xjeN.js";import"./Ckmim1AA.js";import"./DYuLImmP.js";import"./bZ83SDdf.js";import"./Bvly4nEr.js";import"./DaqW2up1.js";import"./CyTawqXh.js";import"./m5AJgy6M.js";import"./98bcCQFi.js";import"./BermJvY9.js";import"./Bi-Bb-u2.js";import"./DgValcHS.js";import"./BPAu6nrW.js";import"./DuJsTdQb.js";import"./1pF_SMMH.js";import"./B69SPGPM.js";try{let F=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},b=new F.Error().stack;b&&(F._sentryDebugIds=F._sentryDebugIds||{},F._sentryDebugIds[b]="7ae699a4-b096-461e-a7a0-8c7f91ff33b2",F._sentryDebugIdIdentifier="sentry-dbid-7ae699a4-b096-461e-a7a0-8c7f91ff33b2")}catch{}const to={key:0,class:"loading d-flex flex-column align-center"},oo={key:1},so=se({__name:"CoverPopover",props:{instance:{type:Object}},setup(F){const $=F.instance,{storyworld:p,changeCover:f}=oe(),c=x(!1),u=y=>{typeof y!="string"||!y||(f(y),$&&$.dismiss(),c.value=!1)},l=E(()=>p?.value?.cover_image||""),h=()=>{f(""),$&&$.dismiss()};return(y,C)=>{const d=D("ion-progress-bar"),_=D("ion-item");return o(),i("div",null,[e(c)?(o(),i("div",to,[C[0]||(C[0]=t("div",{class:"px-3 py-2"},"Uploading",-1)),m(d,{type:"indeterminate"})])):(o(),i("div",oo,[m(dt,{class:"cover-uploader","is-cover":!0,onUploaded:u,uid:"WorldEditorCoverPopover"},{default:M(()=>[m(_,{class:"item-container pointer"},{default:M(()=>[...C[1]||(C[1]=[t("div",{class:"d-flex"},[t("i",{class:"ti-layout-grid4-alt"}),t("div",{class:"ml-2 menu-item d-flex align-items-center"},"Choose a photo")],-1)])]),_:1})]),_:1}),e(l)?(o(),z(_,{key:0,class:"item-container d-flex pointer",onClick:h},{default:M(()=>[...C[2]||(C[2]=[t("i",{class:"ti-eraser"},null,-1),t("div",{class:"ml-2 menu-item d-flex align-items-center"},"Clear Cover Picture",-1)])]),_:1})):R("",!0)]))])}}}),lo=le(so,[["__scopeId","data-v-85f296b4"]]),ao={class:"story-world-header position-relative"},no={class:"cover position-relative"},ro=["src"],io=se({__name:"Cover",setup(F){const{storyworld:b}=oe(),$=E(()=>b?.value?.cover_image),p=f=>{Wt.open(f,lo,{},"create-popover")};return(f,c)=>{const u=D("ion-button"),l=et("image");return o(),i("div",ao,[t("div",no,[Re(t("img",{loading:"lazy",src:e(_t)(e($),"800w"),class:"image"},null,8,ro),[[l]]),m(u,{class:"edit-btn position-absolute btn-reposition",onClick:p},{default:M(()=>[...c[0]||(c[0]=[t("i",{class:"ti-pencil"},null,-1)])]),_:1})])])}}}),co=le(io,[["__scopeId","data-v-1ad5cac8"]]),uo={class:"overall"},vo={class:"story-world-key-info mb-4 position-relative"},mo={class:"one-info"},po={class:"one-info"},fo={class:"one-info"}
1,yo=se({__name:"KeyInfo",setup(F){const{changeInfoKey:b,storyworld:$}=oe(),p=x([]),f=x(!1),c=E({get(){return $?.value?.name||""},set(d){b("name",d)}}),u=E({get(){return $.value?.extra.quote||""},set(d){b("quote",d)}}),l=E({get(){return $?.value?.tags||[]},set(d){b("tags",d)}}),h=d=>{const _=$.value?.tags||[];_.push(d),b("tags",_)},C=Ce(async d=>{if(f.value=!0,!d)p.value=[];else{const _=await gt(1,4,d);p.value=Ne(_.results,T=>T.name)}f.value=!1},500);return(d,_)=>{const T=D("ion-input"),g=D("ion-textarea");return o(),i("div",uo,[t("div",vo,[_[6]||(_[6]=t("div",{class:"title"},"Key Info",-1)),t("div",mo,[_[3]||(_[3]=t("div",{class:"label"},"Story World Name",-1)),m(T,{modelValue:e(c),"onUpdate:modelValue":_[0]||(_[0]=a=>we(c)?c.value=a:null),class:"c-input one-input",placeholder:"Every world begins with a name!"},null,8,["modelValue"])]),t("div",po,[_[4]||(_[4]=t("div",{class:"label"},"Quote",-1)),m(g,{modelValue:e(u),"onUpdate:modelValue":_[1]||(_[1]=a=>we(u)?u.value=a:null),class:"c-textarea one-input",placeholder:"What saying would be inscribed on its gates? Engrave it here!"},null,8,["modelValue"])]),t("div",fo,[_[5]||(_[5]=t("div",{class:"label"},"Tags",-1)),m(e(Kt),{modelValue:e(l),"onUpdate:modelValue":_[2]||(_[2]=a=>we(l)?l.value=a:null),"tag-placeholder":"Select to create a tag",placeholder:"Press Enter to Add Tags ↩","select-label":"","deselect-label":"","show-no-options":!1,options:e(p),multiple:!0,taggable:!0,loading:e(f),"open-direction":"bottom","close-on-select":!1,class:"tags",onTag:h,onSearchChange:e(C)},null,8,["modelValue","options","loading","onSearchChange"])])])])}}}),_o=le(yo,[["__scopeId","data-v-fd931dc2"]]),go={key:0,class:"reorderable-section"},bo={class:"top-bar d-flex align-items-center"},ho=["aria-label"],ko={class:"title flex-grow-1"},wo=["title"],Co={class:"top-actions d-flex align-items-center"},So=["aria-label"],$o=se({__name:"ReorderableSection",props:{title:{type:String},usedKey:{type:String},index:{type:Number,default:0}},setup(F){const{removeSection:b,storyworld:$,setSectionOrder:p}=oe(),f=x(!0),u=de(F,"usedKey"),l=E(()=>$?.value?.included_locations),h=n=>{if(Ie[n])return Ie[n];if(Ee[n])return Ee[n];const w=$?.value?.[n]??$?.value?.extra?.[n];return w?.title?w.title:w?.type?ot(w.type):n},y=async()=>{const n=await bt.create({component:jt,cssClass:"modal-cmfl reorder-sections-modal-wrapper",componentProps:{initialOrder:[...$.value?.extra?.order||[]],labelFor:h,onDone:w=>p(w)}});n.componentProps={...n.componentProps,instance:n},await n.present()},C=x(!1),d=x(!1),_=()=>{d.value=!0},T=()=>{d.value=!1},g=()=>{d.value=!1,ge(()=>{u.value&&(b(u.value),f.value=!1,ge(()=>{f.value=!0}))})},a=()=>{C.value=!C.value};return(n,w)=>e(f)?(o(),i("div",go,[m(Pt,{"is-open":e(d),onDismissModal:T,onRemove:g},null,8,["is-open"]),t("div",bo,[t("button",{class:ne(["collapse-btn no-select d-flex align-items-center justify-content-center",{c
1ollapsed:e(C)}]),"aria-label":e(C)?"Expand section":"Collapse section",onClick:a},[...w[0]||(w[0]=[t("i",{class:"ti-angle-down"},null,-1)])],10,ho),t("div",ko,[t("div",{class:"title-text",title:F.title},H(F.title),9,wo)]),t("div",Co,[t("button",{class:"icon-btn delete-btn no-select d-flex align-items-center justify-content-center","aria-label":"Delete section",onClick:_},[...w[1]||(w[1]=[t("i",{class:"ti-trash"},null,-1)])]),t("button",{class:"icon-btn reorder-btn no-select d-flex align-items-center justify-content-center","aria-label":`Reorder sections (current position ${F.index+1})`,onClick:y},[...w[2]||(w[2]=[t("i",{class:"ti-exchange-vertical"},null,-1)])],8,So)])]),t("div",{class:ne(["content",{collapsed:e(C)}])},[mt(n.$slots,"default",{},void 0,!0)],2),e(u)==="subworlds"&&!("isEmpty"in n?n.isEmpty:e(qe))(e(l))?(o(),i("div",{key:0,class:ne(["content mt-2",{collapsed:e(C)}])},[m(Bt,{value:e(l)},null,8,["value"])],2)):R("",!0)])):R("",!0)}}),xo=le($o,[["__scopeId","data-v-12c9391f"]]),Io={class:"color-pallet mt-2"},Mo={key:0,class:"d-flex mt-2 sortable-container"},To={key:1,class:"colors mt-2 d-flex"},Do=se({__name:"Colors",setup(F){const{setWorldColorsEditable:b,worldColorsEditable:$}=oe(),{width:p}=Le(),f=$,c=x(!1),u={handle:".colorr",animation:150,swapThreshold:1,fallbackTolerance:5,touchStartThreshold:5},l=g=>{const a=[...f.value];a.splice(g.newIndex,0,a.splice(g.oldIndex,1)[0]),b(a.filter(n=>n))},h=()=>{c.value=!c.value},y=E(()=>p.value<=480),C=(g,a)=>{"hex_code"in f.value[g]?f.value[g].hex_code=a:f.value[g].color=a,b(f.value)},d=(g,a)=>{f.value[g].label=a,b(f.value)},_=g=>{f.value.splice(g,1),b(f.value)},T=()=>{const g={hex_code:"#FFFFFF",id:Me(6),label:""};f.value?(f.value.push(g),b(f.value)):b([g])};return(g,a)=>{const n=D("Sortable"),w=D("ion-button"),L=D("ion-custom-button");return o(),i("div",Io,[e(c)?(o(),i("div",Mo,[m(n,{id:"colors",class:"colors","item-key":"id",tag:"div",list:e(f),options:u,onEnd:l},{item:M(({element:U,index:K})=>[(o(),z(Ze,{key:U.id,class:"color-handle",value:U.hex_code||U.color,label:U.label,"is-draggable":e(c),"is-mob-small-screen":e(y),onChanged:r=>C(K,r),onRemoved:()=>_(K)},null,8,["value","label","is-draggable","is-mob-small-screen","onChanged","onRemoved"]))]),_:1},8,["list"])])):(o(),i("div",To,[(o(!0),i(ie,null,fe(e(f),(U,K)=>(o(),z(Ze,{key:U.id,value:U.hex_code||U.color,label:U.label,"is-mob-small-screen":e(y),onChanged:r=>C(K,r),onTextChanged:r=>d(K,r),onRemoved:()=>_(K)},null,8,["value","label","is-mob-small-screen","onChanged","onTextChanged","onRemoved"]))),128)),e(y)?R("",!0):(o(),z(w,{key:0,class:"d-flex color-btn",onClick:Ae(T,["stop"])},{default:M(()=>[...a[0]||(a[0]=[t("div",{class:"d-flex flex-column"},[t("div",null,[t("i",{class:"ti-plus",style:{"font-weight":"900"}})]),t("div",{style:{"font-size":"12px","margin-top":"5px"}},"Add Color")],-1)])]),_:1}))])),t("div",{class:ne(["mt-2 action-buttons",{"mobile-layout":e(y)}])},[e(y)?(o(),z(w,{key:0,class:"add-color-btn",onClick:Ae(T,["stop"])},{default:M(()=>[...a[1]||(a[1]=[t("i",{class:"ti-plus mx-1",style:{"font-weight":"900"}},null,-1),t("span",null,"Add Color",-1)])]),_:1})):R("",!0),t("div",{class:"reorder-button",onClick:Ae(h,["stop"])},[m(L,{color:e(c)?"secondary":""},{default:M(()=>[Z(H(e(c)?"Save Order":"Reorder"),1)]),_:1},8,["color"])])],2)])}}}),Ao=le(Do,[["__scopeId","data-v-43270f61"]]),Vo={class:"text"},Uo={class:"d-flex align-items-center mt-2 wrapper one-row"},Eo={class:"d-flex data"},Lo=se({__name:"FeaturedIn",props:{usedKey:{type:String,default:""},value:{type:Object,default:{}},config:{type:Object,default:{}},isTemplate:{type:Boolean,default:!1}},setup(F){const{changeInfoKey:b}=oe(),{isMobSmallScreen:$}=Le(),p=F,f=x(!1),c=de(p,"value"),u=de(p,"value"),l=de(p,"usedKey"),h=de(p,"usedKey"),y=x([]),C=x({}),d=E(()=>{const K=$.value,r=typeof navigator<"u"&&(navigator.userAgent.includes("OPR")||navigator.userAgent.includes("Opera")),s={handle:".featured-drag-handle",delay:0,animation:150,forceFallback:!K||r,scroll:!0,scrollSensitivity:100,scrollSpeed:15,bubbleScroll:!0,touchStartThreshold:0,fallbackTolerance:3,swapThreshold:.65,dragClass:"sortable-drag",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",fallbackOnBody:!0,fallbackClass:"sortable-fallback",emptyInsertThreshold:5,invertSwap:!0};return r?{...s,forceFallback:!0,touchStartThreshold:0,fallbackTolerance:5,delay:50}:s}),_=()=>{document.body.classList.add("dragging")},T=()=>{document.body.classList.remove("dragging")},g=K=>{const{oldIndex:r,newIndex:s}=K;if(r===s)return;const S=[...y.value];S.splice(s,0,S.splice(r,1)[0]),y.value=S,U(),document.body.classList.remove("dragging")},a=K=>{y.value.splice(K,1),U()},n=()=>{y.value.push({id:Me(8),type:"",title:"",link:"",key:""}),U()};ye(()=>{y.value=Ne(c.value,(K,r)=>({id:Me(8),type:K.type,title:K.title,link:K.link,key:K.key})),C.value=u});const L=Ce((K,r)=>{const s=y.value,S=K.detail.value.replace(he,""),V=y.value,P=K.detail.value;if(S)s[r].key=S.replace(he,"");else{const Y=V.filter(k=>!k.key.replace(he,"")).length;let O=P==="custom"?Ve.repeat(Y):P;for(;V.includes(O);)O+=Ve;s[r].key=O}y.value=s,U()},300),U=()=>{const K=y.value.filter(r=>r.type&&(h.value||r.title&&r.link));b(l.value,K),f.value=!1,ge(()=>{f.value=!0})};return(K,r)=>{const s=D("ion-select-option"),S=D("ion-select"),V=D("ion-input"),P=D("ion-button"),Y=D("Sortable");return o(),i("div",Vo,[m(Y,{list:e(y),options:e(d),"item-key":"id",tag:"div",onEnd:g,onStart:_,onUnchoose:T,onSort:T},{item:M(({element:O,index:k})=>[t("div",Uo,[r[2]||(r[2]=t("div",{class:"featured-drag-handle d-flex align-items-center"},[t("div",{class:"handle d-flex flex-column align-items-center justify-content-center"},[t("i",{class:"ti-more-alt top-h"}),t("i",{class:"ti-more-alt"})])],-1)),t("div",Eo,[m(S,{modelValue:O.type,"onUpdate:modelValue":W=>O.type=W,mode:"md",class:"c-select bg-white featured-in-key mr-2",placeholder:"Select Type",onIonBlur:U},{default:M(()=>[(o(!0),i(ie,null,fe(e(ht),(W,j)=>(o(),i("div",{key:j},[m(s,{class:ne(["disable-as-group-title",{no:!j}])},{default:M(()=>[Z(H(e(xe)(j)),1)]),_:2},1032,["class"]),(o(!0),i(ie,null,fe(W,(A,ae)=>(o(),z(s,{key:ae,class:ne({"custom-keyword":A==="custom"}),value:A},{default:M(()=>[Z(H(e(xe)(A)),1)]),_:2},1032,["class","value"]))),128))]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"]),O.type==="custom"?(o(),z(V,{key:0,class:"c-input about-key mr-2 w-50",value:(O.key||"").replace(e(he),""),placeholder:"Field Title",onIonInput:W=>e(L)(W,k)},null,8,["value","onIonInput"])):R("",!0),m(V,{modelValue:O.title,"onUpdate:modelValue":W=>O.title=W,class:"c-input mr-2",placeholder:"Enter Title",onIonBlur:U},null,8,["modelValue","onUpdate:modelValue"]),m(V,{modelValue:O.link,"onUpdate:modelValue":W=>O.link=W,class:"c-input",placeholder:"Enter Link",onIonBlur:U},null,8,["modelValue","onUpdate:modelValue"])]),m(P,{class:"inline-button",color:"transparent",onClick:W=>a(k)},{default:M(()=>[...r[1]||(r[1]=[t("i",{class:"ti-trash"},null,-1)])]),_:1},8,["onClick"])])]),_:1},8,["list","options"]),m(P,{class:"add-btn text-white w-100 mt-2",onClick:r[0]||(r[0]=O=>n())},{default:M(()=>[...r[3]||(r[3]=[Z("Add More",-1)])]),_:1})])}}}),Oo=le(Lo,[["__scopeId","data-v-3f3bbe47"]]),Ro={class:"text"},Fo={class:"editor"},Wo=se({__name:"Text",props:{usedKey:{type:String,default:""},value:{type:Object,default:{}}},setup(F){const{changeExtraKey:b}=oe(),$=F,p=de($,"value"),f=de($,"usedKey"),c=pt({title:"",body:"",type:""}),{public:{tinyMCEKey:u}}=st(),l=x(0),h=E(()=>{const{dark:C}=Ge();return C.value}),y=()=>{const C={...p.value,...c};b(f.value,C)};return re(h,()=>{l.value++}
1),re(c,y,{deep:!0}),ye(()=>{c.title=p.value.title,c.body=p.value.body,c.type=p.value.type}),(C,d)=>{const _=D("ion-input"),T=D("Editor");return o(),i("div",Ro,[m(_,{modelValue:e(c).title,"onUpdate:modelValue":d[0]||(d[0]=g=>e(c).title=g),class:"c-input one-input",placeholder:"Add your own section title"},null,8,["modelValue"]),t("div",Fo,[(o(),z(T,{key:e(l),modelValue:e(c).body,"onUpdate:modelValue":d[1]||(d[1]=g=>e(c).body=g),"api-key":`${e(u)}`,init:{height:350,relative_urls:!1,menu:{insert:{title:"Insert",items:"image link media inserttable | charmap emoticons hr  | insertdatetime"}},menubar:"edit view insert format tools table help",plugins:"quickbars advlist autolink lists link image charmap preview anchor searchreplace visualblocks code insertdatetime media table code help wordcount",toolbar:"undo redo | bold italic backcolor forecolor |  blocks | fontfamily |                alignleft aligncenter alignright alignjustify |               bullist numlist outdent indent | removeformat | help",contextmenu:!1,quickbars_insert_toolbar:!1,quickbars_selection_toolbar:"bold italic underline strikethrough link"},placeholder:"Write something!"},null,8,["modelValue","api-key"]))])])}}}),Ko=le(Wo,[["__scopeId","data-v-c395c3e9"]]),Po={class:"text"},jo={class:"editor"},Bo=se({__name:"BodyOnly",props:{usedKey:{type:String,default:""},value:{type:String,default:""},placeholder:{type:String,default:"Body"}},setup(F){const{changeInfoKey:b}=oe(),$=F,p=x(""),{public:{tinyMCEKey:f}}=st(),c=de($,"usedKey"),u=de($,"value");ye(()=>{p.value=u.value}),re(u,h=>{h!==p.value&&(p.value=h)});const l=Ce((h,y)=>{b(h,y)},300,{leading:!1,trailing:!0});return re(p,h=>{l(c.value,h)}),(h,y)=>{const C=D("Editor");return o(),i("div",Po,[t("div",jo,[m(C,{modelValue:e(p),"onUpdate:modelValue":y[0]||(y[0]=d=>we(p)?p.value=d:null),"api-key":`${e(f)}`,init:{height:350,relative_urls:!1,menu:{insert:{title:"Insert",items:"image link media inserttable | charmap emoticons hr  | insertdatetime"}},menubar:"edit view insert format tools table help",plugins:"quickbars advlist autolink lists link image charmap preview anchor searchreplace visualblocks code insertdatetime media table code help wordcount",toolbar:"undo redo | bold italic backcolor forecolor |  blocks | fontfamily |                alignleft aligncenter alignright al
1ignjustify |               bullist numlist outdent indent | removeformat | help",contextmenu:!1,quickbars_insert_toolbar:!1,quickbars_selection_toolbar:"bold italic underline strikethrough link"},placeholder:F.placeholder},null,8,["modelValue","api-key","placeholder"])])])}}}),it=le(Bo,[["__scopeId","data-v-1cb3f678"]]),zo={class:"text"},No={class:"d-flex align-items-start mt-2 w-100 one-row"},qo={class:"d-flex flex-column align-items-center reorder-section"},Go=["onClick"],Ho={key:0},Yo={key:0},Xo={key:1},Qo=["value","max","onBlur","onKeyup"],Jo={class:"w-100"},Zo={class:"d-flex align-items-center"},es={class:"w-100"},ts={key:1},os={key:2,class:"embed-container mt-2"},ss=["src"],ls=["src"],as=["src"],ns=["src"],rs=["src"],is=se({__name:"Music",props:{usedKey:{type:String,default:""},value:{type:String,default:{}},isDragging:{type:Boolean,default:!1},placeholder:{type:String,default:{}}},setup(F){const{hostUrl:b}=St(),$=k=>qt(k||"",{hostUrl:b.value}),{changeExtraKey:p}=oe();Fe();const{isMobSmallScreen:f}=Le(),c=x({}),u=x({}),l=F,h=x(!0),y=de(l,"value"),C=de(l,"usedKey"),d=x([]),_=x(!1),T=x(""),g=E(()=>{const k=f.value,W=typeof navigator<"u"&&(navigator.userAgent.includes("OPR")||navigator.userAgent.includes("Opera")),j={handle:".music-drag-handle",delay:0,animation:150,forceFallback:!k||W,scroll:!0,scrollSensitivity:100,scrollSpeed:15,bubbleScroll:!0,touchStartThreshold:0,fallbackTolerance:3,swapThreshold:.65,dragClass:"sortable-drag",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",fallbackOnBody:!0,fallbackClass:"sortable-fallback",emptyInsertThreshold:5,invertSwap:!0};return W?{...j,forceFallback:!0,touchStartThreshold:0,fallbackTolerance:5,delay:50}:j}),a=()=>{document.body.classList.add("dragging")},n=()=>{document.body.classList.remove("dragging")},w=k=>{const{oldIndex:W,newIndex:j}=k;W!==j&&(d.value.splice(j,0,d.value.splice(W,1)[0]),K(),document.body.classList.remove("dragging"))},L=k=>{c.value[k]=!0,ge(()=>{u.value[k]?.focus(),u.value[k]?.select()})},U=(k,W)=>{const j=W.target,A=lt(j.value,10)-1;c.value[k]=!1,!(A===k||A<0||A>=d.value.length)&&(d.value.splice(A,0,d.value.splice(k,1)[0]),K())},K=(k=!0)=>{p(C.value,d.value),k&&(h.value=!1,ge(()=>{h.value=!0}))},r=k=>{d.value?.splice(k,1),K()},s=()=>{_.value=!0},S=()=>{d.value.push({id:Me(8),label:"",link:""}),K()};ye(()=>{d.value=Ne(y.value,(k,W)=>({id:Me(8),label:k.label,link:k.link,resolvedUrl:k.resolvedUrl})),h.value=!1,ge(()=>{h.value=!0})});const V=(k,W,j)=>{d.value[k][j]=W.target.value,K(!1)},P=k=>k.includes("youtu.be")?k.replace("youtu.be/","www.youtube.com/watch?v="):k.includes("m.youtube.com")?k.replace("m.youtube.com","www.youtube.com"):k.includes("m.soundcloud.com")?k.replace("m.soundcloud.com","soundcloud.com"):k,Y=async(k,W)=>{let j=P(W),A=j;if(j.includes("spotify.link")){const te=await kt(j);te&&te!==j&&(A=te,d.value[k].resolvedUrl=te,d.value[k].link=W)}const ae=await wt(A);ae.isValid?(A.includes("soundcloud")&&(T.value=A,A.includes("on.soundcloud")&&(T.value=ae.full_url,A=ae.full_url,d.value[k].link=A)),Ct(A)&&(d.value[k].embedded=!0)):W!==""&&(d.value[k].embedded=!1,be.show("Invalid link. Please enter a valid YouTube, Spotify, or SoundCloud link.","nonative","danger"),d.value[k].link="")},O=k=>{if(k.includes("playlist")){const A=k.match(/spotify\.com\/playlist\/([^?]+)/);return A?A[1]:""}if(k.includes("album")){const A=k.match(/spotify\.com\/album\/([^?]+)/);return A?A[1]:""}if(k.includes("spotify.com/track/")){const A=k.match(/spotify\.com\/track\/([^?]+)/);return A?A[1]:""}const W=/spotify\.com\/(?:intl-[a-z]{2}\/)?(playlist|album|track)\/([^?]+)/,j=k.match(W);return j?j[2]:""};return(k,W)=>{const j=D("inline-svg"),A=D("ion-input"),ae=D("ion-button"),te=D("Sortable");return o(),i("div",zo,[e(h)?(o(),z(te,{key:0,list:e(d),options:e(g),"item-key":"id",tag:"div",onEnd:w,onStart:a,onUnchoose:n,onSort:n},{item:M(({element:B,index:I})=>[t("div",No,[t("div",qo,[W[1]||(W[1]=t("div",{class:"music-drag-handle d-flex align-items-center"},[t("div",{class:"handle d-flex flex-column align-items-center justify-content-center"},[t("i",{class:"ti-more-alt top-h"}),t("i",{class:"ti-more-alt"})])],-1)),t("div",{class:"order reorder-order d-flex align-items-center justify-content-center",onClick:v=>L(I)},[e(c)[I]?(o(),i("input",{key:1,ref:v=>e(u)[I]=v,type:"number",value:I+1,min:1,max:e(d).length,class:"index-input",onBlur:v=>U(I,v),onKeyup:tt(v=>U(I,v),["enter"]),onClick:W[0]||(W[0]=Ae(()=>{},["stop"]))},null,40,Qo)):(o(),i("span",Ho,[I<99?(o(),i("span",Yo,H(e(nt)(I+1)),1)):(o(),i("span",Xo,H(I+1),1
1))]))],8,Go)]),t("div",Jo,[t("div",Zo,[t("div",es,[!e(_)&&!("get"in k?k.get:e(ue))(B,"label")?(o(),i("div",{key:0,class:"d-flex align-items-center clickable-item-hov",style:{padding:"0.75rem"},onClick:s},[m(j,{src:"/pencil.svg",class:"mr-1 pencil-svg"}),W[2]||(W[2]=t("div",{class:"text-primary"},'Label the song - e.g., "Theme Song" (optional)',-1))])):(o(),i("div",ts,[m(A,{class:"c-input one-input mx-2",value:B.label,modelValue:B.label,"onUpdate:modelValue":v=>B.label=v,placeholder:"Label the song",onIonBlur:v=>V(I,v,"label")},null,8,["value","modelValue","onUpdate:modelValue","onIonBlur"])])),m(A,{class:"c-input one-input mx-2",value:B.link,modelValue:B.link,"onUpdate:modelValue":v=>B.link=v,placeholder:F.placeholder,onIonBlur:v=>{V(I,v,"link"),Y(I,B.link)}},null,8,["value","modelValue","onUpdate:modelValue","placeholder","onIonBlur"]),B.embedded?(o(),i("div",os,[(B.link.includes("youtube")||B.link.includes("youtu.be"))&&$(B.link)?(o(),i("iframe",{key:0,src:$(B.link),style:{"border-radius":"8px"},class:"mb-2",width:"98%",height:"120",title:"YouTube player",frameborder:"0",donotallowfullscreen:"",allow:"clipboard-write; encrypted-media; web-share",referrerpolicy:"no-referrer"},null,8,ss)):(B.resolvedUrl||B.link).includes("spotify")&&(B.resolvedUrl||B.link).includes("playlist")?(o(),i("iframe",{key:1,src:`https://open.spotify.com/embed/playlist/${O(B.resolvedUrl||B.link)}?utm_source=generator`,style:{"border-radius":"8px"},width:"98%",height:"80",title:"Spotify player",frameborder:"0",donotallowfullscreen:"",allow:"clipboard-write; encrypted-media; web-share"},null,8,ls)):(B.resolvedUrl||B.link).includes("spotify")&&(B.resolvedUrl||B.link).includes("album")?(o(),i("iframe",{key:2,src:`https://open.spotify.com/embed/album/${O(B.resolvedUrl||B.link)}?utm_source=generator`,style:{"border-radius":"8px"},width:"98%",height:"80",title:"Spotify player",frameborder:"0",donotallowfullscreen:"",allow:"clipboard-write; encrypted-media; web-share"},null,8,as)):(B.resolvedUrl||B.link).includes("spotify")&&(B.resolvedUrl||B.link).includes("track")?(o(),i("iframe",{key:3,src:`https://open.spotify.com/embed/track/${O(B.resolvedUrl||B.link)}`,style:{"border-radius":"8px"},width:"98%",height:"80",title:"Spotify player",frameborder:"0",donotallowfullscreen:"",allow:"clipboard-write; encrypted-media; web-share"},null,8,ns)):R("",!0),B.link.includes("soundcloud")?(o(),i("iframe",{key:4,src:`https://w.soundcloud.com/player/?url=${encodeURIComponent(B.link)}&color=%23ff5500&auto_play=false&show_user=true`,style:{"border-radius":"8px"},class:"mb-2",width:"98%",height:"120",title:"SoundCloud player",frameborder:"0",allow:"autoplay"},null,8,rs)):R("",!0)])):R("",!0)])])]),m(ae,{class:"inline-button clickable-item-hov",color:"transparent",onClick:v=>r(I)},{default:M(()=>[m(j,{src:"/trash.svg"})]),_:1},8,["onClick"])])]),_:1},8,["list","options"])):R("",!0),m(ae,{class:"add-btn text-white w-100 mt-2",onClick:S},{default:M(()=>[...W[3]||(W[3]=[Z("Add More",-1)])]),_:1})])}}}),cs=le(is,[["__scopeId","data-v-dd108315"]]),us={class:"text"},ds={class:"select-modal-content bg-white w-100"},vs={key:0},ms={class:"bold trait-cat-title no-select"},ps=["id"],fs={slot:"end"},ys={key:0,class:"mr-3 position-relative",style:{bottom:"1px"}},_s={key:1,class:"ti-check bold mr-3"},gs={key:2,class:"ti-plus mr-3 bold"},bs={class:"d-flex align-items-start mt-2 one-row"},hs={class:"d-flex flex-column align-items-center reorder-section"},ks={class:"about-drag-handle d-flex align-items-center"},ws=["onClick"],Cs={key:0},Ss={key:0},$s={key:1},xs=["value","max","onBlur","onKeyup"],Is={class:"data d-flex"},Ms={class:"key-button no-select selector-text"},Ts={class:"rest d-flex flex-grow-1"},Ds={class:"textarea-wrapper"},As=["onClick"],Vs=se({__name:"About",props:{usedKey:{type:String,default:""}},setup(F){const b={HIDDEN:-1,MULTI:-2},{isMobSmallScreen:$}=Le(),{worldAbout:p,setWorldAbout:f}=oe(),{userPro:c}=Te(),u=x(b.HIDDEN),l=x(null),h=x([]),y=x({}),C=x({}),d=x({}),_=x([]),T=E(()=>{const I=$.value,v=typeof navigator<"u"&&(navigator.userAgent.includes("OPR")||navigator.userAgent.includes("Opera")),q={handle:".about-drag-handle",delay:0,animation:150,forceFallback:!I||v,
1scroll:!0,scrollSensitivity:100,scrollSpeed:15,bubbleScroll:!0,touchStartThreshold:0,fallbackTolerance:3,swapThreshold:.65,dragClass:"sortable-drag",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",fallbackOnBody:!0,fallbackClass:"sortable-fallback",emptyInsertThreshold:5,invertSwap:!0};return v?{...q,forceFallback:!0,touchStartThreshold:0,fallbackTolerance:5,delay:50}:q}),g=()=>{document.body.classList.add("dragging")},a=()=>{document.body.classList.remove("dragging")},n=I=>{const{oldIndex:v,newIndex:q}=I;if(v===q)return;const X=[...p.value];X.splice(q,0,X.splice(v,1)[0]),f(X),document.body.classList.remove("dragging")},w=I=>{C.value[I]=!0,ge(()=>{d.value[I]?.focus(),d.value[I]?.select()})},L=(I,v)=>{const q=v.target,X=lt(q.value,10)-1;if(C.value[I]=!1,X===I||X<0||X>=p.value.length)return;const ve=[...p.value];ve.splice(X,0,ve.splice(I,1)[0]),f(ve)},U=(I,v)=>{try{I.target.blur(),document.activeElement?.blur(),document.querySelectorAll(".option").forEach(me=>{me.classList.remove("ion-activated")})}catch{}if(v==="custom"&&p.value?.[u.value]?.isCustom&&u.value!==b.MULTI){u.value=b.HIDDEN;return}if(p.value.map(({key:N})=>N).includes(v)&&v!=="custom"){!p.value.find(N=>N.key===v)?.value&&u.value===b.MULTI&&f(p.value.filter(N=>N.key!==v)),u.value!==b.MULTI&&(u.value=b.HIDDEN);return}const q=[...p.value];
1if(v==="custom"&&q[u.value]?.key.startsWith("custom")||q.map(({key:N})=>N).includes(v)&&v!=="custom")return;const X=q.filter(N=>!N.key.replace(he,"")).length,ve=q.filter(N=>N.key.match(he)).map(N=>N.key.length);let ce=X,pe=0;const _e=100;if(ce>=_e){alert("Maximum of 100 custom fields allowed per section.");return}for(;ve.includes(ce)&&ce<_e;)if(ce++,pe++,pe>=_e){alert("Encountered an error when adding a custom field");return}const Q=Ve.repeat(ce);if(u.value!==b.MULTI)q[u.value].key=v==="custom"?Q:v,f(q),u.value=b.HIDDEN;else{const N={key:v==="custom"?Q:v,value:"",isCustom:v==="custom",id:Me(8)};q.push(N),f(q)}},K=()=>{if(u.value===b.HIDDEN||u.value===b.MULTI)return;const I=xt();if(l){const v=p.value[u.value].key,q=I.value.getElementById("p_"+v);if(q){const X=Object.entries(Oe).find(([ve,ce])=>ce.includes(v))?.[0];X&&y.value[X]?(y.value[X]=!1,setTimeout(()=>{q.scrollIntoView({behavior:"smooth",block:"center"})},250)):q.scrollIntoView({behavior:"smooth",block:"center"})}}},r=I=>{y.value[I]=!y.value[I]},s=E(()=>p.value.filter(I=>I.isCustom).length),S=E(()=>p.value.map(({key:I})=>I)),V=I=>S.value.includes(I),P=I=>{const v=Mt.includes(I);if(!v)return!0;if(!Qe.pro&&v)return!1;if(v&&c.value.moreabout)return!0},Y=I=>{const v=Je.includes(I);if(!v)return!0;if(!Qe.pro&&v)return!1;if(v&&c.value.moreabout)return!0},O=async I=>{if(p.value[I].value?.trim()){if(h.value?.includes(I))return;if(!_.value?.includes(p.value[I].key))if(await je("Replace current text with random suggestion?"))_.value.push(p.value[I].key);else return}else _.value=_.value.filter(v=>v!==p.value[I].key);h.value=[...h.value,I];try{const v=p.value,q=v[I].key;if(q==="custom")return;const X=await It(q);v[I].value=(X||"").trim(),f(v)}catch{}finally{h.value=h.value.filter(v=>v!==I)}},k=I=>{f(p.value.filter(v=>v.key!==I))},W=E(()=>at(Oe,Je));He(Object.values(Oe)),He(Object.values(W.value));const j=()=>{u.value=b.MULTI},ae=Ce((I,v)=>{const q=p.value;q[v].value=I.detail.value||"",f(q),_.value=_.value.filter(X=>X!==q[v].key)},300),B=Ce((I,v)=>{const q=p.value,X=I.detail.value.replace(he,""),ve=p.value,ce=I.detail.value;if(X)q[v].key=X.replace(he,"");else{const pe=ve.filter(Q=>!Q.key.replace(he,"")).length;let _e=ce==="custom"?Ve.repeat(pe):ce;for(;ve.includes(_e);)_e+=Ve;q[v].key=_e}f(q)},300);return(I,v)=>{const q=D("PlusTag"),X=D("ion-item"),ve=D("ion-label"),ce=D("ion-list"),pe=D("ion-button"),_e=D("ion-toolbar"),Q=D("ion-footer"),N=D("ion-modal"),me=D("ion-input"),ke=D("ion-textarea"),Se=D("Sortable");return o(),i("div",us,[m(N,{"is-open":e(u)!=b.HIDDEN,onDidDismiss:v[2]||(v[2]=()=>{u.value=b.HIDDEN}),onDidPresent:K,"show-backdrop":!0,class:"select-modal",ref_key:"pickerModal",ref:l},{default:M(()=>[t("div",ds,[m(ce,{class:"scroll"},{default:M(()=>[m(X,{onClick:v[0]||(v[0]=ee=>e($t)(ee,"worldAddSection")),class:"option"},{default:M(()=>[m(q,{size:"md",class:"mr-2"}),v[4]||(v[4]=Z()),v[5]||(v[5]=t("strong",{class:"no-select"},"See 100+ more trait ideas",-1))]),_:1}),(o(!0),i(ie,null,fe(e(Oe),(ee,J)=>(o(),i("div",{key:J},[Y(J)?(o(),i("div",vs,[e(xe)(String(J))?(o(),z(X,{key:0,onClick:G=>r(J),button:""},{default:M(()=>[m(ve,{class:"pt-4"},{default:M(()=>[t("span",ms,H(e(xe)(String(J))),1),t("i",{class:ne([e(y)[J]?"ti-angle-down":"ti-angle-up","ml-2"])},null,2)]),_:2},1024)]),_:2},1032,["onClick"])):R("",!0),Re(t("div",null,[(o(!0),i(ie,null,fe(ee,(G,ct)=>(o(),i("div",{key:ct,class:"option-container"},[P(G)?(o(),z(X,{key:0,button:"",class:ne(["no-select option",{bold:G==="custom",selected:V(G),"current-selection":e(u)>=0&&e(p)?.[e(u)]?.key===G}]),value:G,onClick:ut=>U(ut,G)},{default:M(()=>[t("div",null,[t("span",{id:"p_"+G,class:"bold modal-about-key"},H(e(xe)(G)),9,ps),v[6]||(v[6]=t("br",null,null,-1)),t("small",null,H(e(Ye)?.[G]||""),1)]),t("span",fs,[G==="custom"&&e(s)?(o(),i("span",ys,H(e(s)),1)):R("",!0),V(G)?(o(),i("i",_s)):(o(),i("i",gs))])]),_:2},1032,["class","value","onClick"])):R("",!0)]))),128))],512),[[ft,!e(y)[J]]])])):R("",!0)]))),128))]),_:1}),m(Q,{class:"ion-no-border"},{default:M(()=>[m(_e,{class:"tbottom"},{default:M(()=>[m(pe,{class:"close-btn",size:"large",expand:"block",onClick:v[1]||(v[1]=ee=>u.value=b.HIDDEN)},{default:M(()=>[...v[7]||(v[7]=[t("span",{class:"no-select"},"Close",-1)])]),_:1})]),_:1})]),_:1})])]),_:1},8,["is-open"]),m(Se,{list:e(p),options:e(T),"item-key":"id",tag:"div",onEnd:n,onStart:g,onUnchoose:a,onSort:a}
1,{item:M(({element:ee,index:J})=>[t("div",bs,[t("div",hs,[t("div",ks,[t("div",{class:ne(["handle d-flex flex-column align-items-center justify-content-center",{"has-custom":ee.isCustom}])},[...v[8]||(v[8]=[t("i",{class:"ti-more-alt top-h"},null,-1),t("i",{class:"ti-more-alt"},null,-1)])],2)]),t("div",{class:"order reorder-order d-flex align-items-center justify-content-center",onClick:G=>w(J)},[e(C)[J]?(o(),i("input",{key:1,ref:G=>e(d)[J]=G,type:"number",value:J+1,min:1,max:e(p).length,class:"index-input",onBlur:G=>L(J,G),onKeyup:tt(G=>L(J,G),["enter"]),onClick:v[3]||(v[3]=Ae(()=>{},["stop"]))},null,40,xs)):(o(),i("span",Cs,[J<99?(o(),i("span",Ss,H(e(nt)(J+1)),1)):(o(),i("span",$s,H(J+1),1))]))],8,ws)]),t("div",Is,[m(pe,{class:ne(["mr-2 mt-0 selector",{custom:ee.isCustom}]),onClick:G=>u.value=J,color:"light",disabled:e(h)?.includes(J)},{default:M(()=>[t("span",Ms,[v[9]||(v[9]=t("span",{style:{"font-size":"1.1rem","user-select":"none !important"}},"▾",-1)),Z(H(ee.isCustom?"Custom":e(xe)(ee.key)),1)])]),_:2},1032,["class","onClick","disabled"]),t("div",Ts,[ee.isCustom?(o(),z(me,{key:0,class:"c-input about-key mr-2",placeholder:"Field Title",value:ee.key?.replace(e(he),""),onIonInput:G=>e(B)(G,J)},null,8,["value","onIonInput"])):R("",!0),t("div",Ds,[ee.key!=="custom"&&!ee.isCustom&&!e(Xe)?.includes(ee.key)?(o(),i("img",{key:0,srcset:"/icons/d6-1x.png 1x, /icons/d6-2x.png 2x, /icons/d6-3x.png 3x",alt:"Randomizer",class:ne(["details-icon",[e(h)?.includes(J)?"rloading":"clickable-item-hov"]]),onClick:G=>O(J)},null,10,As)):R("",!0),m(ke,{"auto-grow":"",modelValue:ee.value,"onUpdate:modelValue":G=>ee.value=G,class:ne([{"w-100":!ee.isCustom,"has-icon":!e(Xe)?.includes(ee.key)&&!ee.isCustom},"c-textarea flex-grow-1 details-text"]),placeholder:e(Ye)[ee.key]||"Details",disabled:e(h)?.includes(J),onIonInput:G=>e(ae)(G,J)},null,8,["modelValue","onUpdate:modelValue","class","placeholder","disabled","onIonInput"])])])]),m(pe,{class:"inline-button clickable-item-hov ml-1",color:"transparent",onClick:G=>k(ee.key)},{default:M(()=>[...v[10]||(v[10]=[t("i",{class:"ti-trash"},null,-1)])]),_:1},8,["onClick"])])]),_:1},8,["list","options"]),m(pe,{class:"add-btn text-white w-100 mt-2",onClick:j},{default:M(()=>[...v[11]||(v[11]=[Z("Add More",-1)])]),_:1})])}}}),Us=le(Vs,[["__scopeId","data-v-535f6107"]]),Es={key:0,class:"text world-editor-select"},Ls={key:0},Os={key:1},Rs={key:2},Fs={class:"d-flex align-items-center mt-2 one-row"},Ws={class:"locations-card px-2 py-2"},Ks=se({__name:"Locations",props:{usedKey:{type:String,default:""},value:{type:Array,default:[]}},setup(F){const{user:b}=Te(),{changeInfoKey:$,storyworld:p}=oe(),{isMobSmallScreen:f}=Le(),c=x(!0),u=x([]),l=x({}),h=E(()=>{const r=f.value,s=typeof navigator<"u"&&(navigator.userAgent.includes("OPR")||navigator.userAgent.includes("Opera")),S={handle:".locations-drag-handle",delay:0,animation:150,forceFallback:!r||s,scroll:!0,scrollSensitivity:100,scrollSpeed:15,bubbleScroll:!0,touchStartThreshold:0,fallbackTolerance:3,swapThreshold:.65,dragClass:"sortable-drag",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",fallbackOnBody:!0,fallbackClass:"sortable-fallback",emptyInsertThreshold:5,invertSwap:!0};return s?{...S,forceFallback:!0,touchStartThreshold:0,fallbackTolerance:5,delay:50}:S}),y=()=>{typeof document<"u"&&document.body.classList.add("dragging")},C=()=>{typeof document<"u"&&document.body.classList.remove("dragging")},d=r=>{const{oldIndex:s,newIndex:S}=r;if(s===S)return;const V=[...n.value];V.splice(S,0,V.splice(s,1)[0]),n.value=V;const P=n.value.filter(Y=>Y);$("subworlds",P.map(Y=>Y.id).filter(Boolean)),typeof document<"u"&&document.body.classList.remove("dragging")},_=()=>{const r=n.value.filter(s=>s);$("subworlds",r.map(s=>s.id).filter(Boolean))},T=r=>r?.name?r.name:r?.info?.name?r.info.name:r?.id?`Location ${r.id}`:"Unknown Location",g=()=>{l.value=qe(u.value)?{header:"Add new Locations by creating more Story Worlds!",message:"Say you're building a world called 'Wizarding World'. If you make another world named 'Hogwarts', you can add it as a Location in 'Wizarding World'. It's like making 'Hogwarts' a part of your 'Wizarding World'!",translucent:!0}:{}},a=async()=>{try{const r=await Tt(b.value.id,"story",1,1e3);u.value=r.results,p.value?.id&&(u.value=u.value.filter(s=>s.id!==p.value.id)),g()}catch{}};ye(async()=>{await a(),n.value&&(n.value=n.value.map((r,s)=>({...r,id:r.id||`location-${s}`}))),c.value=!1,ge(()=>{c.value=!0})});const n=x([]),w=E({get:()=>n.value.map(r=>
1r.id).filter(Boolean),set:r=>{const s=(r||[]).map(S=>u.value.find(P=>P.id===S)||{id:S,name:`Unknown Location ${S}`});n.value=s,_()}}),L=r=>{w.value=r.detail.value||[]},U=r=>{!r||!u.value.length||(n.value=r.map((s,S)=>{if(typeof s=="string"||typeof s=="number"){const V=u.value.find(P=>P.id===s);return V?{...V,id:V.id||`location-${S}`}:{id:s,name:`Loading... ${s}`}}return{...s,id:s.id||`location-${S}`}}))};re(()=>p.value?.subworlds,r=>{U(r)},{immediate:!0}),re(()=>u.value,r=>{r.length>0&&p.value?.subworlds&&U(p.value.subworlds)});const K=r=>{n.value.splice(r,1),_()};return(r,s)=>{const S=D("ion-select-option"),V=D("ion-select"),P=D("ion-button"),Y=D("Sortable");return o(),i(ie,null,[e(c)?(o(),i("div",Es,[m(V,{modelValue:e(w),"onUpdate:modelValue":s[0]||(s[0]=O=>we(w)?w.value=O:null),mode:"md",placeholder:"Link a new Story World as a location for this Story World.",multiple:!0,"interface-options":e(l),class:"bg-white select pr-2",onIonChange:L},{default:M(()=>[(o(!0),i(ie,null,fe(e(u),O=>(o(),z(S,{key:O.id,value:O.id},{default:M(()=>[Z(H(O.name)+" ",1),O.privacy==="M"?(o(),i("span",Ls,"🔒")):O.privacy==="U"?(o(),i("span",Os,"🔗")):O.privacy==="E"?(o(),i("span",Rs,"🛡️")):R("",!0)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue","interface-options"])])):R("",!0),t("div",null,[e(c)?(o(),z(Y,{key:0,list:e(n),options:e(h),"item-key":"id",tag:"div",onEnd:d,onStart:y,onUnchoose:C,onSort:C},{item:M(({element:O,index:k})=>[t("div",Fs,[s[2]||(s[2]=t("div",{class:"locations-drag-handle d-flex align-items-center"},[t("div",{class:"handle d-flex flex-column align-items-center justify-content-center"},[t("i",{class:"ti-more-alt top-h"}),t("i",{class:"ti-more-alt"})])],-1)),t("div",Ws,H(T(O)),1),m(P,{class:"inline-button",color:"transparent",onClick:W=>K(k)},{default:M(()=>[...s[1]||(s[1]=[t("i",{class:"ti-trash"},null,-1)])]),_:1},8,["onClick"])])]),_:1},8,["list","options"])):R("",!0)])],64)}}}),Ps=le(Ks,[["__scopeId","data-v-14058b67"]]),js={class:"modal-content-wrapper"},Bs={class:"modal-header"},zs={class:"mt-3"},Ns={class:"d-flex align-items-center"},qs={class:"mt-2"},Gs={class:"d-flex justify-content-between align-items-center"},Hs={class:"desktop-text"},Ys={class:"mobile-text"},Xs={class:"modal-body"},Qs={key:0,class:"selected-characters-container pt-2"},Js={key:1,class:"no-data"},Zs={class:"mt-3"},el={key:0,class:"selectable-characters mb-3"},tl={key:1,class:"no-data"},ol={class:"modal-footer"},sl={class:"d-flex justify-content-center"},De=100,ll=se({__name:"SelectedCharactersModal",props:{isOpen:{type:Boolean},modalTitle:{type:String,default:"Select characters"},allCharacters:{type:Array,default:()=>[]},worldCharacters:{type:Array,default:()=>[]}},emits:["dismissModal","save"],setup(F,{emit:b}){const $=F,p=E(()=>$.allCharacters),f=E(()=>$.worldCharacters),c=x([]),u=x([]),l=S=>{const{oldIndex:V,newIndex:P}=S,Y=c.value[V];c.value.splice(V,1),c.value.splice(P,0,Y)},h=x(""),y=x({handle:".reorder-handle",animation:150}),C=b,d=()=>{C("dismissModal")},_=S=>c.value.map(({id:V})=>V).includes(S?.id),T=S=>{h.value=S?.target?.value||"",g()},g=Ce(async()=>{a()},500),a=async(S=1,V)=>{try{const P={...V};qe(h.value)||(P.name=h.value);let Y="character";const{results:O,...k}=await rt(Y,S,48,P);u.value=O}catch{console.error("Error searching")}},n=()=>{U.value=!U.value},w=E(()=>{const S=h.value?.toLocaleLowerCase().trim();return S?[...p.value.filter(Y=>Y.slug?.toLocaleLowerCase().includes(S)),...u.value].filter((Y,O,k)=>O===k.findIndex(W=>W.slug===Y.slug)):p.value}),L=(S,V)=>{if(V){if(c.value.length>=De){be.show(`You can only add up to ${De} characters to a story world.`,"nonative","primary",void 0,"top");return}c.value.push(S),c.value=[...new Set(c.value)]}V||(c.value=c.value.filter(({id:P})=>P!==S.id))},U=x(!1),K=E(()=>U.value?"Save order":"Reorder"),r=E(()=>U.value?"success":"primary"),s=()=>{C("save",c),C("dismissModal")};return ye(()=>{c.value=f.value||[]}),re(f,S=>{c.value=S}),(S,V)=>{const P=D("ion-input"),Y=D("ion-button"),O=D("Sortable"),k=D("ion-custom-button"),W=D("modals-layout"),j=D("ion-modal");return o(),z(j,{class:"modal-big","is-open":F.isOpen,mode:"md","backdrop-dismiss":!0,"show-backdrop":!0,onDidDismiss:d},{default:M(()=>[m(W,{data:{title:F.modalTitle},class:"layout",onDismissModal:d},{default:M(()=>[t("div",js,[t("div",Bs,[t("div",zs,[t("div",Ns,[V[0]||(V[0]=t("i",{class:"icon pl-2 ti-search position-absolute"},null,-1)),m(P,{class:"c-input one-input",value:e(h),placeholder:"Search your characters",onInput:T},null,8,["value"])])]),t("div",qs,[t("div",Gs,[t("div",{class:ne(["character-counter",{"character-limit-warning":e(c)?.length>=De*.9}])},[t("span",Hs,H(e(c)?.length||0)+" / "+H(De)+" characters selected",1),t("span",Ys,H(e(c)?.length||0)+" / "+H(De),1)],2),m(Y,{color:e(r),class:"reorder-button",onClick:n},{default:M(()=>[Z(H(e(K)),1)]),_:1},8,["color"])])])]),t("div",Xs,[e(c)?.length?(o(),i("div",Qs,[m(O,{"item-key":"id",tag:"div",class:ne(["sorting",{dov:e(U)}]),list:e(c),options:e(y),onEnd:l},{item:M(({element:A,index:ae})=>[(o(),z(Be,{key:ae,class:"selectable-grid-item",character:A,"is-selected":_(A),"image-only":"","is-selectable":"","is-removable":"",hideTypeTag:"","
1is-reorderable":e(U),onSelect:te=>L(A,te)},null,8,["character","is-selected","is-reorderable","onSelect"]))]),_:1},8,["list","options","class"])])):(o(),i("div",Js,"Select characters to reorder")),t("div",Zs,[e(p).length?(o(),i("div",el,[m(We,{scrollSm:!1},{default:M(()=>[(o(!0),i(ie,null,fe(e(w),(A,ae)=>(o(),z(Be,{key:ae,class:"grid-item",character:A,"is-selectable":"","is-selected":_(A),limited:"","hide-privacy-text":"",onSelect:te=>L(A,te)},null,8,["character","is-selected","onSelect"]))),128))]),_:1})])):(o(),i("div",tl,"No characters"))])]),t("div",ol,[t("div",sl,[m(k,{color:"medium",class:"action-btn",onClick:d},{default:M(()=>[...V[1]||(V[1]=[Z("Cancel",-1)])]),_:1}),m(k,{color:"primary",class:"ml-3 action-btn",onClick:s},{default:M(()=>[...V[2]||(V[2]=[Z("Save",-1)])]),_:1})])])])]),_:1},8,["data"])]),_:1},8,["is-open"])}}}),al=le(ll,[["__scopeId","data-v-2f45ef7a"]]),nl={key:0,class:"text world-editor-select"},rl={class:"d-flex justify-content-end"},il={key:0,class:"characters-scroll-container"},cl={key:1,class:"no-data"},ul=se({__name:"Characters",props:{usedKey:{type:String,default:""},value:{type:Array,default:()=>[]}},setup(F){const{user:b}=Te(),{changeInfoKey:$,storyworld:p}=oe(),f=F,c=x(!1),u=x(!0),l=de(f,"usedKey"),h=E(()=>_.value?.length?"Edit/Reorder":"Add characters"),y=T=>{$(l.value,T)},C=x([]),d=async()=>{try{const T=await At(b.value.id,null,{incl_u_m:!0,incl_co:!0},{skipEtag:!0});C.value=T}catch{}};ye(async()=>{Dt(Vt.myCreationsCharacters),await d(),u.value=!1,ge(()=>{u.value=!0})});const _=E(()=>p.value?.character_worlds);return(T,g)=>{const a=D("ion-button");return e(u)?(o(),i("div",nl,[t("div",rl,[m(a,{class:"edit-btn",onClick:g[0]||(g[0]=n=>c.value=!0)},{default:M(()=>[Z(H(e(h)),1)]),_:1})]),e(_)?.length?(o(),i("div",il,[m(We,{lg:3,md:3,sm:2,scrollSm:!1},{default:M(()=>[(o(!0),i(ie,null,fe(e(_),(n,w)=>(o(),z(Be,{key:w,class:"grid-item",character:n,hidePopover:"",hideTypeTag:""},null,8,["character"]))),128))]),_:1})])):(o(),i("div",cl,"No characters in this world yet")),m(al,{"all-characters":e(C),"world-characters":e(_),"is-open":e(c),onDismissModal:g[1]||(g[1]=n=>c.value=!1),onSave:y},null,8,["all-characters","world-characters","is-open"])])):R("",!0)}}}),dl=le(ul,[["__scopeId","data-v-fe27165d"]]),vl={class:"modal-content-wrapper"},ml={class:"modal-header"},pl={class:"d-flex justify-content-end"},fl={class:"mt-3"},yl={class:"d-flex align-items-center"},_l={class:"mt-2"},gl={class:"d-flex justify-content-end"},bl={class:"modal-body"},hl={key:0,class:"selected-folders-container pt-2"},kl={class:"mt-3"},wl={key:0,class:"selectable-folders mb-3"},Cl={class:"d-flex justify-content-center"},Sl={key:1,class:"no-data"},$l={class:"modal-footer"},xl={class:"d-flex justify-content-center"},Il=se({__name:"SelectedFoldersModal",props:{isOpen:{type:Boolean},modalTitle:{type:String,default:"Select folders"},allFolders:{type:Object,default:()=>({data:[],count:0,page:1,hasMore:!0})},worldFolders:{type:Array,default:()=>[]}},emits:["dismissModal","save","loadMore"],setup(F,{emit:b}){const $=F,p=E(()=>$.allFolders),f=E(()=>$.worldFolders),c=x([]),u=s=>{const{oldIndex:S,newIndex:V}=s,P=c.value[S];c.value.splice(S,1),c.value.splice(V,0,P)},l=x(""),h=x({handle:".reorder-handle",animation:150}),y=b,C=()=>{y("dismissModal")},d=s=>c.value.map(({id:S})=>S).includes(s?.id),_=()=>{w.value=!w.value},T=E(()=>l.value?p.value.results.filter(s=>s.slug?.toLocaleLowerCase().includes(l.value)):p.value.results),g=E(()=>p.value.hasMore),a=x(!1),n=(s,S)=>{S&&(c.value.push(s),c.value=[...new Set(c.value)]),S||(c.value=c.value.filter(({id:V})=>V!==s.id))},w=x(!1),L=E(()=>w.value?"Save order":"Reorder"),U=E(()=>w.value?"success":"primary"),K=()=>{y("save",c.value),y("dismissModal")},r=()=>{a.value=!0,y("loadMore"),setTimeout(()=>{a.value=!1},1e3)};return ye(()=>{c.value=f.value||[]}),re(f,s=>{c.value=s}),(s,S)=>{const V=D("ion-input"),P=D("ion-button"),Y=D("Sortable"),O=D("ion-custom-button"),k=D("modals-layout"),W=D("ion-modal");return o(),z(W,{class:"modal-big","is-open":F.isOpen,mode:"md","backdrop-dismiss":!0,"show-backdrop":!0,onDidDismiss:C},{default:M(()=>[m(k,{data:{title:F.modalTitle},class:"layout",onDismissModal:C},{default:M(()=>[t("div",vl,[t("div",ml,[t("div",pl,[t("div",null,H(e(c)?.length||0)+" selected",1)]),t("div",fl,[t("div",yl,[S[1]||(S[1]=t("i",{class:"icon pl-2 ti-search position-absolute"},null,-1)),m(V,{class:"c-input one-input",value:e(l),placeholder:"Search your folders",onInput:S[0]||(S[0]=j=>l.value=j.target.value)},null,8,["value"])])]),t("div",_l,[t("div",gl,[m(P,{color:e(U),class:"reorder-button",onClick:_},{default:M(()=>[Z(H(e(L)),1)]),_:1},8,["color"])])])]),t("div",bl,[e(c)?.length?(o(),i("div",hl,[m(Y,{"item-key":"id",tag:"div",class:ne(["sorting",{dov:e(w)}]),list:e(c),options:e(h),onEnd:u},{item:M(({element:j,index:A})=>[(o(),z(ze,{key:A,class:"selectable-grid-item",folder:j,"is-selected":d(j),"image-only":"","is-selectable":"","is-removable":"","is-reorderable":e(w),onSelect:ae=>n(j,ae)},null,8,["folder","is-selected","is-reorderable","onSelect"]))]),_:1},8,["class","list","options"])])):R("",!0),t("div",kl,[e(T).length?(o(),i("div",wl,[m(We,{scrollSm:!1},{default:M(()=>[(o(!0),i(ie,null,fe(e(T),(j,A)=>(o(),z(ze,{key:A,class:"grid-item",folder:j,"is-selectable":"",bordered:"","is-selected":d(j),limited:"","hide-privacy-text":"","hide-folder-icon":"",onSelect:ae=>n(j,ae)},null,8,["folder","is-selected","onSelect"]))),128))]),_:1}),t("div",Cl,[e(g)&&!e(l)?(o(),z(P,{key:0,color:"medium",fill:"outline",class:"load-more-btn mt-3",disabled:e(a),onClick:r},{default:M(()=>[Z(H(e(a)?"Loading...":"Load More"),1)]),_:1},8,["disabled"])):R("",!0)])])):(o(),i("div",Sl,"No folders"))])]),t("div",$l,[t("div",xl,[m(O,{color:"primary",class:"mr-2 action-btn",onClick:K},{default:M(()=>[...S[2]||(S[2]=[Z("Save",-1)])]),_:1}),m(O,{color:"medium",class:"action-btn",onClick:C},{default:M(()=>[...S[3]||(S[3]=[Z("Cancel",-1)])]),_:1})])])])]),_:1},8,["data"])]),_:1},8,["is-open"])}}}),Ml=le(Il,[["__scopeId","data-v-0c222e57"]]),Tl={key:0,class:"text world-editor-select"},Dl={class:"d-flex justify-content-end"},Al={key:0},Vl={key:1,class:"no-data"},Ul=se({__name:"Folders",props:{usedKey:{type:String,default:""},value:{type:Array,default:()=>[]}}
1,setup(F){const{changeInfoKey:b,storyworld:$}=oe(),p=F,f=x(!1),c=x(!0),u=de(p,"usedKey"),l=E(()=>_.value?.length?"Edit/Reorder":"Add folders"),h=T=>{b(u.value,T)},y=x({results:[],count:0,page:1,hasMore:!0}),C=async(T=1,g=!1)=>{try{const a=await rt("folder",T,12);g?y.value.results=[...y.value.results,...a.results]:y.value.results=a.results,y.value.count=a.count,y.value.page=T,y.value.hasMore=y.value.results.length<a.count}catch{}},d=async()=>{y.value.hasMore&&await C(y.value.page+1,!0)};ye(async()=>{await C(),c.value=!1,ge(()=>{c.value=!0})});const _=E(()=>$.value?.featured_collections);return(T,g)=>{const a=D("ion-button");return e(c)?(o(),i("div",Tl,[t("div",Dl,[m(a,{class:"edit-btn",onClick:g[0]||(g[0]=n=>f.value=!0)},{default:M(()=>[Z(H(e(l)),1)]),_:1})]),e(_)?.length?(o(),i("div",Al,[m(We,{lg:3,md:3,sm:2,scrollSm:!1},{default:M(()=>[(o(!0),i(ie,null,fe(e(_),(n,w)=>(o(),z(ze,{key:w,class:"grid-item",folder:n},null,8,["folder"]))),128))]),_:1})])):(o(),i("div",Vl,"No folders in this world yet")),m(Ml,{"all-folders":e(y),"world-folders":e(_),"is-open":e(f),onDismissModal:g[1]||(g[1]=n=>f.value=!1),onSave:h,onLoadMore:d},null,8,["all-folders","world-folders","is-open"])])):R("",!0)}}}),El=le(Ul,[["__scopeId","data-v-0800b221"]]),Ll={class:"story-world-sections position-relative"},Ol={key:0,class:"text"},Rl={key:1,class:"text"},Fl={key:2,class:"text"},Wl={key:3,class:"text"},Kl={key:4,class:"text"},Pl={key:5,class:"text"},jl={key:6,class:"text"},Bl={key:7,class:"text"},zl={key:8,class:"text"},Nl={key:9,class:"text"},ql=se({__name:"Sections",setup(F){const{storyworld:b,markAsDirty:$}=oe(),p=x(!0),f=Ue(),c=(T,g)=>Ie[T]||Ee[T]||ot(g.type)||"",u=E(()=>f.name==="create-social-space"||f.name==="edit-social-space"?"world":!b.value?.id||f.name==="world-draft-details"?"world_draft":"world"),l=(T,g,a)=>g==="extra"||g==="included_locations"||g==="spotify_link"&&a?!1:T||T==="",h=x(0),y=E(()=>{const{dark:T}=Ge();return T.value});re(y,()=>{h.value++});const C=E(()=>at(b?.value,Ut,"order","included_locations")),d=E(()=>b?.value?.extra?.order||Object.keys(C.value||{}));re(d,()=>{h.value++});const _=E(()=>(d.value||[]).map(a=>({key:a,value:l(C.value[a],a,!0)?C.value[a]:C.value.extra[a]})));return(T,g)=>(o(),i("div",Ll,[e(p)?(o(!0),i(ie,{key:0},fe(e(_),(a,n)=>(o(),i(ie,{key:`_${a.key}`},[l(a.value,a.key,!1)?(o(),z(xo,{key:0,class:"mb-4",title:c(a.key,a.value),index:n,"used-key":a.key},{default:M(()=>[a.key==="description"?(o(),i("div",Ol,[(o(),z(it,{key:e(h),value:a.value,"used-key":a.key,placeholder:"Design worlds no GPS can find. Yet."},null,8,["value","used-key"]))])):R("",!0),a.key==="spotify_link"?(o(),i("div",Rl,[m(cs,{value:a.value,"used-key":a.key,placeholder:"Add Spotify or Youtube or SoundCloud link"},null,8,["value","used-key"])])):R("",!0),a.key==="subworlds"||a.key==="included_locations"?(
1o(),i("div",Fl,[(o(),z(Ps,{key:e(h),value:a.value,"used-key":a.key},null,8,["value","used-key"]))])):R("",!0),a.value.type==="text"?(o(),i("div",Wl,[(o(),z(Ko,{key:e(h),value:a.value,"used-key":a.key},null,8,["value","used-key"]))])):R("",!0),a.key==="colors"?(o(),i("div",Kl,[m(Ao,{"used-key":a.key},null,8,["used-key"])])):R("",!0),a.key==="visual_collections_page"?(o(),i("div",Pl,[m(Gt,{"is-editor":!0,"parent-type":e(u),"parent-id":e(b)?.id,onTouched:e($),"used-key":"world_gallery",key:"inline-gallery-editorsw"},null,8,["parent-type","parent-id","onTouched"]),g[0]||(g[0]=t("div",{style:{height:"10px"}},null,-1))])):R("",!0),a.key==="about"?(o(),i("div",jl,[m(Us,{"used-key":a.key},null,8,["used-key"])])):R("",!0),a.key==="featuredin"?(o(),i("div",Bl,[m(Oo,{value:a.value,"used-key":a.key},null,8,["value","used-key"])])):R("",!0),a.key==="character_worlds"?(o(),i("div",zl,[m(dl,{value:a.value,"used-key":a.key},null,8,["value","used-key"])])):R("",!0),a.key==="featured_collections"?(o(),i("div",Nl,[m(El,{value:a.value,"used-key":a.key},null,8,["value","used-key"])])):R("",!0)]),_:2},1032,["title","index","used-key"])):R("",!0)],64))),128)):R("",!0)]))}}),Gl=le(ql,[["__scopeId","data-v-22474fe3"]]),Hl={class:"story-world-add-section position-relative mb-4"},Yl={class:"d-flex justify-content-between align-items-center h-100"},Xl={key:0,class:"ti-angle-up icon"},Ql={key:1,class:"ti-angle-down icon"},Jl={key:0,class:"options-wrapper"},Zl={class:"options"},ea=["onClick"],ta={key:0,class:"m-0"},oa=se({__name:"AddSection",setup(F){const{addSection:b,storyworld:$}=oe(),p=Ue(),f=d=>d||d==="",c=E(()=>{const d=$?.value?.extra.order.filter(a=>f($?.value?.[a])),_=Object.keys($?.value?.extra||{}).filter(a=>f($.value?.extra[a])),T=Object.keys(Ie).reduce((a,n)=>d?.includes(n)?a:{...a,[n]:Ie[n]},{}),g=Object.keys(Ee).reduce((a,n)=>_.includes(n)?a:{...a,[n]:Ee[n]},{});return{text:"Custom Section",...T,...g}}),u=x(!1),l=x(!1),h=()=>{u.value=!u.value},y=d=>{p.name==="edit-world"?l.value=!0:l.value=!1,b(`${d}`,l.value),h()},C=(d,_)=>d<Object.keys(_).length;return(d,_)=>{const T=D("ion-button");return o(),i("div",Hl,[t("div",{class:"select-like",onClick:h},[t("div",Yl,[_[0]||(_[0]=t("div",null,null,-1)),_[1]||(_[1]=t("div",{class:"title d-flex align-items-center"},[t("i",{class:"ti-plus icon mr-1"}),Z(" Add Section ")],-1)),m(T,{class:"arrow-btn"},{default:M(()=>[e(u)?(o(),i("i",Xl)):(o(),i("i",Ql))]),_:1})])]),e(u)?(o(),i("div",Jl,[t("div",Zl,[(o(!0),i(ie,null,fe(e(c),(g,a,n)=>(o(),i("div",{key:a}
1,[t("div",{class:"one-option d-flex align-items-center",onClick:w=>y(a)},H(g),9,ea),C(n,e(Ie))?(o(),i("hr",ta)):R("",!0)]))),128))])])):R("",!0)])}}}),sa=le(oa,[["__scopeId","data-v-08277081"]]),la={class:"story-world-actions position-relative"},aa={class:"justify-content-center d-flex"},na={key:1,class:"white"},ra={key:1},ia={key:0,class:"d-flex justify-content-center mt-4"},ca=se({__name:"Actions",setup(F){const{user:b}=Te(),$=Et(),p=Ue(),f=x(!1),c=x(""),{storyworld:u,saveAsDraft:l,autosaveDraft:h,autosaveDraftNew:y,autosaveWorld:C,deleteWorld:d,deleteWorldDraft:_,publish:T,autosaveEnabled:g,isDirty:a,isDone:n,isDraft:w,isSaving:L,markIsDone:U,clearAll:K}=oe(),r=E(()=>u?.value?.id),s=E(()=>!r.value),S=E(()=>{const Q=u.value?.author?.id||u.value?.user?.id||u.value?.user_id;return!Q||Q===b.value?.id}),V=x(null),P=x(null),Y=E(()=>u?.value?.privacy==="M"?"Save":"Publish"),O=x(null),k=x(0),W=x(0),j=x(0),A=x(null),ae=()=>{if(k.value===0)return 3e3;const N=3e3*Math.pow(2,k.value);return Math.min(N,6e5)},te=x(null),B=x(null),I=async()=>{if(n.value||!g.value||!a.value||L.value||f.value)return;if($.isAutosaveDeferred){te.value&&clearTimeout(te.value),te.value=setTimeout(()=>{te.value=null,I()},1500);return}if(Date.now()<j.value||(O.value&&await O.value,n.value||!g.value||!a.value)||L.value||f.value)return;W.value=Date.now(),B.value||(B.value=Lt());const N=B.value;O.value=(async()=>{try{w.value?s.value?await y(N):await h():await C(),k.value=0,j.value=0,B.value=null,A.value&&(clearTimeout(A.value),A.value=null)}catch{k.value++;const ke=ae();if(j.value=Date.now()+ke,k.value>=10){const{setAutosaveEnabled:Se}=oe();Se(!1),B.value=null,be.show("Autosave disabled due to connection issues.","nonative","danger");return}A.value&&clearTimeout(A.value),A.value=setTimeout(()=>{A.value=null,I()},ke)}finally{O.value=null}})(),await O.value},v=Ce(I,3e3,{leading:!1,trailing:!0,maxWait:1e4}),q=async()=>{f.value=!0,c.value="delete";try{const Q=await Ot.create({cssClass:"",header:"Are you sure?",message:"Please confirm that you want to delete this world.",buttons:[{text:"Cancel",role:"cancel",cssClass:"text-secondary",id:"cancel-button"},{text:"Delete",id:"confirm-button",role:"ok",cssClass:"text-secondary"}]});await Q.present();const{role:N}=await Q.onDidDismiss();N==="ok"&&(U(),r.value&&(p.name==="draft-story-world"||w.value?await _():await d()))}catch{be.show("Encountered an error - please try again later.","nonative","danger")}},X=async()=>{pe(!0)},ve=l,ce=async()=>{pe(!1)},pe=async(Q=!1)=>{if(!(L.value||f.value)){v.cancel(),te.value&&(clearTimeout(te.value),te.value=null),A.value&&(clearTimeout(A.value),A.value=null),f.value=!0,c.value=Q?"saveAsDraft":"publish",U();try{if(!u.value?.name){await be.show("Story world name is required","nonative","danger");return}if(Q){if(!await ve())return;await be.show("Successfully saved.","nonative","success")}else{const N=await T();if(!N)return;await be.show("Successfully saved.","nonative","success");const me=Fe();await Yt(me,"world",{name:"world-details",params:{slug:N}}),K(),Xt()}}catch(N){N.response?.status===400&&N.response?.data.err_code==="cannot_update"?be.show("You cannot publish NSFW content.","nonative","danger"):await be.show("Error saving world, please try again later","nonative","danger")}finally{f.value=!1}}},_e=E(()=>{const{name:Q}=Ue();return!!(w.value||Q==="draft-story-world"||Q==="create-story-world"&&s.value)});return ye(()=>{const Q=vt();let N=!1,me=!1;const ke=()=>{!V.value&&!P.value&&(V.value=re(()=>Q.$state,v,{deep:!0}),P.value=re(()=>$.$state,v,{deep:!0}))},Se=()=>{N&&me&&ke()},ee=re(()=>Q.contentFullyLoaded,G=>{G&&(me=!0,Se(),ee())},{immediate:!0});setTimeout(()=>{N=!0,Se()},5e3);const J=G=>{if(L.value)return G.preventDefault(),G.returnValue="Save in progress. Leaving now may cause data loss.",G.returnValue};window.addEventListener("beforeunload",J),Pe(()=>{window.removeEventListener("beforeunload",J)})}),Pe(()=>{V.value&&V.value(),P.value&&P.value(),v.cancel(),A.value&&(clearTimeout(A.value),A.value=null),te.value&&(clearTimeout(te.value),te.value=null)}),(Q,N)=>{const me=D("ChLoading"),ke=D("ion-button");return o(),i("div",la,[t("div",aa,[e(_e)?(o(),z(ke,{key:0,class:"btn mr-3 save-draft-button",disabled:e(L)||e(c)==="saveAsDraft"&&e(f),onClick:X},{default:M(()=>[e(c)==="saveAsDraft"&&e(f)?(o(),z(me,{key:0,size:"sm"})):(o(),i("div",na,H(e(L)?"Saving...":"Save as Draft"),1))]),_:1},8,["disabled"])):R("",!0),("get"in Q?Q.get:e(ue))(e(b),"is_email_verified",!0)||e(u)?.privacy==="M"?(o(),z(ke,{key:1,class:"btn",disabled:e(L)||e(c)==="publish"&&e(f),onClick:ce},{default:M(()=>[e(c)==="publish"&&e(f)?(o(),z(me,{key:0,size:"sm"})):(o(),i("div",ra,H(e(L)?"Saving...":e(Y)),1))]),_:1},8,["disabled"])):(o(),z(Ht,{key:2}))]),!e(s)&&e(S)?(o(),i("span",ia,[t("span",{class:"delete-btn",onClick:q},"Delete")])):R("",!0)])}}}),ua=le(ca,[["__scopeId","data-v-0ddc66ef"]]),da={key:0,class:"text"},va={key:0,class:"mt-0"},ma={key:1},pa={class:"placeholder"},fa={key:1},ya=se({__name:"Collections",props:{usedKey:{type:String,default:""},value:{type:Array,default:[]}},setup(F){const{user:b}=Te(),{changeInfoKey:$,isDraft:p}=oe(),f=F,c=x(!0),u=de(f,"value"),l=x(!1);let h=x([]),y=x([]);const C=x([]),d=async()=>{try{const n=await Rt(b.value.id,1,{page_size:1e3});C.value=n.results||n}catch{}};ye(async()=>{await d(),h.value=u.value,y.value=u.value.map(n=>C.value.find(w=>w.id===n)?.name||"Unknown"),c.value=!1,ge(()=>{c.value=!0})});const _=()=>{l.value=!0},T=()=>{l.value=!1},g=async n=>{C.value=n,y.value=h.value.map(L=>n.find(U=>U.id===L)?.name||"Unknown");const w=n.map(L=>L.id);h.value=h.value.filter(L=>w.includes(L)),$("world_collections",h.value)},a=async n=>{let w=n.map(L=>{const U=C.value.find(K=>K.id===L);return U?U.name:null});if(w.some(L=>L===null))try{await d(),w=n.map(L=>{const U=C.value.find(K=>K.id===L);return U?U.name:"Unknown"})}catch{console.error("Failed to refresh collections"),w=w.map(U=>U||"Unknown")}y.value=w,h.value=n,$("world_collections",n)};return(n,w)=>{const L=D("ion-icon");return e(c)?(o(),i("div",da,[w[1]||(w[1]=t("div",{class:"title mb-3"},"Add to folder",-1)),e(p)?(o(),i("div",va,[...w[0]||(w[0]=[t("small",null,"(Will be added to folder after this draft is published)",-1)])])):(o(),i("div",ma,[e(C).length?(o(),i("div",{key:0,class:"custom-select bg-white select pr-2 text",onClick:_},[t("span",pa,H(e(y).length?e(y).join(", "):"Select folders you want your character to be a part of"),1),m(L,{name:"chevron-down-outline"})])):(o(),i("span",fa,"Folders let you organize your characters and worlds!")),e(l)?(o(),z(zt,{key:2,isOpen:e(l),collections:e(C),selectedCollections:e(h),onClose:T,onUpdateSelected:a,onUpdateCollections:g},null,8,["isOpen","collections","selectedCollections"])):R("",!0)]))])):R("",!0)}}}),_a=le(ya,[["__scopeId","data-v-1b6b2680"]]),ga={class:"story-world-settings position-relative"},ba={class:"d-flex align-items-center ml-5"},ha={class:"clickable-item-hov"},ka={key:0,class:"ti-angle-down mr-1 toggle-icon"},wa={key:1,class:"ti-angle-up mr-1 toggle-icon"},Ca={key:0,class:"px-2 mt-3"},Sa={class:"text mt-3"},$a={key:0,class:"d-flex align-items-center mt-2"},xa={key:1,class:"d-flex align-items-center mt-2"},Ia={style:{"font-size":"10px",color:"grey"}},Ma={class:"d-flex align-items-center mt-3"},Ta={class:"d-flex align-items-center mt-4"},Da={class:"d-flex align-items-center mt-4"},Aa={class:"d-flex align-items-center mt-4"},Va=se({__name:"Settings",setup(F){const{storyworld:b,changeInfoKey:$,dropdownCollapsed:p,collapseDropDown:f,isDraft:c}=oe(),u=Fe(),{user:l}=Te(),h=x(0),y=x(!1),C=x(!1),d=()=>{C.value=!0},_=()=>{C.value=!1},T=E(()=>{const{dark:r}=Ge();return r.value});re(T,()=>{h.value++});const g=()=>{let r=a.value;r=!r,f(r)},a=E(()=>p.value||!1),n=E({get(){return b.value?.is_nsfw||!1},set(r){$("is_nsfw",r)}}),w=E({get(){return b.value?.privacy||"P"},set(r){$("privacy",r)}}),L=r=>{$("privacy",r)}
1,U=E({get(){if(ue(b.value,"triggerwarning"))return ue(b.value,"triggerwarning")},set(r){$("triggerwarning",r)}}),K=E(()=>b.value?.world_collections);return(r,s)=>{const S=D("ion-radio"),V=D("ion-radio-group"),P=D("ion-icon"),Y=Qt,O=et("new-tab");return o(),i("div",ga,[t("div",null,[s[15]||(s[15]=t("div",{class:"header"},[Z(" Mark this world as mature "),t("a",{class:"link",target:"_blank",href:"https://docs.google.com/document/d/1xSdAdkRj7n8BfJuz0KKPiM2IJTi8MiAVePruZqr4Gag/edit#heading=h.sqkkh44ifgqo"},"(see content guidelines)")],-1)),m(V,{modelValue:e(n),"onUpdate:modelValue":s[1]||(s[1]=k=>we(n)?n.value=k:null),class:"d-flex mt-3 ml-2",mode:"md"},{default:M(()=>[t("div",{onClick:s[0]||(s[0]=()=>y.value=!0),class:"d-flex align-items-center"},[m(S,{disabled:e(u).currentRoute.value.name==="draft-story-world"||e(b)?.privacy==="M"?!1:e(u).currentRoute.value.name==="edit-world"?e(l).is_nsfw||e(l).show_nsfw?!e(l).is_nsfw&&!e(l).show_nsfw&&e(n):!0:!(e(l).is_nsfw||e(l).show_nsfw),class:"mr-1",value:!0},null,8,["disabled"]),s[10]||(s[10]=Z("Yes ",-1))]),t("div",ba,[m(S,{disabled:e(u).currentRoute.value.name==="draft-story-world"||e(b)?.privacy==="M"?!1:e(u).currentRoute.value.name==="edit-world"?e(l).is_nsfw||e(l).show_nsfw?!e(l).is_nsfw&&!e(l).show_nsfw&&e(n):!0:!(e(l).is_nsfw||e(l).show_nsfw),value:!1,class:"mt-1 mr-1"},null,8,["disabled"]),s[11]||(s[11]=Z("No ",-1))])]),_:1},8,["modelValue"]),!(e(u).currentRoute.value.name==="draft-story-world"||e(b)?.privacy==="M")&&!(e(l).is_nsfw||e(l).show_nsfw)?(o(),i("div",{key:0,class:"d-flex align-items-center p-2 my-2",style:$e([{height:"30px"},e(y)?"background: #ffc409 !important":""])},[m(P,{class:"mr-1",style:{"font-size":"12px !important"},icon:e(Ke)},null,8,["icon"]),t("p",{style:$e([{"font-size":"10px",color:"grey"},e(y)?"font-weight: bold":""])},[s[13]||(s[13]=Z(" You must turn on “show mature content” and confirm you’re 18+ in ",-1)),Re((o(),z(Y,{style:$e(e(y)?"font-weight: bold":""),to:"/account/user-settings"},{default:M(()=>[...s[12]||(s[12]=[t("strong",{class:"clickable-item-hov"},"Content Settings",-1)])]),_:1},8,["style"])),[[O]]),s[14]||(s[14]=Z(" to share mature content ",-1))],4)],4)):R("",!0)]),s[27]||(s[27]=t("hr",{class:"my-4"},null,-1)),m(yt,{name:"slide-fade",mode:"out-in"},{default:M(()=>[t("div",null,[t("div",{class:"d-flex justify-content-between align-items-center clickable-item-hov",onClick:g},[s[16]||(s[16]=t("div",{class:"header"},"Advanced Settings",-1)),s[17]||(s[17]=t("div",null,null,-1)),t("div",ha,[e(a)?(o(),i("i",ka)):(o(),i("i",wa))])]),e(a)?R("",!0):(o(),i("div",Ca,[m(_a,{value:e(K)},null,8,["value"]),t("div",Sa,[s[18]||(s[18]=t("div",{class:"title bold mb-3"},"Trigger warning",-1)),(o(),z(it,{key:e(h),value:e(U),placeholder:"(Optional) This is a pop-up warning for sensitive or triggering topics that are on your world's page","used-key":"triggerwarning"},null,8,["value"]))]),e(b)?.id?(o(),z(Nt,{key:0,class:"mt-3",entity:e(b),"entity-type":e(c)?"world_draft":"world"},null,8,["entity","entity-type"])):R("",!0)]))])]),_:1}),s[28]||(s[28]=t("hr",{class:"my-4"},null,-1)),t("div",null,[s[26]||(s[26]=t("div",{class:"header"},"Privacy",-1)),("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?e(n)&&!e(l).is_nsfw&&!e(l).show_nsfw&&e(u).currentRoute.value.name!=="draft-story-world"?(o(),i("div",xa,[m(P,{class:"mr-1",style:{"font-size":"12px !important"},icon:e(Ke)},null,8,["icon"]),t("p",Ia,[s[21]||(s[21]=Z(" You can not post mature content publicly until you confirm you're 18+ in ",-1)),Re((o(),z(Y,{to:"/account/user-settings"},{default:M(()=>[...s[20]||(s[20]=[t("strong",{class:"clickable-item-hov"},"Content Settings",-1)])]),_:1})),[[O]])])])):R("",!0):(o(),i("div",$a,[m(P,{class:"mr-1",style:{"font-size":"12px !important"},icon:e(Ke)},null,8,["icon"]),s[19]||(s[19]=t("p",{style:{"font-size":"10px",color:"grey"}},"Verify your email to post publicly.",-1))])),m(V,{modelValue:e(w),"onUpdate:modelValue":s[9]||(s[9]=k=>we(w)?w.value=k:null),class:"d-flex flex-column ml-2",mode:"md"},{default:M(()=>[t("div",Ma,[m(S,{value:"M",class:"mr-1 clickable-item-hov"}),t("div",{class:"d-flex flex-column clickable-item-hov no-select",onClick:s[2]||(s[2]=k=>L("M"))},[...s[22]||(s[22]=[t("div",{class:"bold"},"Private",-1),t("div",{class:"msg"},"🔒 Upload your story world for personal use. Only you can see your story world.",-1)])])]),t("div",Ta,[t("div",{onClick:s[3]||(s[3]=()=>("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?null:d())},[m(S,{disabled:!(("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)&&(e(u).currentRoute.value.name==="draft-story-world"||e(l).is_nsfw||e(l).show_nsfw||!e(l).is_nsfw&&!e(l).show_nsfw&&!e(n))),value:"U",class:"mr-1 clickable-item-hov"},null,8,["disabled"])]),t("div",{class:"d-flex flex-column clickable-item-hov no-select",style:$e(e(n)&&!e(l).is_nsfw&&!e(l).show_nsfw&&e(u).currentRoute.value.name!=="draft-story-world"?"color: grey":""),onClick:s[4]||(s[4]=()=>(("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?e(u).currentRoute.value.name==="draft-story-world"||e(l).is_nsfw||e(l).show_nsfw||!e(l).is_nsfw&&!e(l).show_nsfw&&!e(n):d())?L("U"):null)},[...s[23]||(s[23]=[t("div",{class:"bold"},"Unlisted",-1),t("div",{class:"msg"},"🔗 Only you and those with the link can see your story world's page.",-1)])],4)]),t("div",Da,[t("div",{onClick:s[5
1]||(s[5]=()=>("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?null:d())},[m(S,{disabled:!(("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)&&(e(u).currentRoute.value.name==="draft-story-world"||e(l).is_nsfw||e(l).show_nsfw||!e(l).is_nsfw&&!e(l).show_nsfw&&!e(n))),class:"mr-1 clickable-item-hov",value:"E"},null,8,["disabled"])]),t("div",{class:"d-flex flex-column clickable-item-hov no-select",style:$e(e(n)&&!e(l).is_nsfw&&!e(l).show_nsfw&&e(u).currentRoute.value.name!=="draft-story-world"?"color: grey":""),onClick:s[6]||(s[6]=()=>(("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?e(u).currentRoute.value.name==="draft-story-world"||e(l).is_nsfw||e(l).show_nsfw||!e(l).is_nsfw&&!e(l).show_nsfw&&!e(n):d())?L("E"):null)},[...s[24]||(s[24]=[t("div",{class:"bold"},"Members Only",-1),t("div",{class:"msg"},"🛡️ Only verified members can see your story world's page.",-1)])],4)]),t("div",Aa,[t("div",{onClick:s[7]||(s[7]=()=>("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?null:d())},[m(S,{disabled:!(("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)&&(e(u).currentRoute.value.name==="draft-story-world"||e(l).is_nsfw||e(l).show_nsfw||!e(l).is_nsfw&&!e(l).show_nsfw&&!e(n))),class:"mr-1 clickable-item-hov",value:"P"},null,8,["disabled"])]),t("div",{class:"d-flex flex-column clickable-item-hov no-select",style:$e(e(n)&&!e(l).is_nsfw&&!e(l).show_nsfw&&e(u).currentRoute.value.name!=="draft-story-world"?"color: grey":""),onClick:s[8]||(s[8]=()=>(("get"in r?r.get:e(ue))(e(l),"is_email_verified",!0)?e(u).currentRoute.value.name==="draft-story-world"||e(l).is_nsfw||e(l).show_nsfw||!e(l).is_nsfw&&!e(l).show_nsfw&&!e(n):d())?L("P"):null)},[...s[25]||(s[25]=[t("div",{class:"bold"},"Public",-1),t("div",{class:"msg"},"Set your story world out into the world! Everyone can see your story world's page.",-1)])],4)])]),_:1},8,["modelValue"])]),m(Jt,{"is-open":e(C),onDismissModal:_},null,8,["is-open"])])}}}),Ua=le(Va,[["__scopeId","data-v-0cb18e3b"]]),Ea={key:0,class:"lock-content"},La={class:"lock-username"},Oa={key:1,class:"mb-4"},Ra={class:"text-center w-100 title"},Fa=se({__name:"index",setup(F){const{loadEditor:b,clearAll:$,isDirty:p,isDone:f,markIsDone:c,currentStoryWorld:u}=oe(),l=Fe(),h=Ue(),y=E(()=>h.name==="draft-story-world"),C=E(()=>u.value||(y.value&&g.value?{id:g.value}:null)),{lockedByUsername:d,tryAcquire:_,tryRelease:T}=Zt(),g=E(()=>{const{id:n}=h.params;return Array.isArray(n)?"":n}),a=E(()=>g.value?"Edit your Story World":"Weave your World");return ye(async()=>{if(!(h.query.coOwnerInvite==="true"&&y.value))try{$();const n=h.name;await b(g.value,n),g.value&&n==="edit-world"?await _("world",g.value):g.value&&n==="draft-story-world"&&await _("world_draft",g.value)}catch{c(),be.show("Could not load world. Please try again later.","nonative","danger"),$(),l.push({name:"my-creations"})}}),re(()=>h.query.coOwnerInvite,async(n,w)=>{if(w==="true"&&!n&&y.value&&g.value)try{$(),await b(g.value,h.name),await _("world_draft",g.value)}catch{l.push({name:"my-creations"})}}),Pe(()=>{T()}),Ft(async(n,w,L)=>{const{isSaving:U}=oe();if(f.value||!p.value&&!U.value)return $(),L();if(U.value){if(!await je("Save in progress. Leaving now may cause data loss. Are you sure you want to leave?"))return}else if(p.value&&!await je("Are you sure you want to leave? You may lose unsaved changes."))return;$(),L()}),(n,w)=>{const L=D("ion-page");return o(),i(ie,null,[e(y)?(o(),z(eo,{key:0,"entity-type":"world_draft",entity:e(C),"claim-redirect-path":`/story-worlds/create/draft/${e(g)}`},null,8,["entity","claim-redirect-path"])):R("",!0),m(L,{class:ne(["page scrollable create-story-world-page",{"editor-locked":e(d)}])},{default:M(()=>[e(d)?(o(),i("div",Ea,[w[0]||(w[0]=t("i",{class:"ti-lock lock-icon"},null,-1)),t("p",La,"@"+H(e(d)),1),w[1]||(w[1]=t("p",{class:"lock-message"},"is currently editing this world",-1)),w[2]||(w[2]=t("p",{class:"lock-submessage"},"You'll be able to edit once they're done.",-1))])):R("",!0),e(d)?R("",!0):(o(),i("div",Oa,[t("div",Ra,H(e(a)),1),m(co,{class:"mt-4"}),m(_o,{class:"one-section"}),m(Gl),m(sa,{class:"one-section mt-3"}),m(Ua,{class:"mt-5"}),m(ua,{class:"mt-4"}
1),w[3]||(w[3]=t("div",{class:"bottom-spacer"},null,-1))]))]),_:1},8,["class"])],64)}}}),Pn=le(Fa,[["__scopeId","data-v-23bcea06"]]);export{Pn as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.