diff --git a/yuuna/assets/ttu-ebook-reader/_app/immutable/chunks/store-fb60485f.js b/yuuna/assets/ttu-ebook-reader/_app/immutable/chunks/store-fb60485f.js index ea780fafd..6b93a3a19 100644 --- a/yuuna/assets/ttu-ebook-reader/_app/immutable/chunks/store-fb60485f.js +++ b/yuuna/assets/ttu-ebook-reader/_app/immutable/chunks/store-fb60485f.js @@ -23,7 +23,7 @@ var Il=Object.defineProperty;var Bl=(n,t,e)=>t in n?Il(n,t,{enumerable:!0,config `),Zt(r.$$.fragment),this.h()},l(l){t=be(l,"BUTTON",{class:!0});var o=ye(t);e=nt(o,`Cancel `),Gt(r.$$.fragment,o),o.forEach(K),this.h()},h(){le(t,"class",$a(Dn)+" svelte-1f582b9")},m(l,o){Be(l,t,o),fe(t,e),Xt(r,t,null),i=!0,s||(a=qn(t,"click",n[12]),s=!0)},p:Fr,i(l){i||(pe(r.$$.fragment,l),i=!0)},o(l){Ie(r.$$.fragment,l),i=!1},d(l){l&&K(t),zt(r),s=!1,a()}}}function O0(n){let t,e,r,i,s,a,l,o,c=(n[2]||n[3])&&Ia(n);return s=new Mn({}),{c(){t=we("div"),c&&c.c(),e=Et(),r=we("button"),i=tt(`Confirm `),Zt(s.$$.fragment),this.h()},l(d){t=be(d,"DIV",{class:!0,slot:!0});var f=ye(t);c&&c.l(f),e=Tt(f),r=be(f,"BUTTON",{class:!0});var u=ye(r);i=nt(u,`Confirm - `),Gt(s.$$.fragment,u),u.forEach(K),f.forEach(K),this.h()},h(){le(r,"class",$a(Dn)+" svelte-1f582b9"),le(t,"class","mt-2 flex grow justify-between"),le(t,"slot","footer")},m(d,f){Be(d,t,f),c&&c.m(t,null),fe(t,e),fe(t,r),fe(r,i),Xt(s,r,null),a=!0,l||(o=qn(r,"click",n[7]),l=!0)},p(d,f){d[2]||d[3]?c?(c.p(d,f),f&12&&pe(c,1)):(c=Ia(d),c.c(),pe(c,1),c.m(t,e)):c&&(gi(),Ie(c,1,1,()=>{c=null}),wi())},i(d){a||(pe(c),pe(s.$$.fragment,d),a=!0)},o(d){Ie(c),Ie(s.$$.fragment,d),a=!1},d(d){d&&K(t),c&&c.d(),zt(s),l=!1,o()}}}function R0(n){let t,e;return t=new $i({props:{$$slots:{footer:[O0],content:[F0]},$$scope:{ctx:n}}}),{c(){Zt(t.$$.fragment)},l(r){Gt(t.$$.fragment,r)},m(r,i){Xt(t,r,i),e=!0},p(r,[i]){const s={};i&65663&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){e||(pe(t.$$.fragment,r),e=!0)},o(r){Ie(t.$$.fragment,r),e=!1},d(r){zt(t,r)}}}function D0(n,t,e){let{description:r}=t,{action:i}=t,{requiresSecret:s=!0}=t,{showCancel:a=!1}=t,{forwardSecret:l=!1}=t,{encryptedData:o}=t,{resolver:c}=t,d,f="",u="";const m=Va();async function g(){d.classList.remove("error-animation"),e(6,u="");try{if(o)h({...JSON.parse(new TextDecoder().decode(await N0(window,o,f))),...l?{secret:f}:{}});else if(s)throw new Error("No data to unlock found");h({clientId:"",clientSecret:""})}catch(b){e(6,u=`Failed to unlock Data${b.message?`: ${b.message}`:""}`),d.classList.add("error-animation")}}function h(b){c(b),m("close")}ql(()=>(Fa.next(!0),()=>Fa.next(!1)));const p=()=>{h()};function w(){f=this.value,e(5,f)}function x(b){Ua[b?"unshift":"push"](()=>{d=b,e(4,d)})}return n.$$set=b=>{"description"in b&&e(0,r=b.description),"action"in b&&e(1,i=b.action),"requiresSecret"in b&&e(2,s=b.requiresSecret),"showCancel"in b&&e(3,a=b.showCancel),"forwardSecret"in b&&e(9,l=b.forwardSecret),"encryptedData"in b&&e(10,o=b.encryptedData),"resolver"in b&&e(11,c=b.resolver)},[r,i,s,a,d,f,u,g,h,l,o,c,p,w,x]}class Di extends jn{constructor(t){super(),Wn(this,t,D0,R0,Hn,{description:0,action:1,requiresSecret:2,showCancel:3,forwardSecret:9,encryptedData:10,resolver:11})}}class tn extends I{constructor(){super(...arguments);V(this,"rootDirectory");V(this,"titleToDirectory",new Map);V(this,"titleToFiles",new Map)}updateSettings(e,r,i,s,a,l){this.window=e,this.isForBrowser=r,this.saveBehavior=i,this.cacheStorageData=s,this.askForStorageUnlock=a;const o=l||ls.getValue();o!==this.storageSourceName&&this.clearData(),this.storageSourceName=o}async getBookList(){if(!this.dataListFetched){re.listLoading$.next(!0);const e=await this.ensureRoot(),r=await tn.list(e,!0);await this.setTitleData(r),this.dataListFetched=!0}return[...this.titleToBookCard.values()]}clearData(e=!0){this.titleToFiles.clear(),e&&(this.rootDirectory=void 0,this.titleToDirectory.clear(),this.titleToBookCard.clear(),this.dataListFetched=!1)}async prepareBookForReading(){const e=await re.getDataByTitle(this.currentContext.title);let r=0,i=e;if(!i||!i.elementHtml){const{file:s}=await this.getExternalFile("bookdata_");i=s?i||{title:this.currentContext.title,styleSheet:"",elementHtml:"",blobs:{},coverImage:"",hasThumb:!0,characters:0,sections:[],lastBookModified:0,lastBookOpen:0,storageSource:void 0}:void 0}if(!i)throw new Error("No local or external book data found");return i.storageSource!==this.storageSourceName?(i.storageSource=this.storageSourceName,r=await is(this.window,Z.BROWSER,void 0,!0,this.cacheStorageData,ve.Overwrite).saveBook(i,!0,!1)):e!=null&&e.id&&(r=e.id),r}async updateLastRead(e){const{file:r,files:i,rootDirectory:s}=await this.getExternalFile("bookdata_");if(!r)return;const a=await r.getFile(),l=I.getBookFileName(e),{characters:o,lastBookModified:c,lastBookOpen:d}=I.getBookMetadata(l);await this.writeFile(s,l,a,i,r),this.addBookCard(this.currentContext.title,{characters:o,lastBookModified:c,lastBookOpen:d})}async getFilenameForRecentCheck(e){if(this.saveBehavior===ve.Overwrite){I.reportProgress();return}const{file:r}=await this.getExternalFile(e,1);return r==null?void 0:r.name}async isBookPresentAndUpToDate(e){if(!e)return I.reportProgress(),!1;const{file:r}=await this.getExternalFile("bookdata_",1);let i=!1;if(r&&this.saveBehavior===ve.NewOnly){const{lastBookModified:s,lastBookOpen:a}=I.getBookMetadata(e),{lastBookModified:l,lastBookOpen:o}=I.getBookMetadata(r.name);i=!!(l&&s&&l>=s&&(o||0)>=(a||0))}return i}async isProgressPresentAndUpToDate(e){if(!e)return I.reportProgress(),!1;const{file:r}=await this.getExternalFile("progress_",1);let i=!1;if(r&&this.saveBehavior===ve.NewOnly){const{lastBookmarkModified:s}=I.getProgressMetadata(e),{lastBookmarkModified:a}=I.getProgressMetadata(r.name);i=!!(a&&s&&(a||0)>=(s||0))}return i}async getBook(){const{file:e}=await this.getExternalFile("bookdata_",this.isForBrowser?.4:.8);if(!e)return;const r=await e.getFile();return this.isForBrowser?this.extractBookData(r,r.name,.6):r}async getProgress(){const{file:e}=await this.getExternalFile("progress_",this.isForBrowser?.6:.8);if(!e)return;const r=await e.getFile();if(this.isForBrowser){const i=JSON.parse(await tn.readFileObject(r));return I.reportProgress(.4),i}return r}async getCover(){if(this.currentContext.imagePath instanceof Blob)return I.reportProgress(),this.currentContext.imagePath;const{file:e}=await this.getExternalFile("cover_",.8);return e?await e.getFile():void 0}async saveBook(e,r=!0){const i=e instanceof File,{file:s,files:a,rootDirectory:l}=await this.getExternalFile("bookdata_",.2),o=I.getBookFileName(e,s&&r?"":s==null?void 0:s.name),{characters:c,lastBookModified:d,lastBookOpen:f}=I.getBookMetadata(o);if(s&&this.saveBehavior===ve.NewOnly){const{lastBookModified:m,lastBookOpen:g}=I.getBookMetadata(s.name);if(m&&d&&m>=d&&(g||0)>=(f||0))return 0}let u;return i?(u=e,I.reportProgress(.2)):u=await this.zipBookData(e,.4),await this.writeFile(l,o,u,a,s,i?.6:.4),this.addBookCard(this.currentContext.title,{characters:c,lastBookModified:d,lastBookOpen:f}),0}async saveProgress(e){const r=I.getProgressFileName(e),{lastBookmarkModified:i,progress:s}=I.getProgressMetadata(r),{file:a,files:l,rootDirectory:o}=await this.getExternalFile("progress_");if(a&&this.saveBehavior===ve.NewOnly){const{lastBookmarkModified:c}=I.getProgressMetadata(a.name);if(c&&i&&(c||0)>=(i||0))return}await this.writeFile(o,r,e instanceof File?e:JSON.stringify(e),l,a,.6),this.addBookCard(this.currentContext.title,{lastBookmarkModified:i,progress:s})}async saveCover(e){if(!e){I.reportProgress();return}const{file:r,files:i,rootDirectory:s}=await this.getExternalFile("cover_");if(!r){const a=await I.getCoverFileName(e);await this.writeFile(s,a,e,i,void 0,.6)}this.titleToBookCard.has(this.currentContext.title)&&this.addBookCard(this.currentContext.title,{imagePath:e})}async deleteBookData(e,r){const i=await this.ensureRoot(),s=[],a=ht(1),l=[];let o="";return qt.next({progressBase:1,maxProgress:e.length}),e.forEach(c=>l.push(a(async()=>{var d;try{Ct(r),await i.removeEntry(I.sanitizeForFilename(c),{recursive:!0});const f=(d=this.titleToBookCard.get(c))==null?void 0:d.id;f&&s.push(f),this.titleToDirectory.delete(c),this.titleToFiles.delete(c),this.titleToBookCard.delete(c),re.dataListChanged$.next(this),I.reportProgress()}catch(f){o=$n(f,`Error deleting ${c}: `,[a])}}))),await Promise.all(l).catch(()=>{}),{error:o,deleted:s}}async ensureRoot(e=this.askForStorageUnlock){try{if(this.rootDirectory)return await tn.verifyPermission(this.rootDirectory),this.rootDirectory;const i=await(await re.db).get("storageSource",this.storageSourceName);if(!i)throw new Error(`No storage source with name ${this.storageSourceName} found`);const s=i.data;if(s instanceof ArrayBuffer)throw new Error("Wrong filesystem handle type");if(!s.directoryHandle)throw new Error("Filesystem handle not found");await tn.verifyPermission(s.directoryHandle),this.rootDirectory=s.directoryHandle}catch(r){if(r.message.includes("activation is required")&&(!this.rootDirectory||e))return await new Promise(i=>{Tr.dialogs$.next([{component:Di,props:{description:"You are trying to access data on your filesystem",action:"Please grant permissions in the next dialog",requiresSecret:!1,resolver:i},disableCloseOnClick:!0}])}),this.ensureRoot(!1);throw r}return this.rootDirectory}async setTitleData(e,r=!0){const i=ht(1),s=[];e.forEach(a=>s.push(i(async()=>{try{const l=await tn.list(a);if(!l.length)return;const o={id:I.getDummyId(),title:I.desanitizeFilename(a.name),imagePath:"",characters:0,lastBookModified:0,lastBookOpen:0,progress:0,lastBookmarkModified:0,isPlaceholder:!1},c=ht(1),d=[];l.forEach(f=>d.push(c(async()=>{try{if(f.name.startsWith("bookdata_")){const u=I.getBookMetadata(f.name);o.characters=u.characters,o.lastBookModified=u.lastBookModified,o.lastBookOpen=u.lastBookOpen}else if(f.name.startsWith("progress_")){const u=I.getProgressMetadata(f.name);o.lastBookmarkModified=u.lastBookmarkModified,o.progress=u.progress}else f.name.startsWith("cover_")&&(o.imagePath=await f.getFile())}catch(u){throw c.clearQueue(),u}}))),await Promise.all(d),this.titleToDirectory.set(o.title,a),this.titleToFiles.set(o.title,l),this.titleToBookCard.set(o.title,o)}catch(l){throw i.clearQueue(),l}}))),await Promise.all(s).catch(a=>{throw r&&this.clearData(),a})}async getExternalFile(e,r=.4){const i=r/2,s=await this.ensureRoot();I.reportProgress(i);const a=await this.getExternalFiles(s),l=a.find(o=>o.name.startsWith(e));return I.reportProgress(i),{file:l,files:a,rootDirectory:s}}async getExternalFiles(e){if((!this.cacheStorageData||!this.dataListFetched)&&!this.titleToFiles.has(this.currentContext.title)){const r=await e.getDirectoryHandle(this.sanitizedTitle,{create:!1}).catch(()=>{});r&&await this.setTitleData([r],!1)}return this.titleToFiles.get(this.currentContext.title)||[]}async writeFile(e,r,i,s,a,l=.4){const o=l/2,c=this.titleToDirectory.get(this.currentContext.title)||await e.getDirectoryHandle(this.sanitizedTitle,{create:!0}),d=await c.getFileHandle(r,{create:!0}),f=await d.createWritable();if(await f.write(i),await f.close(),I.reportProgress(o),a){await d.isSameEntry(a)||await c.removeEntry(a.name);const u=s.filter(m=>m.name!==a.name);u.push(d),this.titleToFiles.set(this.currentContext.title,u)}else s.push(d),this.titleToFiles.set(this.currentContext.title,s);this.titleToDirectory.set(this.currentContext.title,c),I.reportProgress(o)}static async verifyPermission(e){const r={mode:"readwrite"};if(await e.queryPermission(r)==="granted"||await e.requestPermission(r)==="granted")return!0;throw new Error("No permissions granted to access filesystem")}static async list(e,r=!1){const i=[],s=e.values();let a=await s.next();for(;!a.done;)(a.value.kind==="directory"&&r||a.value.kind==="file")&&i.push(a.value),a=await s.next();return i}static readFileObject(e){return new Promise((r,i)=>{const s=new FileReader;s.addEventListener("load",()=>{r(s.result)}),s.addEventListener("error",()=>{i(new Error(`Error reading file ${e.name}`))}),s.readAsText(e)})}}function M0(n){var i;const t=n.navigator.userAgent,e=/\b(BlackBerry|webOS|iPhone|IEMobile|Android|Windows Phone|iPad|iPod)\b/i;if("maxTouchPoints"in n.navigator)return n.navigator.maxTouchPoints>0;if("msMaxTouchPoints"in n.navigator)return n.navigator.msMaxTouchPoints>0;const r=(i=n.matchMedia)==null?void 0:i.call(n,"(pointer:coarse)");return(r==null?void 0:r.media)==="(pointer: coarse)"?!!r.matches:"orientation"in n?!0:e.test(t)}function ep(n){return n.location.href.startsWith("https://ttu-ebook.web.app")}function tp(){}const np=on(!1),ui=new Map;class Rn{constructor(t,e){V(this,"storageType");V(this,"refreshEndpoint");V(this,"parentWindow");V(this,"storageSourceName","");V(this,"remoteData");V(this,"authWindow",null);V(this,"codeVerifier","");V(this,"authResolver");V(this,"authRejector");V(this,"rebindedWinHandler");V(this,"authCloseIntervalTime",500);V(this,"authCloseInterval");V(this,"authTimeout",45e3);V(this,"authTimeoutTimer");this.storageType=t,this.refreshEndpoint=e}async getToken(t,e,r,i,s){const a=ui.get(e),l=!a||r;(!a||this.storageSourceName!==e)&&(this.remoteData=void 0,this.storageSourceName=e);let o=await this.verifyToken(a);if(o)return o.accessToken;this.remoteData=void 0;let c,d=s;if(e===Ge.GDRIVE_DEFAULT)this.remoteData={clientId:co,clientSecret:""};else if(e===Ge.ONEDRIVE_DEFAULT)this.remoteData={clientId:po,clientSecret:""};else{if(!d){const m=await(await re.db).get("storageSource",e);if(!m)throw new Error(`No storage source with name ${e} found`);if(d=l?await new Promise(g=>{Tr.dialogs$.next([{component:Di,props:{description:"You are trying to access protected data",action:`Enter the correct password for ${e} and login to your account if required to proceed`,encryptedData:m.data,forwardSecret:!0,resolver:g},disableCloseOnClick:!0}])}):void 0,!d)throw new Error("Unable to unlock required data")}if(this.remoteData={clientId:d.clientId,clientSecret:d.clientSecret,refreshToken:d.refreshToken},o=await this.verifyToken(o),o)return o.accessToken;c=d.secret}if(this.parentWindow=t,i?(this.authWindow=i,this.authWindow.location.assign(`${zr}/auth?ttu-init-auth=1`)):l?this.authWindow=Rn.createWindow(`${zr}/auth?ttu-init-auth=1`,"auth",Math.min(Math.max(this.parentWindow.innerWidth,300),560),Math.min(Math.max(this.parentWindow.innerHeight,300),560),t):this.authWindow=null,!this.authWindow){if(l)return await new Promise(u=>{Tr.dialogs$.next([{component:Di,props:{description:"You are trying to access external data",action:"Login to your account when prompted",requiresSecret:!1,encryptedData:void 0,resolver:u},disableCloseOnClick:!0}])}),this.getToken(t,e,!1,Rn.createWindow(`${zr}/auth?ttu-init-wait=1`,"auth",Math.min(Math.max(this.parentWindow.innerWidth,300),560),Math.min(Math.max(this.parentWindow.innerHeight,300),560),t),d);throw new Error("Unable to open login window. Please check your popup settings")}let f="";try{if(o=await this.waitForAuth(),ui.set(e,o),this.parentWindow&&this.remoteData.clientId&&(this.storageType!==Z.GDRIVE||this.remoteData.clientSecret)&&o.refreshToken&&o.refreshToken!==this.remoteData.refreshToken&&c){this.remoteData.refreshToken=o.refreshToken;try{await(await re.db).put("storageSource",{name:e,type:this.storageType,data:await P0(this.parentWindow,JSON.stringify({clientId:this.remoteData.clientId,clientSecret:this.remoteData.clientSecret,refreshToken:o.refreshToken}),c),lastSourceModified:Date.now()})}catch(u){kt.error(`Error updating refresh token for ${e}: ${u.message}`)}}}catch(u){f=u.message}finally{c="",this.clearAuthData()}if(f)throw new Error(f);return o==null?void 0:o.accessToken}async verifyToken(t){if(!(!t&&!this.remoteData))return t&&t.expiration>Date.now()?t:this.refreshToken()}async refreshToken(){var l;if(!(this.refreshEndpoint&&this.storageSourceName&&((l=this.remoteData)==null?void 0:l.clientId)&&(this.storageType!==Z.GDRIVE||this.remoteData.clientSecret)&&this.remoteData.refreshToken))return;const t=new FormData;t.append("client_id",this.remoteData.clientId),t.append("refresh_token",this.remoteData.refreshToken),t.append("grant_type","refresh_token"),this.storageType===Z.GDRIVE&&t.append("client_secret",this.remoteData.clientSecret);const e=await fetch(this.refreshEndpoint,{method:"POST",body:t}).then(async o=>{if(!o.ok)throw new Error(await La(o));return o.json()}).catch(o=>{kt.error(`Unable to refresh token for ${this.storageSourceName}: ${o.message}`)});if(!e){this.remoteData.refreshToken=void 0;return}const{access_token:r,expires_in:i,scope:s}=e;if(!r||!i||!s){this.remoteData.refreshToken=void 0,kt.error(`A required authentication property was not found + `),Gt(s.$$.fragment,u),u.forEach(K),f.forEach(K),this.h()},h(){le(r,"class",$a(Dn)+" svelte-1f582b9"),le(t,"class","mt-2 flex grow justify-between"),le(t,"slot","footer")},m(d,f){Be(d,t,f),c&&c.m(t,null),fe(t,e),fe(t,r),fe(r,i),Xt(s,r,null),a=!0,l||(o=qn(r,"click",n[7]),l=!0)},p(d,f){d[2]||d[3]?c?(c.p(d,f),f&12&&pe(c,1)):(c=Ia(d),c.c(),pe(c,1),c.m(t,e)):c&&(gi(),Ie(c,1,1,()=>{c=null}),wi())},i(d){a||(pe(c),pe(s.$$.fragment,d),a=!0)},o(d){Ie(c),Ie(s.$$.fragment,d),a=!1},d(d){d&&K(t),c&&c.d(),zt(s),l=!1,o()}}}function R0(n){let t,e;return t=new $i({props:{$$slots:{footer:[O0],content:[F0]},$$scope:{ctx:n}}}),{c(){Zt(t.$$.fragment)},l(r){Gt(t.$$.fragment,r)},m(r,i){Xt(t,r,i),e=!0},p(r,[i]){const s={};i&65663&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){e||(pe(t.$$.fragment,r),e=!0)},o(r){Ie(t.$$.fragment,r),e=!1},d(r){zt(t,r)}}}function D0(n,t,e){let{description:r}=t,{action:i}=t,{requiresSecret:s=!0}=t,{showCancel:a=!1}=t,{forwardSecret:l=!1}=t,{encryptedData:o}=t,{resolver:c}=t,d,f="",u="";const m=Va();async function g(){d.classList.remove("error-animation"),e(6,u="");try{if(o)h({...JSON.parse(new TextDecoder().decode(await N0(window,o,f))),...l?{secret:f}:{}});else if(s)throw new Error("No data to unlock found");h({clientId:"",clientSecret:""})}catch(b){e(6,u=`Failed to unlock Data${b.message?`: ${b.message}`:""}`),d.classList.add("error-animation")}}function h(b){c(b),m("close")}ql(()=>(Fa.next(!0),()=>Fa.next(!1)));const p=()=>{h()};function w(){f=this.value,e(5,f)}function x(b){Ua[b?"unshift":"push"](()=>{d=b,e(4,d)})}return n.$$set=b=>{"description"in b&&e(0,r=b.description),"action"in b&&e(1,i=b.action),"requiresSecret"in b&&e(2,s=b.requiresSecret),"showCancel"in b&&e(3,a=b.showCancel),"forwardSecret"in b&&e(9,l=b.forwardSecret),"encryptedData"in b&&e(10,o=b.encryptedData),"resolver"in b&&e(11,c=b.resolver)},[r,i,s,a,d,f,u,g,h,l,o,c,p,w,x]}class Di extends jn{constructor(t){super(),Wn(this,t,D0,R0,Hn,{description:0,action:1,requiresSecret:2,showCancel:3,forwardSecret:9,encryptedData:10,resolver:11})}}class tn extends I{constructor(){super(...arguments);V(this,"rootDirectory");V(this,"titleToDirectory",new Map);V(this,"titleToFiles",new Map)}updateSettings(e,r,i,s,a,l){this.window=e,this.isForBrowser=r,this.saveBehavior=i,this.cacheStorageData=s,this.askForStorageUnlock=a;const o=l||ls.getValue();o!==this.storageSourceName&&this.clearData(),this.storageSourceName=o}async getBookList(){if(!this.dataListFetched){re.listLoading$.next(!0);const e=await this.ensureRoot(),r=await tn.list(e,!0);await this.setTitleData(r),this.dataListFetched=!0}return[...this.titleToBookCard.values()]}clearData(e=!0){this.titleToFiles.clear(),e&&(this.rootDirectory=void 0,this.titleToDirectory.clear(),this.titleToBookCard.clear(),this.dataListFetched=!1)}async prepareBookForReading(){const e=await re.getDataByTitle(this.currentContext.title);let r=0,i=e;if(!i||!i.elementHtml){const{file:s}=await this.getExternalFile("bookdata_");i=s?i||{title:this.currentContext.title,styleSheet:"",elementHtml:"",blobs:{},coverImage:"",hasThumb:!0,characters:0,sections:[],lastBookModified:0,lastBookOpen:0,storageSource:void 0}:void 0}if(!i)throw new Error("No local or external book data found");return i.storageSource!==this.storageSourceName?(i.storageSource=this.storageSourceName,r=await is(this.window,Z.BROWSER,void 0,!0,this.cacheStorageData,ve.Overwrite).saveBook(i,!0,!1)):e!=null&&e.id&&(r=e.id),r}async updateLastRead(e){const{file:r,files:i,rootDirectory:s}=await this.getExternalFile("bookdata_");if(!r)return;const a=await r.getFile(),l=I.getBookFileName(e),{characters:o,lastBookModified:c,lastBookOpen:d}=I.getBookMetadata(l);await this.writeFile(s,l,a,i,r),this.addBookCard(this.currentContext.title,{characters:o,lastBookModified:c,lastBookOpen:d})}async getFilenameForRecentCheck(e){if(this.saveBehavior===ve.Overwrite){I.reportProgress();return}const{file:r}=await this.getExternalFile(e,1);return r==null?void 0:r.name}async isBookPresentAndUpToDate(e){if(!e)return I.reportProgress(),!1;const{file:r}=await this.getExternalFile("bookdata_",1);let i=!1;if(r&&this.saveBehavior===ve.NewOnly){const{lastBookModified:s,lastBookOpen:a}=I.getBookMetadata(e),{lastBookModified:l,lastBookOpen:o}=I.getBookMetadata(r.name);i=!!(l&&s&&l>=s&&(o||0)>=(a||0))}return i}async isProgressPresentAndUpToDate(e){if(!e)return I.reportProgress(),!1;const{file:r}=await this.getExternalFile("progress_",1);let i=!1;if(r&&this.saveBehavior===ve.NewOnly){const{lastBookmarkModified:s}=I.getProgressMetadata(e),{lastBookmarkModified:a}=I.getProgressMetadata(r.name);i=!!(a&&s&&(a||0)>=(s||0))}return i}async getBook(){const{file:e}=await this.getExternalFile("bookdata_",this.isForBrowser?.4:.8);if(!e)return;const r=await e.getFile();return this.isForBrowser?this.extractBookData(r,r.name,.6):r}async getProgress(){const{file:e}=await this.getExternalFile("progress_",this.isForBrowser?.6:.8);if(!e)return;const r=await e.getFile();if(this.isForBrowser){const i=JSON.parse(await tn.readFileObject(r));return I.reportProgress(.4),i}return r}async getCover(){if(this.currentContext.imagePath instanceof Blob)return I.reportProgress(),this.currentContext.imagePath;const{file:e}=await this.getExternalFile("cover_",.8);return e?await e.getFile():void 0}async saveBook(e,r=!0){const i=e instanceof File,{file:s,files:a,rootDirectory:l}=await this.getExternalFile("bookdata_",.2),o=I.getBookFileName(e,s&&r?"":s==null?void 0:s.name),{characters:c,lastBookModified:d,lastBookOpen:f}=I.getBookMetadata(o);if(s&&this.saveBehavior===ve.NewOnly){const{lastBookModified:m,lastBookOpen:g}=I.getBookMetadata(s.name);if(m&&d&&m>=d&&(g||0)>=(f||0))return 0}let u;return i?(u=e,I.reportProgress(.2)):u=await this.zipBookData(e,.4),await this.writeFile(l,o,u,a,s,i?.6:.4),this.addBookCard(this.currentContext.title,{characters:c,lastBookModified:d,lastBookOpen:f}),0}async saveProgress(e){const r=I.getProgressFileName(e),{lastBookmarkModified:i,progress:s}=I.getProgressMetadata(r),{file:a,files:l,rootDirectory:o}=await this.getExternalFile("progress_");if(a&&this.saveBehavior===ve.NewOnly){const{lastBookmarkModified:c}=I.getProgressMetadata(a.name);if(c&&i&&(c||0)>=(i||0))return}await this.writeFile(o,r,e instanceof File?e:JSON.stringify(e),l,a,.6),this.addBookCard(this.currentContext.title,{lastBookmarkModified:i,progress:s})}async saveCover(e){if(!e){I.reportProgress();return}const{file:r,files:i,rootDirectory:s}=await this.getExternalFile("cover_");if(!r){const a=await I.getCoverFileName(e);await this.writeFile(s,a,e,i,void 0,.6)}this.titleToBookCard.has(this.currentContext.title)&&this.addBookCard(this.currentContext.title,{imagePath:e})}async deleteBookData(e,r){const i=await this.ensureRoot(),s=[],a=ht(1),l=[];let o="";return qt.next({progressBase:1,maxProgress:e.length}),e.forEach(c=>l.push(a(async()=>{var d;try{Ct(r),await i.removeEntry(I.sanitizeForFilename(c),{recursive:!0});const f=(d=this.titleToBookCard.get(c))==null?void 0:d.id;f&&s.push(f),this.titleToDirectory.delete(c),this.titleToFiles.delete(c),this.titleToBookCard.delete(c),re.dataListChanged$.next(this),I.reportProgress()}catch(f){o=$n(f,`Error deleting ${c}: `,[a])}}))),await Promise.all(l).catch(()=>{}),{error:o,deleted:s}}async ensureRoot(e=this.askForStorageUnlock){try{if(this.rootDirectory)return await tn.verifyPermission(this.rootDirectory),this.rootDirectory;const i=await(await re.db).get("storageSource",this.storageSourceName);if(!i)throw new Error(`No storage source with name ${this.storageSourceName} found`);const s=i.data;if(s instanceof ArrayBuffer)throw new Error("Wrong filesystem handle type");if(!s.directoryHandle)throw new Error("Filesystem handle not found");await tn.verifyPermission(s.directoryHandle),this.rootDirectory=s.directoryHandle}catch(r){if(r.message.includes("activation is required")&&(!this.rootDirectory||e))return await new Promise(i=>{Tr.dialogs$.next([{component:Di,props:{description:"You are trying to access data on your filesystem",action:"Please grant permissions in the next dialog",requiresSecret:!1,resolver:i},disableCloseOnClick:!0}])}),this.ensureRoot(!1);throw r}return this.rootDirectory}async setTitleData(e,r=!0){const i=ht(1),s=[];e.forEach(a=>s.push(i(async()=>{try{const l=await tn.list(a);if(!l.length)return;const o={id:I.getDummyId(),title:I.desanitizeFilename(a.name),imagePath:"",characters:0,lastBookModified:0,lastBookOpen:0,progress:0,lastBookmarkModified:0,isPlaceholder:!1},c=ht(1),d=[];l.forEach(f=>d.push(c(async()=>{try{if(f.name.startsWith("bookdata_")){const u=I.getBookMetadata(f.name);o.characters=u.characters,o.lastBookModified=u.lastBookModified,o.lastBookOpen=u.lastBookOpen}else if(f.name.startsWith("progress_")){const u=I.getProgressMetadata(f.name);o.lastBookmarkModified=u.lastBookmarkModified,o.progress=u.progress}else f.name.startsWith("cover_")&&(o.imagePath=await f.getFile())}catch(u){throw c.clearQueue(),u}}))),await Promise.all(d),this.titleToDirectory.set(o.title,a),this.titleToFiles.set(o.title,l),this.titleToBookCard.set(o.title,o)}catch(l){throw i.clearQueue(),l}}))),await Promise.all(s).catch(a=>{throw r&&this.clearData(),a})}async getExternalFile(e,r=.4){const i=r/2,s=await this.ensureRoot();I.reportProgress(i);const a=await this.getExternalFiles(s),l=a.find(o=>o.name.startsWith(e));return I.reportProgress(i),{file:l,files:a,rootDirectory:s}}async getExternalFiles(e){if((!this.cacheStorageData||!this.dataListFetched)&&!this.titleToFiles.has(this.currentContext.title)){const r=await e.getDirectoryHandle(this.sanitizedTitle,{create:!1}).catch(()=>{});r&&await this.setTitleData([r],!1)}return this.titleToFiles.get(this.currentContext.title)||[]}async writeFile(e,r,i,s,a,l=.4){const o=l/2,c=this.titleToDirectory.get(this.currentContext.title)||await e.getDirectoryHandle(this.sanitizedTitle,{create:!0}),d=await c.getFileHandle(r,{create:!0}),f=await d.createWritable();if(await f.write(i),await f.close(),I.reportProgress(o),a){await d.isSameEntry(a)||await c.removeEntry(a.name);const u=s.filter(m=>m.name!==a.name);u.push(d),this.titleToFiles.set(this.currentContext.title,u)}else s.push(d),this.titleToFiles.set(this.currentContext.title,s);this.titleToDirectory.set(this.currentContext.title,c),I.reportProgress(o)}static async verifyPermission(e){const r={mode:"readwrite"};if(await e.queryPermission(r)==="granted"||await e.requestPermission(r)==="granted")return!0;throw new Error("No permissions granted to access filesystem")}static async list(e,r=!1){const i=[],s=e.values();let a=await s.next();for(;!a.done;)(a.value.kind==="directory"&&r||a.value.kind==="file")&&i.push(a.value),a=await s.next();return i}static readFileObject(e){return new Promise((r,i)=>{const s=new FileReader;s.addEventListener("load",()=>{r(s.result)}),s.addEventListener("error",()=>{i(new Error(`Error reading file ${e.name}`))}),s.readAsText(e)})}}function M0(n){var i;const t=n.navigator.userAgent,e=/\b(BlackBerry|webOS|iPhone|IEMobile|Android|Windows Phone|iPad|iPod)\b/i;if("maxTouchPoints"in n.navigator)return n.navigator.maxTouchPoints>0;if("msMaxTouchPoints"in n.navigator)return n.navigator.msMaxTouchPoints>0;const r=(i=n.matchMedia)==null?void 0:i.call(n,"(pointer:coarse)");return(r==null?void 0:r.media)==="(pointer: coarse)"?!!r.matches:"orientation"in n?!0:e.test(t)}function ep(n){return n.location.href.startsWith("https://ttu-ebook.web.app")}function tp(){}const np=on(!1),ui=new Map;class Rn{constructor(t,e){V(this,"storageType");V(this,"refreshEndpoint");V(this,"parentWindow");V(this,"storageSourceName","");V(this,"remoteData");V(this,"authWindow",null);V(this,"codeVerifier","");V(this,"authResolver");V(this,"authRejector");V(this,"rebindedWinHandler");V(this,"authCloseIntervalTime",500);V(this,"authCloseInterval");V(this,"authTimeout",45e3);V(this,"authTimeoutTimer");this.storageType=t,this.refreshEndpoint=e}async getToken(t,e,r,i,s){const a=ui.get(e),l=!a||r;(!a||this.storageSourceName!==e)&&(this.remoteData=void 0,this.storageSourceName=e);let o=await this.verifyToken(a);if(o)return o.accessToken;this.remoteData=void 0;let c,d=s;if(e===Ge.GDRIVE_DEFAULT)this.remoteData={clientId:co,clientSecret:""};else if(e===Ge.ONEDRIVE_DEFAULT)this.remoteData={clientId:po,clientSecret:""};else{if(!d){const m=await(await re.db).get("storageSource",e);if(!m)throw new Error(`No storage source with name ${e} found`);if(d=l?await new Promise(g=>{Tr.dialogs$.next([{component:Di,props:{description:"You are trying to access protected data",action:`Enter the correct password for ${e} and login to your account if required to proceed`,encryptedData:m.data,forwardSecret:!0,resolver:g},disableCloseOnClick:!0}])}):void 0,!d)throw new Error("Unable to unlock required data")}if(this.remoteData={clientId:d.clientId,clientSecret:d.clientSecret,refreshToken:d.refreshToken},o=await this.verifyToken(o),o)return o.accessToken;c=d.secret}if(this.parentWindow=t,i?(this.authWindow=i,this.authWindow.location.assign(`${zr}/auth.html?ttu-init-auth=1`)):l?this.authWindow=Rn.createWindow(`${zr}/auth.html?ttu-init-auth=1`,"auth",Math.min(Math.max(this.parentWindow.innerWidth,300),560),Math.min(Math.max(this.parentWindow.innerHeight,300),560),t):this.authWindow=null,!this.authWindow){if(l)return await new Promise(u=>{Tr.dialogs$.next([{component:Di,props:{description:"You are trying to access external data",action:"Login to your account when prompted",requiresSecret:!1,encryptedData:void 0,resolver:u},disableCloseOnClick:!0}])}),this.getToken(t,e,!1,Rn.createWindow(`${zr}/auth.html?ttu-init-wait=1`,"auth",Math.min(Math.max(this.parentWindow.innerWidth,300),560),Math.min(Math.max(this.parentWindow.innerHeight,300),560),t),d);throw new Error("Unable to open login window. Please check your popup settings")}let f="";try{if(o=await this.waitForAuth(),ui.set(e,o),this.parentWindow&&this.remoteData.clientId&&(this.storageType!==Z.GDRIVE||this.remoteData.clientSecret)&&o.refreshToken&&o.refreshToken!==this.remoteData.refreshToken&&c){this.remoteData.refreshToken=o.refreshToken;try{await(await re.db).put("storageSource",{name:e,type:this.storageType,data:await P0(this.parentWindow,JSON.stringify({clientId:this.remoteData.clientId,clientSecret:this.remoteData.clientSecret,refreshToken:o.refreshToken}),c),lastSourceModified:Date.now()})}catch(u){kt.error(`Error updating refresh token for ${e}: ${u.message}`)}}}catch(u){f=u.message}finally{c="",this.clearAuthData()}if(f)throw new Error(f);return o==null?void 0:o.accessToken}async verifyToken(t){if(!(!t&&!this.remoteData))return t&&t.expiration>Date.now()?t:this.refreshToken()}async refreshToken(){var l;if(!(this.refreshEndpoint&&this.storageSourceName&&((l=this.remoteData)==null?void 0:l.clientId)&&(this.storageType!==Z.GDRIVE||this.remoteData.clientSecret)&&this.remoteData.refreshToken))return;const t=new FormData;t.append("client_id",this.remoteData.clientId),t.append("refresh_token",this.remoteData.refreshToken),t.append("grant_type","refresh_token"),this.storageType===Z.GDRIVE&&t.append("client_secret",this.remoteData.clientSecret);const e=await fetch(this.refreshEndpoint,{method:"POST",body:t}).then(async o=>{if(!o.ok)throw new Error(await La(o));return o.json()}).catch(o=>{kt.error(`Unable to refresh token for ${this.storageSourceName}: ${o.message}`)});if(!e){this.remoteData.refreshToken=void 0;return}const{access_token:r,expires_in:i,scope:s}=e;if(!r||!i||!s){this.remoteData.refreshToken=void 0,kt.error(`A required authentication property was not found had token: ${!!r} had expiration: ${!!i} had scope: ${!!s}`);return}const a={accessToken:r,scope:s,expiration:Date.now()+(Number.parseInt(i,10)-600)*1e3,refreshToken:this.remoteData.refreshToken};return ui.set(this.storageSourceName,a),a}base64Url(t){if(!this.parentWindow)throw new Error("Parent window not defined");return this.parentWindow.btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}waitForAuth(){return new Promise((t,e)=>{if(!this.parentWindow){e(new Error("Parent window not defined"));return}this.authResolver=t,this.authRejector=e,this.rebindedWinHandler=this.winHandler.bind(this),this.parentWindow.addEventListener("message",this.rebindedWinHandler,!1),this.authCloseInterval=setInterval(()=>{var r;(r=this.authWindow)!=null&&r.closed&&e(new Error("Window was closed before login"))},this.authCloseIntervalTime),this.authTimeoutTimer=setTimeout(()=>{e(new Error("Login timeout"))},this.authTimeout)})}async winHandler(t){if(!(!this.parentWindow||!this.remoteData||t.source!==this.authWindow||!this.authResolver||!this.authRejector))switch(t.data.type){case"getAuthVariables":t.ports[0].postMessage({result:{...this.remoteData,...Rn.getAuthVariables(this.storageType),sendSecret:this.storageType===Z.GDRIVE&&!B0(this.storageSourceName)}});break;case"auth":this.authResolver(t.data.payload);break;case"getCodeChallenge":if(!this.codeVerifier){const e=new Uint8Array(32);this.parentWindow.crypto.getRandomValues(e),this.codeVerifier=this.base64Url(e)}t.ports[0].postMessage({result:this.base64Url(await this.parentWindow.crypto.subtle.digest("SHA-256",new TextEncoder().encode(this.codeVerifier)))});break;case"getCodeVerifier":t.ports[0].postMessage({result:this.codeVerifier});break;case"failure":kt.error(t.data.payload.detail),this.authRejector(new Error(t.data.payload.message));break}}clearAuthData(){var t,e;clearTimeout(this.authTimeoutTimer),clearInterval(this.authCloseInterval),this.parentWindow&&this.rebindedWinHandler&&this.parentWindow.removeEventListener("message",this.rebindedWinHandler,!1);try{(t=this.authWindow)!=null&&t.closed||(e=this.authWindow)==null||e.close()}catch{}this.authResolver=void 0,this.authRejector=void 0,this.rebindedWinHandler=void 0,this.parentWindow=void 0,this.authWindow=null,this.codeVerifier=""}static createWindow(t,e,r,i,s){const a=M0(s),l=typeof s.screenX<"u"?s.screenX:s.screenLeft,o=typeof s.screenY<"u"?s.screenY:s.screenTop,c=typeof s.outerWidth<"u"?s.outerWidth:document.documentElement.clientWidth,d=typeof s.outerHeight<"u"?s.outerHeight:document.documentElement.clientHeight-22,f=a?null:r,u=a?null:i,m=l<0?s.screen.width+l:l,g=f?parseInt(`${m+(c-f)/2}`,10):0,h=u?parseInt(`${o+(d-u)/2.5}`,10):0,p=[];return f!==null&&p.push(`width=${f}`),u!==null&&p.push(`height=${u}`),p.push(`left=${g}`),p.push(`top=${h}`),p.push("scrollbars=1"),s.open(t,e,p.join(","))}static getAuthVariables(t){switch(t){case Z.GDRIVE:return{authEndpoint:oo,tokenEndpoint:Hc,scope:lo};case Z.ONEDRIVE:return{authEndpoint:fo,tokenEndpoint:uo,scope:ho};default:return{}}}static revokeToken(t,e){const r=new URLSearchParams;r.append("token",e),fetch(`${t}?${r.toString()}`,{method:"POST"}).catch(()=>{})}}class vl extends I{constructor(e,r,i){super(r,e);V(this,"authManager");V(this,"rootId","");V(this,"titleToId",new Map);V(this,"titleToFiles",new Map);this.authManager=new Rn(this.storageType,i)}updateSettings(e,r,i,s,a,l){this.window=e,this.isForBrowser=r,this.saveBehavior=i,this.cacheStorageData=s,this.askForStorageUnlock=a,this.setInternalSettings(l)}clearData(e=!0){this.titleToFiles.clear(),e&&(this.rootId="",this.titleToId.clear(),this.titleToBookCard.clear(),this.dataListFetched=!1)}async prepareBookForReading(){const e=await re.getDataByTitle(this.currentContext.title);let r=0,i=e;if(!i||!i.elementHtml){const{file:s}=await this.getExternalFile("bookdata_");i=s?i||{title:this.currentContext.title,styleSheet:"",elementHtml:"",blobs:{},coverImage:"",hasThumb:!0,characters:0,sections:[],lastBookModified:0,lastBookOpen:0,storageSource:void 0}:void 0}if(!i)throw new Error("No local or external book data found");return i.storageSource!==this.storageSourceName?(i.storageSource=this.storageSourceName,r=await is(this.window,Z.BROWSER,void 0,!0,this.cacheStorageData,ve.Overwrite).saveBook(i,!0,!1)):e!=null&&e.id&&(r=e.id),r}async updateLastRead(e){const{titleId:r,files:i,file:s}=await this.getExternalFile("bookdata_");if(!s)return;const a=I.getBookFileName(e),{characters:l,lastBookModified:o,lastBookOpen:c}=I.getBookMetadata(a);await this.upload(r,a,i,s,void 0),this.addBookCard(this.currentContext.title,{characters:l,lastBookModified:o,lastBookOpen:c})}async getFilenameForRecentCheck(e){if(this.saveBehavior===ve.Overwrite){I.reportProgress();return}const{file:r}=await this.getExternalFile(e);return I.completeStep(),r==null?void 0:r.name}async isBookPresentAndUpToDate(e){if(!e)return I.reportProgress(),!1;const{file:r}=await this.getExternalFile("bookdata_");let i=!1;if(r&&this.saveBehavior===ve.NewOnly){const{lastBookModified:s,lastBookOpen:a}=I.getBookMetadata(e),{lastBookModified:l,lastBookOpen:o}=I.getBookMetadata(r.name);i=!!(l&&s&&l>=s&&(o||0)>=(a||0))}return I.completeStep(),i}async isProgressPresentAndUpToDate(e){if(!e)return I.reportProgress(),!1;const{file:r}=await this.getExternalFile("progress_");let i=!1;if(r&&this.saveBehavior===ve.NewOnly){const{lastBookmarkModified:s}=I.getProgressMetadata(e),{lastBookmarkModified:a}=I.getProgressMetadata(r.name);i=!!(a&&s&&(a||0)>=(s||0))}return I.completeStep(),i}async getBook(){const{file:e,data:r}=await this.getExternalFile("bookdata_","blob",this.isForBrowser?.7:1);if(!!e)return this.isForBrowser?this.extractBookData(r,e.name,.3):new File([r],e.name,{type:"application/zip"})}async getProgress(){const{file:e,data:r}=await this.getExternalFile("progress_","json");if(!!e)return this.isForBrowser?r:new File([new Blob([JSON.stringify(r)])],e.name,{type:"application/json"})}async getCover(){if(this.currentContext.imagePath instanceof Blob)return I.reportProgress(),this.currentContext.imagePath;const{data:e}=await this.getExternalFile("cover_","blob");return e}async saveBook(e,r=!0){const{titleId:i,files:s,file:a}=await this.getExternalFile("bookdata_","",.2,!1),l=I.getBookFileName(e,r?"":a==null?void 0:a.name),{characters:o,lastBookModified:c,lastBookOpen:d}=I.getBookMetadata(l);if(a&&this.saveBehavior===ve.NewOnly){const{lastBookModified:f,lastBookOpen:u}=I.getBookMetadata(a.name);if(f&&c&&f>=c&&(u||0)>=(d||0))return 0}return e instanceof File?await this.upload(i,l,s,a,e):await this.upload(i,l,s,a,await this.zipBookData(e,.2),.6),this.addBookCard(this.currentContext.title,{characters:o,lastBookModified:c,lastBookOpen:d}),0}async saveProgress(e){const r=I.getProgressFileName(e),i=e instanceof File?e:JSON.stringify(e),{titleId:s,files:a,file:l}=await this.getExternalFile("progress_","",.2,!1),{lastBookmarkModified:o,progress:c}=I.getProgressMetadata(r);if(l&&this.saveBehavior===ve.NewOnly){const{lastBookmarkModified:d}=I.getProgressMetadata(l.name);if(d&&o&&(d||0)>=(o||0))return}await this.upload(s,r,a,l,i),this.addBookCard(this.currentContext.title,{lastBookmarkModified:o,progress:c})}async saveCover(e){if(!e){I.reportProgress();return}const{titleId:r,files:i,file:s}=await this.getExternalFile("cover_","",.2,!1);if(!(s!=null&&s.id)){const a=await I.getCoverFileName(e);await this.upload(r,a,i,void 0,e)}this.titleToBookCard.has(this.currentContext.title)&&this.addBookCard(this.currentContext.title,{imagePath:e})}async deleteBookData(e,r){await this.ensureTitle();let i="";const s=[],a=ht(1),l=[];return qt.next({progressBase:1,maxProgress:e.length}),e.forEach(o=>l.push(a(async()=>{try{Ct(r);const c=this.titleToId.get(o);c&&await this.executeDelete(c),this.titleToFiles.delete(o);const d=this.titleToBookCard.get(o);d&&s.push(d.id),this.titleToId.delete(o),this.titleToBookCard.delete(o),re.dataListChanged$.next(this),I.reportProgress()}catch(c){i=$n(c,`Error deleting ${o}: `,[a])}}))),await Promise.all(l).catch(()=>{}),{error:i,deleted:s}}async request(e,r={},i="json",s=1){const a=await this.authManager.getToken(this.window,this.storageSourceName,this.askForStorageUnlock),l=this;return new Promise((o,c)=>{const d=new XMLHttpRequest;if(d.responseType=i,d.addEventListener("abort",()=>{c(new ml)}),r.trackDownload&&(this.currentLastProgressValue=0,this.currentProgressBase=s,d.onprogress=f=>{var u;if((u=l.cancelSignal)!=null&&u.aborted){d.abort();return}f.lengthComputable&&l.reportFunction(f.loaded,f.total)}),r.trackUpload&&(this.currentLastProgressValue=0,this.currentProgressBase=s,d.upload.onprogress=f=>{var u;if((u=l.cancelSignal)!=null&&u.aborted){d.abort();return}f.lengthComputable&&l.reportFunction(f.loaded,f.total)}),d.addEventListener("readystatechange",async function(){if(this.readyState===4)if(this.status>=200&&this.status<400)o(this.response);else{const u=await La(this);this.status===404?(kt.error(u),c(new Error("Resource not found. Refresh your current tab and try again"))):c(new Error(u))}},!1),d.open(r.method||"GET",e,!0),r.headers){const f=Object.entries(r.headers);for(let u=0,{length:m}=f;uf.name.startsWith(e));if(I.reportProgress(a),!c)return{titleId:l,file:void 0,files:o,data:void 0};let d;return r&&(d=await this.retrieve(c,r,a*2)),{titleId:l,file:c,files:o,data:d}}updateAfterUpload(e,r,i,s,a={}){if(s){const l=i.map(o=>{const c=o;return o.name===s.name&&(c.name=r),c});this.titleToFiles.set(this.currentContext.title,l)}else i.push({id:e,name:r,...a}),this.titleToFiles.set(this.currentContext.title,i)}}class L0 extends vl{constructor(e){super(Z.GDRIVE,e,qc);V(this,"baseFileApiUrl","https://www.googleapis.com/drive/v3/files");V(this,"baseUploadApiUrl","https://www.googleapis.com/upload/drive/v3/files")}setInternalSettings(e){const r=e||as.getValue();r!==this.storageSourceName&&this.clearData(),this.storageSourceName=r}async getBookList(){if(!this.dataListFetched){re.listLoading$.next(!0);try{await this.ensureTitle();const e=await this.list(`trashed=false and mimeType='application/vnd.google-apps.folder' and '${this.rootId}' in parents`,"files(id,name),nextPageToken"),r=new Map;for(let i=0,{length:s}=e;ic.id));const s=ht(1),a=[];i.forEach(l=>a.push(s(async()=>{this.setTitleData(this.groupExternalFiles(await this.list(`trashed=false and ('${l.join("' in parents or '")}' in parents)`,"files(id,name,thumbnailLink,parents),nextPageToken"),r))}))),await Promise.all(a).catch(l=>{throw s.clearQueue(),l})}this.dataListFetched=!0}catch(e){throw this.clearData(),e}}return[...this.titleToBookCard.values()]}async ensureTitle(e=I.rootName,r="root",i=!1){var c,d,f;if(e===I.rootName&&this.rootId)return this.rootId;const s=this.titleToId.get(e);if(s)return s;const a=I.sanitizeForFilename(e),l=new URLSearchParams;l.append("corpora","user"),l.append("spaces","drive"),l.append("fields","files(id)"),l.append("q",`trashed=false and '${r}' in parents and mimeType = 'application/vnd.google-apps.folder' and name = "${a}"`);let o=(f=(d=(c=await this.request(`${this.baseFileApiUrl}?${l.toString()}`))==null?void 0:c.files)==null?void 0:d[0])==null?void 0:f.id;if(!o&&!i){const u=JSON.stringify({mimeType:"application/vnd.google-apps.folder",name:a,parents:[r]});o=(await this.request(this.baseFileApiUrl,{method:"POST",body:u,headers:{"Content-Type":"application/json"}})).id}if(o&&this.titleToId.set(e,o),o&&e===I.rootName&&(this.rootId=o),!o&&e===I.rootName)throw new Error("Root folder not found");return o}async getExternalFiles(e){if((!this.cacheStorageData||!this.dataListFetched)&&!this.titleToFiles.has(this.currentContext.title)){const r=await this.list(`trashed=false and '${e}' in parents`,"files(id,name,thumbnailLink,parents)");if(r.length){const i=new Map;i.set(this.currentContext.title,r),this.setTitleData(i)}}return this.titleToFiles.get(this.currentContext.title)||[]}retrieve(e,r,i=1){const s=new URLSearchParams;return s.append("fields","files(name)"),s.append("alt","media"),this.request(`${this.baseFileApiUrl}/${e.id}?${s.toString()}`,{trackDownload:!0},r,i)}async upload(e,r,i,s,a,l=.8){const o=new FormData,c=new URLSearchParams;o.append("resource",new Blob([JSON.stringify(s?{name:r}:{name:r,parents:[e]})],{type:"application/json"})),a&&o.append("file",a),c.append("uploadType","multipart");const d=await this.request(`${this.baseUploadApiUrl}${s?`/${s.id}`:""}?${c.toString()}`,{method:s?"PATCH":"POST",body:o,trackUpload:!0},"json",l);return this.updateAfterUpload(d.id,d.name,i,s,{parents:[e]}),d}executeDelete(e){return this.request(`${this.baseFileApiUrl}/${e}`,{method:"DELETE"})}async list(e,r,i=[],s=""){const a=new URLSearchParams;a.append("corpora","user"),a.append("spaces","drive"),a.append("fields",r),a.append("q",e),s&&a.append("pageToken",s);const l=await this.request(`${this.baseFileApiUrl}?${a.toString()}`);return l&&(i.push(...l.files||[]),l.nextPageToken&&await this.list(e,r,i,l.nextPageToken)),i}groupExternalFiles(e,r){const i=new Map;for(let s=0,{length:a}=e;so.push(l(async()=>{var u,m;const{responses:d}=await this.request("https://graph.microsoft.com/v1.0/$batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requests:c})}),f=d.find(g=>g.status<200||g.status>299);if(f){const{body:g}=f;throw new Error(g.error_description||((u=g.error)==null?void 0:u.message)||g.error||"Received error on data retrival")}for(let g=0,{length:h}=d;g{throw l.clearQueue(),c})}this.dataListFetched=!0}catch(e){throw this.clearData(),e}}return[...this.titleToBookCard.values()]}async ensureTitle(e=I.rootName,r="root",i=!1){var c,d,f;if(e===I.rootName&&this.rootId)return this.rootId;const s=this.titleToId.get(e);if(s)return s;const a=I.sanitizeForFilename(e),l=new URLSearchParams;l.append("select","id,name"),l.append("filter",`name eq '${a}'`);let o="";if(e===I.rootName)o=(f=(d=(c=await this.request(`${this.baseEndpoint}/${r}/children?${l.toString()}`))==null?void 0:c.value)==null?void 0:d[0])==null?void 0:f.id;else if(this.rootId){const u=await this.list(this.rootId);for(let m=0,{length:g}=u;m{}),f}}if(!s)throw new Error("Renaming requires a remote id");return await this.rename(r,i,s,o)}executeDelete(e){return this.request(`${this.baseEndpoint}/${e}`,{method:"DELETE"})}async list(e="root",r=!1,i=[],s=""){let a;if(s)a=await this.request(s);else{const l=new URLSearchParams;l.append("select","id,name"),r&&l.append("expand","thumbnails"),a=await this.request(`${this.baseEndpoint}/${e}/children?${l.toString()}`)}return a&&(i.push(...a.value||[]),a["@odata.nextLink"]&&await this.list(e,r,i,a==null?void 0:a["@odata.nextLink"])),i}async setTitleData(e,r){var s,a,l,o;if(!r.length)return;const i={id:I.getDummyId(),title:e,imagePath:"",characters:0,lastBookModified:0,lastBookOpen:0,progress:0,lastBookmarkModified:0,isPlaceholder:!1};for(let c=0,{length:d}=r;cthis.dataListChanged$.pipe(Xr(void 0),ys(t=>{this.lastHandler=t}),ln(()=>Nr),ln(t=>bi(Promise.resolve(this.lastHandler||is(window,t,"")).then(e=>(kt.clearHistory(),e.getBookList()))).pipe(so(e=>{if(e instanceof Error){const r=kt.errorCount>1;kt.warn(e.message),Tr.dialogs$.next([{component:r?jc:cc,props:{title:"Failure",message:r?"Error(s) occurred":`An Error occured: ${e.message}`}}])}return t!==Z.BROWSER&&(this.lastHandler=void 0,Nr.next(Z.BROWSER)),[[]]}))),ys(()=>{this.lastHandler=void 0,this.listLoading$.next(!1)}),Qn({refCount:!0,bufferSize:1}))));V(this,"bookmarksChanged$",new $t);V(this,"bookmarks$",this.bookmarksChanged$.pipe(Xr(0),ln(()=>this.db$),ln(t=>t.getAll("bookmark")),Qn({refCount:!0,bufferSize:1})));V(this,"lastItemChanged$",new $t);V(this,"lastItem$",this.lastItemChanged$.pipe(Xr(0),ln(()=>this.db$),ln(t=>t.get("lastItem",Pn)),Qn({refCount:!0,bufferSize:1})));V(this,"storageSourcesChanged$",new $t);this.db=t,this.db$=bi(t).pipe(Qn({refCount:!0,bufferSize:1})),this.isReady$=this.db$.pipe(Wi(e=>!!e))}async getData(t){if(!Number.isNaN(t))return(await this.db).get("data",t)}async getDataByTitle(t){if(t)return(await this.db).getFromIndex("data","title",t)}async upsertData(t,e,r=!0,i=!0){const s=await this.db;let a,l;const o=s.transaction("data","readwrite"),{store:c}=o,d=await c.index("title").get(t.title);if(d)i&&(d.storageSource=void 0),e===ve.NewOnly&&d.lastBookModified&&t.lastBookModified&&d.lastBookModified>=t.lastBookModified&&(d.lastBookOpen||0)>=(t.lastBookOpen||0)?(l=d,a=d.id):(l={...t,id:d.id,...r?{lastBookModified:t.lastBookModified,lastBookOpen:t.lastBookOpen}:{lastBookModified:t.lastBookModified||d.lastBookModified,lastBookOpen:t.lastBookOpen||d.lastBookOpen},...i?{storageSource:void 0}:{}},a=await c.put(l));else{const f=t;a=await c.add(f),l={...t,id:a}}return await o.done,l}async deleteData(t,e){const r=await this.db,i=await r.get("lastItem",Pn),s=await r.getAllKeys("bookmark"),a=i==null?void 0:i.dataId,l=new Set(s),o=[],c=ht(1),d=[];let f="";return qt.next({progressBase:1,maxProgress:t.length}),t.forEach(u=>d.push(c(async()=>{try{Ct(e),o.push(await this.deleteSingleData(r,u,{lastItem:a,bookmarkIds:l}))}catch(m){f=$n(m,`Error deleting Book with id ${u}: `,[c])}}))),await Promise.all(d).catch(()=>{}),{error:f,deleted:o}}async getBookmark(t){return(await this.db).get("bookmark",t)}async putBookmark(t,e){const r=await this.db;let i;if(e===ve.Overwrite)i=await r.put("bookmark",t);else{const s=await r.get("bookmark",t.dataId);s&&s.lastBookmarkModified&&t.lastBookmarkModified&&(s.lastBookmarkModified||0)>=(t.lastBookmarkModified||0)?i=s.dataId:i=await r.put("bookmark",t)}return i}async putLastItem(t){const r=await(await this.db).put("lastItem",{dataId:t},Pn);return this.lastItemChanged$.next(),r}async deleteLastItem(){await(await this.db).delete("lastItem",Pn),this.lastItemChanged$.next()}async deleteSingleData(t,e,r){const i=["data"],s=r.lastItem===e,a=r.bookmarkIds.has(e);s&&i.push("lastItem"),a&&i.push("bookmark");const l=t.transaction(i,"readwrite");try{s&&await l.objectStore("lastItem").delete(Pn),a&&await l.objectStore("bookmark").delete(e),await l.objectStore("data").delete(e),await l.done,s&&this.lastItemChanged$.next()}catch(o){try{l.abort(),await l.done}catch{}throw o}return qt.next({progressToAdd:1}),e}async getStorageSources(){return(await this.db).getAll("storageSource")}async saveStorageSource(t,e,r,i){const a=(await this.db).transaction(["storageSource"],"readwrite");try{const l=a.objectStore("storageSource");e&&t.name!==e&&await l.delete(e),t.name===e?await l.put(t):await l.add(t),await a.done,r?yr.next(t.name):e&&yr.next(""),i?fi(t.name,t.type):e&&fi("",t.type)}catch(l){try{a.abort(),await a.done}catch{}throw l}}async deleteStorageSource(t,e,r){await(await this.db).delete("storageSource",t.name),e&&yr.next(""),r&&fi("",t.type)}}const j0=(n,t)=>t.some(e=>n instanceof e);let Ba,Pa;function W0(){return Ba||(Ba=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function H0(){return Pa||(Pa=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const yl=new WeakMap,Mi=new WeakMap,_l=new WeakMap,hi=new WeakMap,ss=new WeakMap;function q0(n){const t=new Promise((e,r)=>{const i=()=>{n.removeEventListener("success",s),n.removeEventListener("error",a)},s=()=>{e(Ht(n.result)),i()},a=()=>{r(n.error),i()};n.addEventListener("success",s),n.addEventListener("error",a)});return t.then(e=>{e instanceof IDBCursor&&yl.set(e,n)}).catch(()=>{}),ss.set(t,n),t}function Z0(n){if(Mi.has(n))return;const t=new Promise((e,r)=>{const i=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",a),n.removeEventListener("abort",a)},s=()=>{e(),i()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),i()};n.addEventListener("complete",s),n.addEventListener("error",a),n.addEventListener("abort",a)});Mi.set(n,t)}let Li={get(n,t,e){if(n instanceof IDBTransaction){if(t==="done")return Mi.get(n);if(t==="objectStoreNames")return n.objectStoreNames||_l.get(n);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Ht(n[t])},set(n,t,e){return n[t]=e,!0},has(n,t){return n instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in n}};function G0(n){Li=n(Li)}function X0(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){const r=n.call(pi(this),t,...e);return _l.set(r,t.sort?t.sort():[t]),Ht(r)}:H0().includes(n)?function(...t){return n.apply(pi(this),t),Ht(yl.get(this))}:function(...t){return Ht(n.apply(pi(this),t))}}function z0(n){return typeof n=="function"?X0(n):(n instanceof IDBTransaction&&Z0(n),j0(n,W0())?new Proxy(n,Li):n)}function Ht(n){if(n instanceof IDBRequest)return q0(n);if(hi.has(n))return hi.get(n);const t=z0(n);return t!==n&&(hi.set(n,t),ss.set(t,n)),t}const pi=n=>ss.get(n);function K0(n,t,{blocked:e,upgrade:r,blocking:i,terminated:s}={}){const a=indexedDB.open(n,t),l=Ht(a);return r&&a.addEventListener("upgradeneeded",o=>{r(Ht(a.result),o.oldVersion,o.newVersion,Ht(a.transaction),o)}),e&&a.addEventListener("blocked",o=>e(o.oldVersion,o.newVersion,o)),l.then(o=>{s&&o.addEventListener("close",()=>s()),i&&o.addEventListener("versionchange",c=>i(c.oldVersion,c.newVersion,c))}).catch(()=>{}),l}const Q0=["get","getKey","getAll","getAllKeys","count"],Y0=["put","add","delete","clear"],mi=new Map;function Na(n,t){if(!(n instanceof IDBDatabase&&!(t in n)&&typeof t=="string"))return;if(mi.get(t))return mi.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,i=Y0.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Q0.includes(e)))return;const s=async function(a,...l){const o=this.transaction(a,i?"readwrite":"readonly");let c=o.store;return r&&(c=c.index(l.shift())),(await Promise.all([c[e](...l),i&&o.done]))[0]};return mi.set(t,s),s}G0(n=>({...n,get:(t,e,r)=>Na(t,e)||n.get(t,e,r),has:(t,e)=>!!Na(t,e)||n.has(t,e)}));async function J0(n,t,e,r){n.createObjectStore("data",{keyPath:"id",autoIncrement:!0}).createIndex("title","title"),n.createObjectStore("bookmark",{keyPath:"dataId"}),n.createObjectStore("lastItem");const s=n,a=r,l={data:{},scrollX:{}};{let o=await a.objectStore("keyvaluepairs").openCursor();for(;o;){const c=/([^-]+)-(.+)/.exec(o.key);if(c)switch(c[1]){case"data":case"scrollX":l[c[1]][c[2]]=o.value;break}else o.key==="lastItem"&&(l[o.key]=o.value);o=await o.continue()}}await Promise.all(Object.entries(l.data).map(async([o,c])=>{const d=JSON.parse(c);if(eh(d)){const f={...d,blobs:{},hasThumb:!1,characters:0,lastBookModified:0,lastBookOpen:0},u=await r.objectStore("data").add(f),m=l.scrollX[o];m&&await r.objectStore("bookmark").put({dataId:u,scrollX:+m,progress:"0%",lastBookmarkModified:0}),l.lastItem===o&&r.objectStore("lastItem").put({dataId:u},0)}})),s.deleteObjectStore("keyvaluepairs"),s.deleteObjectStore("local-forage-detect-blob-support")}function eh(n){return typeof n=="object"&&n?["title","elementHtml","styleSheet"].every(t=>t in n&&typeof n[t]=="string"):!1}function th(n="books"){return K0(n,4,{async upgrade(t,e,r,i){switch(e){case 0:{t.createObjectStore("data",{keyPath:"id",autoIncrement:!0}).createIndex("title","title"),t.createObjectStore("bookmark",{keyPath:"dataId"}),t.createObjectStore("lastItem"),t.createObjectStore("storageSource",{keyPath:"name"});break}case 2:{await J0(t,e,r,i);break}case 3:{t.createObjectStore("storageSource",{keyPath:"name"});break}}}})}var kl=(n=>(n.Partial="partial",n.Full="full",n.Toggle="toggle",n))(kl||{});function Xe(n=vn){return Ur(n,t=>!!+t,t=>t?"1":"0")}function Pt(n=vn){return Ur(n,t=>+t,t=>`${t}`)}function El(n,t=vn){return Ur(t,e=>JSON.parse(e||n),e=>JSON.stringify(e))}function nh(n=vn){return El("{}",n)}function Tl(n=vn){return El("[]",n)}var Sl=(n=>(n.Continuous="continuous",n.Paginated="paginated",n))(Sl||{});const rh=Ve()("theme","light-theme"),ih=Pt()("autoScrollMultiplier",20),sh=Ve()("fontFamilyGroupOne",""),ah=Ve()("fontFamilyGroupTwo",""),oh=Pt()("fontSize",20),lh=Pt()("lineHeight",1.65),ch=Xe()("hideSpoilerImage",!0),dh=Xe()("hideFurigana",!1),fh=Ve()("furiganaStyle",kl.Partial),Al=Ve()("writingMode","vertical-rl"),rp=Al.pipe(Wi(n=>n==="vertical-rl")),uh=Ve()("viewMode",Sl.Paginated),hh=Pt()("secondDimensionMaxValue",0),ph=Pt()("firstDimensionMargin",0),mh=Pt()("swipeThreshold",10),gh=Xe()("disableWheelNavigation",!1),wh=Xe()("autoPositionOnResize",!0),bh=Xe()("avoidPageBreak",!1),xh=Xe()("customReadingPointEnabled",!1),vh=Xe()("selectionToBookmarkEnabled",!1),yh=Xe()("confirmClose",!1),_h=Xe()("autoBookmark",!1),kh=Pt()("pageColumns",0),Cl=Xe()("requestPersistentStorage",!0),Eh=Xe()("cacheStorageData",!1),Th=Ve()("autoReplication",ao.Off),Sh=Ve()("replicationSaveBehavior",ve.NewOnly),Ah=Xe()("showExternalPlaceholder",!1),as=Ve()("gDriveStorageSource",Ge.GDRIVE_DEFAULT),os=Ve()("oneDriveStorageSource",Ge.ONEDRIVE_DEFAULT),ls=Ve()("fsStorageSource",""),yr=Ve()("syncTarget",""),ip=Ve()("lastExportedTarget",Z.BACKUP),sp=Tl()("lastExportedTypes",[bn.PROGRESS]),ap=on({KeyB:ot.BOOKMARK,KeyR:ot.JUMP_TO_BOOKMARK,PageDown:ot.NEXT_PAGE,PageUp:ot.PREV_PAGE,Space:ot.AUTO_SCROLL_TOGGLE,KeyA:ot.AUTO_SCROLL_INCREASE,KeyD:ot.AUTO_SCROLL_DECREASE,KeyN:ot.PREV_CHAPTER,KeyM:ot.NEXT_CHAPTER,KeyT:ot.SET_READING_POINT}),Ch=th(),re=new $0(Ch),op=Xe()("domainHintSeen",!1),lp=nh()("booklistSortOptions",{[Z.BROWSER]:{property:"lastBookOpen",direction:Nn.DESC},[Z.GDRIVE]:{property:"title",direction:Nn.ASC},[Z.ONEDRIVE]:{property:"title",direction:Nn.ASC},[Z.FS]:{property:"title",direction:Nn.ASC}}),cp=Pt()("verticalCustomReadingPosition",100),dp=Pt()("horizontalCustomReadingPosition",0),Ih=on(!0),Fa=on(!1),fp=Tl()("userfonts",[]);export{a0 as $,ln as A,uc as B,Nc as C,o0 as D,Fa as E,kl as F,gh as G,xh as H,Oc as I,to as J,Bn as K,ph as L,cc as M,vh as N,mh as O,V0 as P,on as Q,Xr as R,Qn as S,hc as T,Fc as U,Sl as V,Uh as W,Dh as X,Mh as Y,Fh as Z,dl as _,Tr as a,Gh as a$,Pc as a0,Gl as a1,ot as a2,is as a3,Z as a4,ao as a5,rh as a6,Al as a7,Ge as a8,S0 as a9,bn as aA,Wh as aB,Wt as aC,lp as aD,ls as aE,os as aF,as as aG,I0 as aH,Jh as aI,kr as aJ,Nn as aK,jh as aL,Oh as aM,Rh as aN,$i as aO,sp as aP,ip as aQ,bl as aR,Mn as aS,Dn as aT,Qh as aU,Yh as aV,Ah as aW,I as aX,B0 as aY,P0 as aZ,Rn as a_,jc as aa,ap as ab,dp as ac,Vh as ad,$h as ae,rp as af,Eh as ag,Sh as ah,Nr as ai,yr as aj,Th as ak,yh as al,uh as am,cp as an,ih as ao,ah as ap,oh as aq,lh as ar,ch as as,dh as at,fh as au,hh as av,wh as aw,bh as ax,kh as ay,_h as az,Zh as b,ui as b0,Di as b1,fi as b2,Lh as b3,ve as b4,qh as b5,Gc as b6,np as c,op as d,M0 as e,tp as f,Ih as g,sh as h,ep as i,re as j,Wa as k,Ha as l,Wi as m,bi as n,qa as o,zr as p,io as q,Bt as r,pc as s,ys as t,fp as u,Hh as v,Ic as w,It as x,xt as y,f0 as z}; diff --git a/yuuna/assets/ttu-ebook-reader/_app/immutable/components/pages/b/_page.svelte-f75ac4b0.js b/yuuna/assets/ttu-ebook-reader/_app/immutable/components/pages/b/_page.svelte-f75ac4b0.js index cf387926e..c6ee6907a 100644 --- a/yuuna/assets/ttu-ebook-reader/_app/immutable/components/pages/b/_page.svelte-f75ac4b0.js +++ b/yuuna/assets/ttu-ebook-reader/_app/immutable/components/pages/b/_page.svelte-f75ac4b0.js @@ -1 +1 @@ -var xi=Object.defineProperty;var $i=(t,e,n)=>e in t?xi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var et=(t,e,n)=>($i(t,typeof e!="symbol"?e+"":e,n),n);import{S as Mt,i as Et,n as Dt,V as er,e as zt,W as tr,a as W,B as Nt,f as M,a2 as wn,h as nr,j as $,w as Me,s as ue,k as ee,l as te,x as Ee,c as fe,m as J,a8 as X,p as y,y as De,N as Ce,d as q,g as ut,t as Y,b as ft,z as Te,R as Tt,D as G,_ as Hn,T as Gn,a1 as ne,G as le,a5 as Wn,a9 as jo,q as we,r as Se,u as Ye,aa as io,ab as ce,ac as he,o as Xo,Y as or,Z as ir,F as rr,L as qo,a0 as ro,$ as ar,ad as lr,A as sr}from"../../../chunks/index-be8ea2fc.js";import{k as ur,l as Ko,n as Yo,o as fr,q as hn,r as Bt,s as cr,v as hr,w as dr,x as ht,y as wt,B as gn,z as Sn,A as Lt,m as Ke,C as $t,D as Uo,F as it,u as Jo,E as Kt,G as Qo,H as Zo,I as mn,J as xo,K as ao,t as _t,L as $o,c as jn,N as ei,O as gr,P as It,Q as mr,R as On,S as Ln,T as pr,U as Vn,V as Yt,W as ti,X as kr,Y as br,Z as Cr,f as Rt,i as _r,a as tt,_ as wr,$ as ni,a0 as Sr,a1 as Pr,a2 as bt,a3 as ln,a4 as sn,a5 as jt,M as Ct,a6 as vr,a7 as yr,a8 as lo,j as En,a9 as Rr,aa as Mr,p as so,ab as Er,ac as Dn,ad as zn,ae as Nn,af as Dr,ag as Tr,ah as Fr,ai as Br,aj as Ir,ak as Ar,g as Or,al as Lr,am as Vr,an as Tn,ao as Fn,h as zr,ap as Nr,aq as Hr,ar as Gr,as as Wr,at as jr,au as Xr,av as qr,aw as Kr,ax as Yr,ay as Ur,az as Jr,aA as uo}from"../../../chunks/store-fb60485f.js";import{p as Qr}from"../../../chunks/stores-6a6870f3.js";import{f as fo,g as co}from"../../../chunks/format-page-title-2ca75b98.js";import{F as ct,f as Xn,a as Jt,b as Zr,c as xr,d as $r,e as ea,g as ta}from"../../../chunks/fa-33dddbd3.js";import{t as oi,k as pn,l as Qt,_ as en,u as na,O as St,i as Ft,n as oa,h as ia,a as nt,m as mt,v as Bn}from"../../../chunks/error-handler-df8dffd6.js";import{i as ii}from"../../../chunks/fonts-e5a631ed.js";import{m as ra,t as st,c as Zt,f as ho}from"../../../chunks/index-61bb0c2c.js";import{r as yt,M as aa,m as qe,c as ri}from"../../../chunks/merged-header-icon-5b1d438d.js";import{a as la}from"../../../chunks/theme-option-f9f8f697.js";var Ut={schedule:function(t){var e=requestAnimationFrame,n=cancelAnimationFrame,i=Ut.delegate;i&&(e=i.requestAnimationFrame,n=i.cancelAnimationFrame);var o=e(function(r){n=void 0,t(r)});return new oi(function(){return n==null?void 0:n(o)})},requestAnimationFrame:function(){for(var t=[],e=0;e0?t.prototype.requestAsyncId.call(this,n,i,o):(n.actions.push(this),n._scheduled||(n._scheduled=Ut.requestAnimationFrame(function(){return n.flush(void 0)})))},e.prototype.recycleAsyncId=function(n,i,o){var r;if(o===void 0&&(o=0),o!=null?o>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,n,i,o);var a=n.actions;i!=null&&((r=a[a.length-1])===null||r===void 0?void 0:r.id)!==i&&(Ut.cancelAnimationFrame(i),n._scheduled=void 0)},e}(ai),ca=function(t){en(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.flush=function(n){this._active=!0;var i=this._scheduled;this._scheduled=void 0;var o=this.actions,r;n=n||o.shift();do if(r=n.execute(n.state,n.delay))break;while((n=o[0])&&n.id===i&&o.shift());if(this._active=!1,r){for(;(n=o[0])&&n.id===i&&o.shift();)n.unsubscribe();throw r}},e}(li),Pn=new ca(fa),Ht=new St(function(t){return t.complete()});function qn(){for(var t=[],e=0;e!r.parentChapter);let n=t.find(r=>r.progress<100);n||(n=t[t.length-1]);const i=n.parentChapter||n.reference,o=e.findIndex(r=>r.reference===i);return[e,o,i]}function Ia(t){let e,n;return{c(){e=new er(!1),n=zt(),this.h()},l(i){e=tr(i,!1),n=zt(),this.h()},h(){e.a=n},m(i,o){e.m(t[0],i,o),W(i,n,o)},p(i,[o]){o&1&&e.p(i[0])},i:Nt,o:Nt,d(i){i&&M(n),i&&e.d()}}}function Aa(t,e,n){let{html:i}=e;const o=wn();return nr(()=>{o("load")}),t.$$set=r=>{"html"in r&&n(0,i=r.html)},[i]}class ci extends Mt{constructor(e){super(),Et(this,e,Aa,Ia,Dt,{html:0})}}function Oa(t,e){var o;const n=(o=document.elementFromPoint(t,e))==null?void 0:o.closest("p");if(!n)return;const i=Sn(n);if(!!i.length)return{range:Yn(i[0]),parent:n}}function Yn(t,e=0,n=0){const i=new Range;return i.setStart(t,e),i.setEnd(t,n),i}function La(t,e){var a,l,f;const n=(a=t.getSelection())!=null&&a.toString().trim()?(l=t.getSelection())==null?void 0:l.getRangeAt(0):void 0;let i;if(n?i=n:i=e,!i)return;const o=(f=i.endContainer.parentElement)==null?void 0:f.closest("p");if(!o)return;const r=Sn(o);if(!!r.length)return Yn(r[0])}function po(t,e){const n=t.createRange();return n.selectNode(e),n.getBoundingClientRect()}function hi(t,e=250){var n;(n=t.getSelection())==null||n.removeAllRanges(),setTimeout(()=>{var i;(i=t.getSelection())==null||i.addRange(new Range)},e)}function di(t,e,n,i){const o=Math.min(Math.max(i,0),n?t.innerWidth/4:t.innerHeight/4),r=e.getBoundingClientRect(),a=n?o:r.left,l=n?t.innerWidth-o:r.right,f=n?r.top:o,u=n?r.bottom:t.innerHeight-o,g=Number(getComputedStyle(e).lineHeight.replace(/px$/,""));return{elLeftReferencePoint:a,elRightReferencePoint:l,elTopReferencePoint:f,elBottomReferencePoint:u,firstDimensionMargin:o,pointGap:g}}function qt(t,e,n,i=0){if(!t)return;const o=`animate-[pulse_${n}s_cubic-bezier(0.4,0,0.6,1)_${i?"1":"infinite"}]`;t.classList[e](o),i&&setTimeout(()=>t.classList.remove(o),i)}class Va{constructor(e,n,i,o,r=Pn){et(this,"enabled$",new gn(!1));this.multiplier=e,this.verticalMode=n,this.enabled$.pipe(Lt(a=>{if(!a)return Ht;let l=0;return Ca(0,r).pipe(Ke(()=>Date.now()),Da(),Ke(f=>this.calcNewPos(f)),Ke(f=>{l+=f;const u=Math.trunc(l);return l-=u,u}),$t(f=>f!==0))}),st(i)).subscribe(a=>{let l="top";n&&(l="left"),o.documentElement.scrollBy({[l]:a})})}toggle(){this.enabled$.next(!this.enabled$.getValue())}off(){this.enabled$.next(!1)}calcNewPos([e,n]){let i=.00365956;return this.verticalMode&&(i=-91489e-8),i*this.multiplier*(n-e)}}function At(t,e){return e==="rtl"?-t:t}class za{constructor(e,n,i){this.calculator=e,this.window=n,this.firstDimensionMargin=i}scrollToBookmark(e,n=0){const i=this.getBookmarkPosition(e);if(!i)return;const{scrollToData:o}=ko(i,this.firstDimensionMargin),r=this.calculator.verticalMode?"left":"top";o.left!==void 0&&r==="left"?o.left+=n:o.top!==void 0&&r==="top"&&(o.top-=n),this.window.scrollTo(o)}formatBookmarkData(e,n=0){const i=this.calculator.calcExploredCharCount(n),o=this.calculator.charCount,{verticalMode:r}=this.calculator,a=r?"scrollX":"scrollY";return{dataId:e,exploredCharCount:i,progress:i/o,[a]:this.window[a],lastBookmarkModified:new Date().getTime()}}formatBookmarkDataByRange(e){return this.formatBookmarkData(e)}getBookmarkBarPosition(e){const n=this.getBookmarkPosition(e);if(!!n)return ko(n,this.firstDimensionMargin).bookmarkPosData}getBookmarkPosition(e){if(!e.exploredCharCount)return;const{verticalMode:n}=this.calculator,i=this.getBookmarkTargetPosByScrollValue(e);if(i)return i;const o=this.calculator.getScrollPosByCharCount(e.exploredCharCount);return n?{scrollX:o}:{scrollY:o}}getBookmarkTargetPosByScrollValue(e){const{exploredCharCount:n}=e,i=o=>{const r=e[o];if(!r)return;const a=At(r,this.calculator.direction);if(this.calculator.getCharCountByScrollPos(a)===n)return{[o]:r}};return this.calculator.verticalMode?i("scrollX"):i("scrollY")}}function ko(t,e){return"scrollX"in t?{scrollToData:{left:t.scrollX},bookmarkPosData:{right:`${-t.scrollX+e}px`}}:{scrollToData:{top:t.scrollY},bookmarkPosData:{top:`${t.scrollY+e}px`}}}function gi(t){const e=(n,i,o,r)=>{if(or?e(n,i,a-1,r):e(n,a+1,o,r)};return(n,i)=>e(n,0,n.length-1,i)}function Na(){const t=(e,n,i,o)=>{if(i0?t(e,n,r-1,o):t(e,r+1,i,o)};return(e,n)=>t(e,0,e.length-1,n)}const Ha=Na(),Ga=gi(-1),Cn=gi(void 0);class mi{constructor(e,n,i,o,r){et(this,"charCount");et(this,"accumulatedCharCount");et(this,"paragraphPos");et(this,"paragraphs");et(this,"paragraphPosToAccCharCount",new Map);this.containerEl=e,this.axis=n,this.direction=i,this.scrollEl=o,this.document=r,this.paragraphs=Sn(e),this.paragraphPos=Array(this.paragraphs.length),this.accumulatedCharCount=[];let a=0;this.paragraphs.forEach(l=>{a+=Uo(l),this.accumulatedCharCount.push(a)}),this.charCount=a}get verticalMode(){return this.axis==="vertical"}updateParagraphPos(e=0){const n=this.scrollEl.getBoundingClientRect(),i=At(this.verticalMode?n.right:n.top,this.direction),o=Number(getComputedStyle(this.containerEl)[this.verticalMode?"paddingRight":"paddingTop"].replace(/px$/,"")),r=new Map;for(let a=0;a(this.verticalMode?f.width:f.height)<=0?this.paragraphPos[a-1]||0:At(this.verticalMode?f.left:f.bottom,this.direction)-i-o+e)();this.paragraphPos[a]=g;const P=r.get(g)||[];r.set(g,P),P.push(a)}this.paragraphPosToAccCharCount=new Map(Array.from(r.entries()).map(([a,l])=>[a,Math.max(...l.map(f=>this.accumulatedCharCount[f]))]))}calcExploredCharCount(e=0){return this.getCharCountByScrollPos(this.scrollPos+e)}getCharCountByScrollPos(e){const n=Cn(this.paragraphPos,e);return this.paragraphPosToAccCharCount.get(this.paragraphPos[n])||0}getBookMarkPosForSection(e,n){const i=Math.max(0,Ga(this.accumulatedCharCount,n-e));let o=i,r=this.processSectionBookmarkIteration(i,e,n);if(!r){for(let a=i+1,{length:l}=this.accumulatedCharCount;ai){let a=this.paragraphs[e];a.parentElement&&(a=a.parentElement.closest("p")||a.parentElement);const{top:l,right:f,left:u}=po(this.document,a);r=this.axis==="horizontal"?{left:f}:{top:l,left:u}}return r}get scrollPos(){return At(this.scrollEl[this.scrollPosProp],this.direction)}get scrollPosProp(){return this.verticalMode?"scrollLeft":"scrollTop"}}function Wa(t,e,n){const i=qa(e,n)(t,"scrollLeft");return(o,r,a)=>{if(!ja(o))return;const l=Xa(o,r,a);i(-l),o.preventDefault()}}function ja(t){return!(!t.deltaY||t.deltaX||t.altKey||t.shiftKey||t.ctrlKey||t.metaKey)}function Xa(t,e,n){switch(t.deltaMode){case 0:return t.deltaY;case 1:return t.deltaY*e*1.75;default:return t.deltaY*n}}function qa(t,e){return(n,i)=>{let o=!1,r=t[i],a=t[i];const l=()=>{o=!0;const f=Math.trunc((r-t[i])/n);if(t[i]!==a){o=!1;return}if(a+=f,t.scrollBy(f,0),Math.abs(f)>0){e(l);return}o=!1};return f=>{o||(r=t[i],a=t[i]),r+=f,o||e(l)}}}class Ka{constructor(e,n,i){this.verticalMode=e,this.firstDimensionMargin=n,this.window=i}nextPage(){this.scrollByPercent(.95)}prevPage(){this.scrollByPercent(-.95)}updateSectionDataByOffset(){}scrollTo(e){this.window.scrollTo({[this.verticalMode?"left":"top"]:e})}scrollByPercent(e){let n=this.window.innerHeight,i="top",o=1;this.verticalMode&&(n=this.window.innerWidth,i="left",o=-1);const r=n-this.firstDimensionMargin*2;this.window.scrollBy({[i]:r*e*o,behavior:"smooth"})}}const{document:bo,window:Ya}=Gn;function Co(t){let e,n,i,o,r;return{c(){e=$("div"),i=ue(),o=$("div"),this.h()},l(a){e=ee(a,"DIV",{class:!0,style:!0}),te(e).forEach(M),i=fe(a),o=ee(a,"DIV",{class:!0,style:!0}),te(o).forEach(M),this.h()},h(){J(e,"class","fixed z-[5]"),J(e,"style",n=t[23]+": 100%; "+t[22]+": "+t[15]+"px; "+t[21][0]+": 0"),X(e,"inset-y-0",t[2]),X(e,"inset-x-0",!t[2]),y(e,"background-color",t[4]),J(o,"class","fixed z-[5]"),J(o,"style",r=t[23]+": 100%; "+t[22]+": "+t[15]+"px; "+t[21][1]+": 0"),X(o,"inset-y-0",t[2]),X(o,"inset-x-0",!t[2]),y(o,"background-color",t[4])},m(a,l){W(a,e,l),W(a,i,l),W(a,o,l)},p(a,l){l[0]&14712832&&n!==(n=a[23]+": 100%; "+a[22]+": "+a[15]+"px; "+a[21][0]+": 0")&&J(e,"style",n),l[0]&4&&X(e,"inset-y-0",a[2]),l[0]&4&&X(e,"inset-x-0",!a[2]),l[0]&16&&y(e,"background-color",a[4]),l[0]&14712832&&r!==(r=a[23]+": 100%; "+a[22]+": "+a[15]+"px; "+a[21][1]+": 0")&&J(o,"style",r),l[0]&4&&X(o,"inset-y-0",a[2]),l[0]&4&&X(o,"inset-x-0",!a[2]),l[0]&16&&y(o,"background-color",a[4])},d(a){a&&M(e),a&&M(i),a&&M(o)}}}function _o(t){let e,n,i,o;const r=[Ja,Ua],a=[];function l(f,u){return f[2]?0:1}return e=l(t),n=a[e]=r[e](t),{c(){n.c(),i=zt()},l(f){n.l(f),i=zt()},m(f,u){a[e].m(f,u),W(f,i,u),o=!0},p(f,u){let g=e;e=l(f),e===g?a[e].p(f,u):(ut(),Y(a[g],1,1,()=>{a[g]=null}),ft(),n=a[e],n?n.p(f,u):(n=a[e]=r[e](f),n.c()),q(n,1),n.m(i.parentNode,i))},i(f){o||(q(n),o=!0)},o(f){Y(n),o=!1},d(f){a[e].d(f),f&&M(i)}}}function Ua(t){let e,n,i;return n=new ct({props:{icon:Jt}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","pointer-events-none absolute text-sm opacity-25 sm:text-xl"),y(e,"color",t[3]),y(e,"left",t[17]),y(e,"top",`calc(${t[19].top} + 1.5rem)`)},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&8&&y(e,"color",o[3]),r[0]&131072&&y(e,"left",o[17]),r[0]&524288&&y(e,"top",`calc(${o[19].top} + 1.5rem)`)},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function Ja(t){let e,n,i;return n=new ct({props:{icon:Jt}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","pointer-events-none absolute text-xl opacity-25"),y(e,"color",t[3]),y(e,"right",`calc(${t[19].right} + 1rem)`),y(e,"top",t[17])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&8&&y(e,"color",o[3]),r[0]&524288&&y(e,"right",`calc(${o[19].right} + 1rem)`),r[0]&131072&&y(e,"top",o[17])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function wo(t){let e,n,i;return n=new ct({props:{icon:Xn,spin:!0}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed inset-0 flex h-full w-full items-center justify-center text-7xl"),y(e,"color",t[3]),y(e,"background-color",t[4])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&8&&y(e,"color",o[3]),r[0]&16&&y(e,"background-color",o[4])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function Qa(t){let e,n,i=`${t[9]}px`,o=`${t[20]||t[1]}px`,r,a,l,f,u,g,P;n=new ci({props:{html:t[0]}}),n.$on("load",t[27]);let k=t[15]&&Co(t),m=t[19]&&_o(t),v=!t[18]&&wo(t);return{c(){e=$("div"),Me(n.$$.fragment),r=ue(),k&&k.c(),a=ue(),m&&m.c(),l=ue(),v&&v.c(),f=ue(),this.h()},l(s){e=ee(s,"DIV",{class:!0});var C=te(e);Ee(n.$$.fragment,C),C.forEach(M),r=fe(s),k&&k.l(s),a=fe(s),m&&m.l(s),l=fe(s),v&&v.l(s),f=fe(s),this.h()},h(){J(e,"class","book-content m-auto svelte-1ouz3ba"),X(e,"book-content--writing-vertical-rl",t[2]),X(e,"book-content--writing-horizontal-rl",!t[2]),X(e,"book-content--hide-furigana",t[12]),X(e,"book-content--hide-spoiler-image",t[11]),X(e,"book-content--furigana-style-partial",t[13]===it.Partial),X(e,"book-content--furigana-style-full",t[13]===it.Full),X(e,"book-content--furigana-style-toggle",t[13]===it.Toggle),y(e,"color",t[3]),y(e,"font-size",i),y(e,"line-height",t[10]),y(e,"max-width",!t[2]&&t[14]?`${t[14]}px`:void 0),y(e,"max-height",t[20]?`${t[20]}px`:void 0),y(e,"padding-left",t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"padding-right",t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"padding-top",!t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"padding-bottom",!t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"--font-family-serif",t[7]),y(e,"--font-family-sans-serif",t[8]),y(e,"--book-content-hint-furigana-font-color",t[5]),y(e,"--book-content-hint-furigana-shadow-color",t[6]),y(e,"--book-content-child-height",o)},m(s,C){W(s,e,C),De(n,e,null),t[49](e),W(s,r,C),k&&k.m(s,C),W(s,a,C),m&&m.m(s,C),W(s,l,C),v&&v.m(s,C),W(s,f,C),u=!0,g||(P=[Ce(Ya,"scroll",t[26]),Ce(bo.body,"wheel",t[25],{passive:!1}),Ce(bo.body,"mousedown",t[50])],g=!0)},p(s,C){const p={};C[0]&1&&(p.html=s[0]),n.$set(p),(!u||C[0]&4)&&X(e,"book-content--writing-vertical-rl",s[2]),(!u||C[0]&4)&&X(e,"book-content--writing-horizontal-rl",!s[2]),(!u||C[0]&4096)&&X(e,"book-content--hide-furigana",s[12]),(!u||C[0]&2048)&&X(e,"book-content--hide-spoiler-image",s[11]),(!u||C[0]&8192)&&X(e,"book-content--furigana-style-partial",s[13]===it.Partial),(!u||C[0]&8192)&&X(e,"book-content--furigana-style-full",s[13]===it.Full),(!u||C[0]&8192)&&X(e,"book-content--furigana-style-toggle",s[13]===it.Toggle),C[0]&8&&y(e,"color",s[3]),C[0]&512&&i!==(i=`${s[9]}px`)&&y(e,"font-size",i),C[0]&1024&&y(e,"line-height",s[10]),C[0]&16388&&y(e,"max-width",!s[2]&&s[14]?`${s[14]}px`:void 0),C[0]&1048576&&y(e,"max-height",s[20]?`${s[20]}px`:void 0),C[0]&32772&&y(e,"padding-left",s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&32772&&y(e,"padding-right",s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&32772&&y(e,"padding-top",!s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&32772&&y(e,"padding-bottom",!s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&128&&y(e,"--font-family-serif",s[7]),C[0]&256&&y(e,"--font-family-sans-serif",s[8]),C[0]&32&&y(e,"--book-content-hint-furigana-font-color",s[5]),C[0]&64&&y(e,"--book-content-hint-furigana-shadow-color",s[6]),C[0]&1048578&&o!==(o=`${s[20]||s[1]}px`)&&y(e,"--book-content-child-height",o),s[15]?k?k.p(s,C):(k=Co(s),k.c(),k.m(a.parentNode,a)):k&&(k.d(1),k=null),s[19]?m?(m.p(s,C),C[0]&524288&&q(m,1)):(m=_o(s),m.c(),q(m,1),m.m(l.parentNode,l)):m&&(ut(),Y(m,1,1,()=>{m=null}),ft()),s[18]?v&&(ut(),Y(v,1,1,()=>{v=null}),ft()):v?(v.p(s,C),C[0]&262144&&q(v,1)):(v=wo(s),v.c(),q(v,1),v.m(f.parentNode,f))},i(s){u||(q(n.$$.fragment,s),q(m),q(v),u=!0)},o(s){Y(n.$$.fragment,s),Y(m),Y(v),u=!1},d(s){s&&M(e),Te(n),t[49](null),s&&M(r),k&&k.d(s),s&&M(a),m&&m.d(s),s&&M(l),v&&v.d(s),s&&M(f),g=!1,Tt(P)}}}function Za(t,e,n){let i,o,r,a,l,f,u,g,P;G(t,Jo,S=>n(57,l=S)),G(t,Kt,S=>n(58,f=S)),G(t,Qo,S=>n(24,u=S)),G(t,Vt,S=>n(59,g=S)),G(t,Zo,S=>n(48,P=S));let{htmlContent:k}=e,{width:m}=e,{height:v}=e,{verticalMode:s}=e,{fontColor:C}=e,{backgroundColor:p}=e,{hintFuriganaFontColor:E}=e,{hintFuriganaShadowColor:N}=e,{fontFamilyGroupOne:R}=e,{fontFamilyGroupTwo:F}=e,{fontSize:z}=e,{lineHeight:K}=e,{hideSpoilerImage:D}=e,{hideFurigana:B}=e,{furiganaStyle:L}=e,{secondDimensionMaxValue:T}=e,{firstDimensionMargin:I}=e,{autoPositionOnResize:w}=e,{autoBookmark:V}=e,{loadingState:b}=e,{multiplier:A}=e,{bookmarkData:Q}=e,{exploredCharCount:re}=e,{bookCharCount:pe}=e,{autoScroller:Ve}=e,{bookmarkManager:Pe}=e,{pageManager:_e}=e,{customReadingPoint:Ie}=e,{customReadingPointLeft:ze}=e,{customReadingPointTop:de}=e,{customReadingPointScrollOffset:oe}=e;const ie=wn();let Fe=!1,U,Z,Ne={},ve,ye,_,O,He,j=0,Be=!1,ke=window.matchMedia("(min-width: 640px)").matches?"0.5rem":"0.25rem",Ae=!1;const dt=Wa(4,document.documentElement,requestAnimationFrame),Ue=new nt,be=new nt,me=new nt,Je=new Map,Qe=new Map;let ge=0,at=!1;Hn(()=>{me.next(),me.complete()}),ve=new Va(A,s,me,document),Ve=ve,Zt([Ue,be]).pipe($t(()=>w),mn(1),Ke(([S,ae])=>s?ae:S),si(),xt(10),xo(Pn),st(me)).subscribe(()=>{if(!Z||!_)return;const S=Z.getScrollPosByCharCount(j)+(s?oe:-oe);Be=!0,_.scrollTo(S)});function Ge(){if(!P||!U)return;const{elLeftReferencePoint:S,elTopReferencePoint:ae,elRightReferencePoint:We,elBottomReferencePoint:Oe,firstDimensionMargin:d,pointGap:x}=di(window,U,s,I);if(s){n(34,de=ae),n(33,ze=Math.min(Math.max(d+(We-S)*(Ie/100)-2,S+x),We-2)),n(35,oe=window.innerWidth-d-ze);return}n(34,de=Math.min(Math.max(d+(Oe-ae)*(Ie/100),d),Oe-x*1.5)),n(33,ze=S),n(35,oe=de-d)}function pt(S){S.updateParagraphPos(),Ge(),n(28,re=S.calcExploredCharCount(oe)),He&&(He=!1,Q.then(ae=>{!ae||!Pe||(j=ae.exploredCharCount||0,Pe.scrollToBookmark(ae,oe))}).finally(()=>{V&&rt(window,"scroll").pipe(mn(1),xt(3e3),st(me)).subscribe(()=>{ie("bookmark")}),Kn.pipe(Gt(1),Lt(ae=>ae.length?(ae.forEach(We=>{const Oe=We.reference,d=document.getElementById(Oe);d&&(ge||(ge=Number(getComputedStyle(d)[s?"marginLeft":"marginBottom"].replace(/px$/,""))/2),Qe.set(Oe,{...We,progress:0}),Je.set(Oe,d))}),Je.size?(je(),rt(window,"scroll")):Ht):Ht),Ra(()=>nn(at?100:500)),st(me)).subscribe(je)})),n(44,Ne={}),n(18,Fe=!0)}function je(){const S=[...Qe.entries()];for(let ae=0,{length:We}=S;ae{!Z||(n(28,re=Z.calcExploredCharCount(oe)),!Be&&re&&(j=re),Be=!1)})}function gt(){if(!U)return;n(43,Z=new mi(U,s?"vertical":"horizontal",s?"rtl":"ltr",document.documentElement,document)),n(28,re=0),j=re,n(29,pe=Z.charCount);let S=!1;try{S=document.fonts.check(`${z}px ${R||"Noto Serif JP"}`)}catch(ae){mt.error(`Error checking Font Load: ${ae.message}`),S=!0}if(S)ie("contentChange",U);else if(!Ae){Ae=!0;const ae=ii(R,l)?3e4:1e4,We=setTimeout(()=>{mt.error(`Error loading primary Font: ${R}`),ie("contentChange",U)},ae);document.fonts.addEventListener("loadingdone",()=>{clearTimeout(We),ie("contentChange",U)})}}rn.pipe(st(me)).subscribe(S=>{let ae=document.getElementById(S);if(!ae)return;ae=!S.startsWith(ao)&&ae.closest(`div[id^="${ao}"]`)||ae,at=!0;const Oe=ae.getBoundingClientRect();s?window.scrollBy(-(window.innerWidth-Oe.right-(I||0)-oe-(!oe||oe&&ge>oe?ge:0)),0):window.scrollBy(0,Oe.top-(I||0)-oe-(!oe||oe&&ge>oe?ge:0))});function Re(S){ne[S?"unshift":"push"](()=>{U=S,n(16,U)})}const kt=S=>{u&&S.button===1&&S.preventDefault()};return t.$$set=S=>{"htmlContent"in S&&n(0,k=S.htmlContent),"width"in S&&n(36,m=S.width),"height"in S&&n(1,v=S.height),"verticalMode"in S&&n(2,s=S.verticalMode),"fontColor"in S&&n(3,C=S.fontColor),"backgroundColor"in S&&n(4,p=S.backgroundColor),"hintFuriganaFontColor"in S&&n(5,E=S.hintFuriganaFontColor),"hintFuriganaShadowColor"in S&&n(6,N=S.hintFuriganaShadowColor),"fontFamilyGroupOne"in S&&n(7,R=S.fontFamilyGroupOne),"fontFamilyGroupTwo"in S&&n(8,F=S.fontFamilyGroupTwo),"fontSize"in S&&n(9,z=S.fontSize),"lineHeight"in S&&n(10,K=S.lineHeight),"hideSpoilerImage"in S&&n(11,D=S.hideSpoilerImage),"hideFurigana"in S&&n(12,B=S.hideFurigana),"furiganaStyle"in S&&n(13,L=S.furiganaStyle),"secondDimensionMaxValue"in S&&n(14,T=S.secondDimensionMaxValue),"firstDimensionMargin"in S&&n(15,I=S.firstDimensionMargin),"autoPositionOnResize"in S&&n(37,w=S.autoPositionOnResize),"autoBookmark"in S&&n(38,V=S.autoBookmark),"loadingState"in S&&n(39,b=S.loadingState),"multiplier"in S&&n(40,A=S.multiplier),"bookmarkData"in S&&n(41,Q=S.bookmarkData),"exploredCharCount"in S&&n(28,re=S.exploredCharCount),"bookCharCount"in S&&n(29,pe=S.bookCharCount),"autoScroller"in S&&n(30,Ve=S.autoScroller),"bookmarkManager"in S&&n(31,Pe=S.bookmarkManager),"pageManager"in S&&n(32,_e=S.pageManager),"customReadingPoint"in S&&n(42,Ie=S.customReadingPoint),"customReadingPointLeft"in S&&n(33,ze=S.customReadingPointLeft),"customReadingPointTop"in S&&n(34,de=S.customReadingPointTop),"customReadingPointScrollOffset"in S&&n(35,oe=S.customReadingPointScrollOffset)},t.$$.update=()=>{if(t.$$.dirty[0]&4&&n(23,i=s?"height":"width"),t.$$.dirty[0]&4&&n(22,o=s?"width":"height"),t.$$.dirty[0]&4&&n(21,r=s?["left","right"]:["top","bottom"]),t.$$.dirty[1]&32&&Ue.next(m),t.$$.dirty[0]&2&&be.next(v),t.$$.dirty[0]&16388&&n(20,a=s&&T?T:void 0),t.$$.dirty[0]&212996&&T&&U){const S=Number(getComputedStyle(U)[s?"marginTop":"marginRight"].replace(/px$/,""));n(17,ke=`min(max(calc(${`${S}px - ${ke}`}), ${ke}), ${S?`${S}px`:ke})`)}if(t.$$.dirty[0]&1&&k&&(He=!0),t.$$.dirty[0]&2|t.$$.dirty[1]&4384&&Z&&m&&v&&!b){const S=Z;requestAnimationFrame(()=>{pt(S)})}t.$$.dirty[0]&4|t.$$.dirty[1]&16896&&ve&&(n(45,ve.multiplier=A,ve),n(45,ve.verticalMode=s,ve)),t.$$.dirty[0]&32768|t.$$.dirty[1]&36864&&Z&&(n(46,ye=Z&&new za(Z,window,I||0)),n(31,Pe=ye)),t.$$.dirty[1]&41984&&Ne&&(n(19,O=void 0),Q.then(S=>{!S||n(19,O=ye==null?void 0:ye.getBookmarkBarPosition(S))})),t.$$.dirty[0]&32772|t.$$.dirty[1]&65536&&(n(47,_=new Ka(s,I,window)),n(32,_e=_)),t.$$.dirty[0]&65536|t.$$.dirty[1]&133120&&P&&U&&Number.isFinite(Ie)&&(Ge(),Xe(),je())},[k,v,s,C,p,E,N,R,F,z,K,D,B,L,T,I,U,ke,Fe,O,a,r,o,i,u,Ze,Xe,gt,re,pe,Ve,Pe,_e,ze,de,oe,m,w,V,b,A,Q,Ie,Z,Ne,ve,ye,_,P,Re,kt]}class xa extends Mt{constructor(e){super(),Et(this,e,Za,Qa,Dt,{htmlContent:0,width:36,height:1,verticalMode:2,fontColor:3,backgroundColor:4,hintFuriganaFontColor:5,hintFuriganaShadowColor:6,fontFamilyGroupOne:7,fontFamilyGroupTwo:8,fontSize:9,lineHeight:10,hideSpoilerImage:11,hideFurigana:12,furiganaStyle:13,secondDimensionMaxValue:14,firstDimensionMargin:15,autoPositionOnResize:37,autoBookmark:38,loadingState:39,multiplier:40,bookmarkData:41,exploredCharCount:28,bookCharCount:29,autoScroller:30,bookmarkManager:31,pageManager:32,customReadingPoint:42,customReadingPointLeft:33,customReadingPointTop:34,customReadingPointScrollOffset:35},null,[-1,-1,-1])}}const $a="px-4 md:px-8";function el(t){const e=Array.from(t.getElementsByTagName("img"));return new St(n=>{const i=e.filter(r=>r.src).map(tl);if(i.length<=0){n.next(!1),n.complete();return}const o=Zt(i).subscribe(()=>{n.next(!1),n.complete()});return n.next(!0),o})}function tl(t){return t.complete?qn(1):Sa(rt(t,"load"),rt(t,"error"))}function nl(t,e){const n=ol(t),i=rl(t);return o=>on(n(o),il(o,e),i(o))}function ol(t){return e=>{const n=Array.from(e.getElementsByTagName("a"));n.forEach(o=>{o.href=t.location.pathname+o.hash});const i=n.map(o=>_n(o).pipe(_t(()=>rn.next(o.hash.substring(1)))));return on(...i)}}function il(t,e){const n=e===it.Toggle,o=Array.from(t.getElementsByTagName("ruby")).map(r=>n?_n(r).pipe(_t(()=>{r.classList.toggle("reveal-rt")})):_n(r).pipe(Gt(1),_t(()=>{r.classList.add("reveal-rt")})));return on(...o)}function rl(t){return e=>{const i=Array.from(e.querySelectorAll("[data-ttu-spoiler-img]")).map(o=>{const r=t.createElement("span");return r.classList.add("spoiler-label"),r.setAttribute("aria-hidden","true"),r.innerText="ネタバレ",o.appendChild(r),_n(o).pipe(Gt(1),_t(()=>{o.removeChild(r),o.removeAttribute("data-ttu-spoiler-img")}))});return on(...i)}}function _n(t){return rt(t,"click").pipe(_t(e=>{e.preventDefault(),e.stopImmediatePropagation()}))}const al=300,ll=60,pi="none";function Xt(t,e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}function sl(t,e){return e.filter(n=>t.pointerId!==n.pointerId)}function un(t,e,n,i,o){t.dispatchEvent(new CustomEvent(`${e}${o}`,{detail:{event:n,pointersCount:i.length}}))}function ul(t,e,n,i,o,r=pi){e.style.touchAction=r;let a=[];function l(u){a.push(u),un(e,t,u,a,"down"),i==null||i(a,u);const g=u.pointerId;function P(p){g===p.pointerId&&(a=sl(p,a),a.length||k(),un(e,t,p,a,"up"),o==null||o(a,p))}function k(){m(),v(),s(),C()}const m=Xt(e,"pointermove",p=>{a=a.map(E=>p.pointerId===E.pointerId?p:E),un(e,t,p,a,"move"),n==null||n(a,p)}),v=Xt(e,"lostpointercapture",p=>{P(p)}),s=Xt(e,"pointerup",p=>{P(p)}),C=Xt(e,"pointerleave",p=>{a=[],k(),un(e,t,p,a,"up"),o==null||o(a,p)})}const f=Xt(e,"pointerdown",l);return{destroy:()=>{f()}}}function fl(t,e={timeframe:al,minSwipeDistance:ll,touchAction:pi}){const n="swipe";let i,o,r,a;function l(u,g){o=g.clientX,r=g.clientY,i=Date.now(),u.length===1&&(a=g.target)}function f(u,g){if(g.type==="pointerup"&&u.length===0&&Date.now()-i=2*v&&m>e.minSwipeDistance?s=P>0?"right":"left":v>=2*m&&v>e.minSwipeDistance&&(s=k>0?"bottom":"top"),s&&t.dispatchEvent(new CustomEvent(n,{detail:{direction:s,target:a}}))}}return ul(n,t,null,l,f,e.touchAction)}class cl{constructor(e,n,i,o,r){this.calculator=e,this.pageManager=n,this.sectionReady$=i,this.sectionIndex$=o,this.setIntendedCharCount=r}scrollToBookmark(e){const n=e.exploredCharCount;if(!n)return;const i=this.calculator.getSectionIndexByCharCount(n),o=l=>{const f=l.getScrollPosByCharCount(n);this.pageManager.scrollTo(f,!1),this.setIntendedCharCount(n)};if(this.sectionIndex$.getValue()===i){o(this.calculator);return}const a=this.sectionReady$.subscribe(l=>{o(l),a.unsubscribe()});this.sectionIndex$.next(i)}formatBookmarkData(e){return this.formatBookmarkDataByRange(e,void 0)}formatBookmarkDataByRange(e,n){const i=this.calculator.calcExploredCharCount(n),o=this.calculator.charCount;return{dataId:e,exploredCharCount:i,progress:i/o,lastBookmarkModified:new Date().getTime()}}}class hl{constructor(e,n,i,o,r,a,l,f,u,g,P){et(this,"translateX",0);et(this,"sectionData",new Map);this.contentEl=e,this.scrollEl=n,this.sections=i,this.sectionIndex$=o,this.virtualScrollPos$=r,this.width=a,this.height=l,this.pageGap=f,this.verticalMode=u,this.pageChange$=g,this.sectionRenderComplete$=P,Kn.pipe(Gt(1)).subscribe(k=>{!k.length||(k.forEach(m=>{this.sectionData.set(m.reference,{...m,progress:0})}),bn.next(this.sectionData))})}nextPage(){this.flipPage(1)}prevPage(){this.flipPage(-1)}updateSectionDataByOffset(e=0){var o,r;const n=this.verticalMode?this.height:this.width,i=this.virtualScrollPos$.getValue()/this.scrollEl[this.verticalMode?"scrollHeight":"scrollWidth"]*100;if(e){const l=(this.virtualScrollPos$.getValue()+n+this.pageGap)/this.scrollEl[this.verticalMode?"scrollHeight":"scrollWidth"]*100-i;this.updateSectionData((o=this.sections[this.sectionIndex$.getValue()])==null?void 0:o.id,i+l*e)}else this.updateSectionData((r=this.sections[this.sectionIndex$.getValue()])==null?void 0:r.id,i)}flipPage(e){const n=this.verticalMode?"scrollHeight":"scrollWidth",i=this.verticalMode?this.height:this.width,o=i+this.pageGap,r=!0;if(this.translateX){const P=()=>{this.contentEl.style.removeProperty("transform"),this.translateX=0};if(e<0){const k=this.translateX;P(),this.scrollToPos(-k-o,r);return}if(this.nextSection(r)){P();return}return}const a=0,l=this.scrollEl[n],f=this.virtualScrollPos$.getValue(),u=f+o*e,g=Math.ceil(u);if(g=l){this.nextSection(r);return}this.scrollOrTranslateToPos(u,l,i,r)}scrollTo(e,n){const i=this.verticalMode?"scrollHeight":"scrollWidth",o=this.verticalMode?this.height:this.width;this.scrollOrTranslateToPos(e,this.scrollEl[i],o,n)}prevSection(e,n,i,o){const r=this.sectionIndex$.getValue()-1;return r<0?!1:(this.updateSectionIndex(r).subscribe(()=>{const a=this.scrollEl[n];let l=e*(Math.ceil(a/e)-1);Math.ceil(l)>=a&&(l-=e),this.scrollOrTranslateToPos(l,a,i,o)}),!0)}nextSection(e){const n=this.sectionIndex$.getValue()+1;return n>=this.sections.length?!1:(this.updateSectionIndex(n).subscribe(()=>{var i,o;this.scrollToPos(0,e),this.updateSectionData((i=this.sections[n-1])==null?void 0:i.id,100,!1),this.updateSectionData((o=this.sections[n])==null?void 0:o.id,0)}),!0)}scrollOrTranslateToPos(e,n,i,o){var a;if(this.updateSectionData((a=this.sections[this.sectionIndex$.getValue()])==null?void 0:a.id,e/n*100),this.verticalMode){this.scrollToPos(e,o);return}if(e+i<=n){this.scrollToPos(e,o);return}this.translateXToPos(-e,o)}scrollToPos(e,n){this.virtualScrollPos$.next(e),this.scrollEl.scrollTo({[this.verticalMode?"top":"left"]:e}),this.pageChange$.next(n)}translateXToPos(e,n){this.virtualScrollPos$.next(-e),this.contentEl.style.transform=`translateX(${e}px)`,this.translateX=e,this.pageChange$.next(n)}updateSectionIndex(e){return new St(n=>{if(this.sectionIndex$.getValue()===e){n.next(),n.complete();return}const i=this.sectionRenderComplete$.subscribe(o=>{o===e&&n.next(),n.complete(),i.unsubscribe()});return this.sectionIndex$.next(e),i})}updateSectionData(e,n,i=!0){if(!e||!this.sectionData.has(e))return;const o=[...this.sectionData.values()];let r=!1;o.forEach(a=>{const l=this.sectionData.get(a.reference),f=a.reference===e;f?l.progress=n:r?l.progress=0:l.progress=100,!r&&f&&(r=!0),this.sectionData.set(a.reference,l)}),i&&bn.next(this.sectionData)}}class dl{constructor(e,n,i,o,r,a,l,f,u){et(this,"charCount");et(this,"sectionAccCharCounts");et(this,"sectionIndex",-1);et(this,"calculator");this.containerEl=e,this.sections=n,this.virtualScrollPos$=i,this.getWidth=o,this.getHeight=r,this.getPageGap=a,this.verticalMode=l,this.scrollEl=f,this.document=u;const g=k=>Sn(k).reduce((v,s)=>v+Uo(s),0);let P=0;this.sectionAccCharCounts=n.map(k=>(P+=g(k),P)),this.charCount=P}updateCurrentSection(e){this.calculator=new mi(this.containerEl,this.verticalMode?"horizontal":"vertical","ltr",this.scrollEl,this.document),this.sectionIndex=e}updateParagraphPos(){!this.calculator||this.calculator.updateParagraphPos(this.virtualScrollPos$.getValue())}calcExploredCharCount(e){if(e&&this.calculator)return this.getSectionStartCount()+this.calculator.getCharCountToPoint(e);const n=this.verticalMode?0:-this.screenSize;return this.getCharCountByScrollPos(this.virtualScrollPos$.getValue()+n)}getCharCountByScrollPos(e){if(!this.calculator)return-1;const n=this.getSectionStartCount();return this.calculator.getCharCountByScrollPos(e)+n}getSectionIndexByCharCount(e){return Cn(this.sectionAccCharCounts,e)+1}getScrollPosByCharCount(e){if(!this.calculator)return-1;const n=this.getSectionStartCount(),i=this.sectionAccCharCounts[this.sectionIndex],o=e-n,r=e===i&&i-n>0;if(o<0||e>i||r)return-1;if(o===0)return 0;const a=Cn(this.calculator.accumulatedCharCount,o),{accumulatedCharCount:l,paragraphPos:f}=this.calculator,u=l[a];if(Number.isNaN(Number(f[a])))return-1;const g=(s,C)=>s>=C?C:l[s]>u?s:g(s+1,C),P=f[g(a+1,l.length-1)],{screenSize:k}=this,m=this.verticalMode?-1:0,v=k*(Math.ceil(P/k)+m);return At(v,this.calculator.direction)}checkBookmarkOnScreen(e){const n=this.getScrollPosByCharCount(e),i=this.virtualScrollPos$.getValue();return n===i&&this.calculator?{isBookmarkScreen:!0,...this.calculator.getBookMarkPosForSection(this.getSectionStartCount(),e)}:{isBookmarkScreen:n===i,bookmarkPos:void 0,node:void 0,isFirstNode:!0}}getOffsetToRange(e,n){if(!e)return 0;const i=e.getBoundingClientRect();if(this.verticalMode)return 1-i.left/this.screenSizeMirrored;const o=Math.floor(100/n),r=Math.floor(this.screenSize/n),a=o*i.bottom/this.screenSizeMirrored;let l=a,f=0;for(let u=0;u=u;u+=r)l=f*o+a,f+=1;return l/100}getSectionStartCount(){return this.sectionAccCharCounts[this.sectionIndex-1]||0}get screenSize(){return(this.verticalMode?this.getHeight():this.getWidth())+this.getPageGap()}get screenSizeMirrored(){return(this.verticalMode?this.getWidth():this.getHeight())+this.getPageGap()}}const{window:gl}=Gn;function So(t){let e,n,i;return n=new ct({props:{icon:Xn,spin:!0}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed inset-0 flex h-full w-full items-center justify-center text-7xl"),y(e,"color",t[4]),y(e,"background-color",t[5])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&16&&y(e,"color",o[4]),r[0]&32&&y(e,"background-color",o[5])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function Po(t){let e,n,i;return n=new ct({props:{icon:Jt}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed h-3 w-3 text-base opacity-25 sm:text-xl"),y(e,"color",t[4]),y(e,"top",t[21]),y(e,"left",t[22]),y(e,"right",t[23])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&16&&y(e,"color",o[4]),r[0]&2097152&&y(e,"top",o[21]),r[0]&4194304&&y(e,"left",o[22]),r[0]&8388608&&y(e,"right",o[23])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function ml(t){let e,n,i,o,r=`${t[10]}px`,a=`${t[1]}px`,l=`${t[2]}px`,f=`${t[3]?t[1]:(t[1]+Ot)/t[24]-Ot}px`,u,g,P,k,m,v;i=new ci({props:{html:t[20]}}),i.$on("load",t[26]);let s=!t[19]&&So(t),C=t[0]&&Po(t);return{c(){e=$("div"),n=$("div"),Me(i.$$.fragment),u=ue(),s&&s.c(),g=ue(),C&&C.c(),P=zt(),this.h()},l(p){e=ee(p,"DIV",{class:!0});var E=te(e);n=ee(E,"DIV",{class:!0});var N=te(n);Ee(i.$$.fragment,N),N.forEach(M),E.forEach(M),u=fe(p),s&&s.l(p),g=fe(p),C&&C.l(p),P=zt(),this.h()},h(){J(n,"class","book-content-container svelte-u9j5ct"),J(e,"class","book-content m-auto svelte-u9j5ct"),X(e,"book-content--avoid-page-break",t[15]),X(e,"book-content--writing-vertical-rl",t[3]),X(e,"book-content--writing-horizontal-rl",!t[3]),X(e,"book-content--hide-furigana",t[13]),X(e,"book-content--hide-spoiler-image",t[12]),X(e,"book-content--furigana-style-partial",t[14]===it.Partial),X(e,"book-content--furigana-style-full",t[14]===it.Full),X(e,"book-content--furigana-style-toggle",t[14]===it.Toggle),y(e,"color",t[4]),y(e,"font-size",r),y(e,"line-height",t[11]),y(e,"padding-top",!t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"padding-bottom",!t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"padding-left",t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"padding-right",t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"max-width",t[1]?`${t[1]}px`:void 0),y(e,"max-height",t[3]&&t[2]?`${t[2]}px`:void 0),y(e,"--font-family-serif",t[8]),y(e,"--font-family-sans-serif",t[9]),y(e,"--book-content-hint-furigana-font-color",t[6]),y(e,"--book-content-hint-furigana-shadow-color",t[7]),y(e,"--book-content-child-width",a),y(e,"--book-content-child-height",l),y(e,"--book-content-child-column-width",!t[3]&&t[24]===1?`${t[1]}px`:""),y(e,"--book-content-column-count",t[24]),y(e,"--book-content-image-max-width",f)},m(p,E){W(p,e,E),le(e,n),De(i,n,null),t[44](n),t[45](e),W(p,u,E),s&&s.m(p,E),W(p,g,E),C&&C.m(p,E),W(p,P,E),k=!0,m||(v=[Ce(gl,"keydown",t[28]),Wn(o=fl.call(null,e,{timeframe:500,minSwipeDistance:t[25],touchAction:"pan-y"})),Ce(e,"swipe",t[27])],m=!0)},p(p,E){const N={};E[0]&1048576&&(N.html=p[20]),i.$set(N),o&&jo(o.update)&&E[0]&33554432&&o.update.call(null,{timeframe:500,minSwipeDistance:p[25],touchAction:"pan-y"}),(!k||E[0]&32768)&&X(e,"book-content--avoid-page-break",p[15]),(!k||E[0]&8)&&X(e,"book-content--writing-vertical-rl",p[3]),(!k||E[0]&8)&&X(e,"book-content--writing-horizontal-rl",!p[3]),(!k||E[0]&8192)&&X(e,"book-content--hide-furigana",p[13]),(!k||E[0]&4096)&&X(e,"book-content--hide-spoiler-image",p[12]),(!k||E[0]&16384)&&X(e,"book-content--furigana-style-partial",p[14]===it.Partial),(!k||E[0]&16384)&&X(e,"book-content--furigana-style-full",p[14]===it.Full),(!k||E[0]&16384)&&X(e,"book-content--furigana-style-toggle",p[14]===it.Toggle),E[0]&16&&y(e,"color",p[4]),E[0]&1024&&r!==(r=`${p[10]}px`)&&y(e,"font-size",r),E[0]&2048&&y(e,"line-height",p[11]),E[0]&65544&&y(e,"padding-top",!p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&65544&&y(e,"padding-bottom",!p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&65544&&y(e,"padding-left",p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&65544&&y(e,"padding-right",p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&2&&y(e,"max-width",p[1]?`${p[1]}px`:void 0),E[0]&12&&y(e,"max-height",p[3]&&p[2]?`${p[2]}px`:void 0),E[0]&256&&y(e,"--font-family-serif",p[8]),E[0]&512&&y(e,"--font-family-sans-serif",p[9]),E[0]&64&&y(e,"--book-content-hint-furigana-font-color",p[6]),E[0]&128&&y(e,"--book-content-hint-furigana-shadow-color",p[7]),E[0]&2&&a!==(a=`${p[1]}px`)&&y(e,"--book-content-child-width",a),E[0]&4&&l!==(l=`${p[2]}px`)&&y(e,"--book-content-child-height",l),E[0]&16777226&&y(e,"--book-content-child-column-width",!p[3]&&p[24]===1?`${p[1]}px`:""),E[0]&16777216&&y(e,"--book-content-column-count",p[24]),E[0]&16777226&&f!==(f=`${p[3]?p[1]:(p[1]+Ot)/p[24]-Ot}px`)&&y(e,"--book-content-image-max-width",f),p[19]?s&&(ut(),Y(s,1,1,()=>{s=null}),ft()):s?(s.p(p,E),E[0]&524288&&q(s,1)):(s=So(p),s.c(),q(s,1),s.m(g.parentNode,g)),p[0]?C?(C.p(p,E),E[0]&1&&q(C,1)):(C=Po(p),C.c(),q(C,1),C.m(P.parentNode,P)):C&&(ut(),Y(C,1,1,()=>{C=null}),ft())},i(p){k||(q(i.$$.fragment,p),q(s),q(C),k=!0)},o(p){Y(i.$$.fragment,p),Y(s),Y(C),k=!1},d(p){p&&M(e),Te(i),t[44](null),t[45](null),p&&M(u),s&&s.d(p),p&&M(g),C&&C.d(p),p&&M(P),m=!1,Tt(v)}}}const vo="overflow-hidden",Ot=40;function pl(t,e,n){let i,o,r,a,l,f,u,g,P;G(t,Kt,d=>n(51,o=d)),G(t,Vt,d=>n(52,r=d)),G(t,$o,d=>n(53,a=d)),G(t,jn,d=>n(54,l=d)),G(t,Jo,d=>n(55,f=d)),G(t,Qo,d=>n(56,u=d)),G(t,ei,d=>n(57,g=d)),G(t,gr,d=>n(25,P=d));let{htmlContent:k}=e,{width:m}=e,{height:v}=e,{verticalMode:s}=e,{fontColor:C}=e,{backgroundColor:p}=e,{hintFuriganaFontColor:E}=e,{hintFuriganaShadowColor:N}=e,{fontFamilyGroupOne:R}=e,{fontFamilyGroupTwo:F}=e,{fontSize:z}=e,{lineHeight:K}=e,{hideSpoilerImage:D}=e,{hideFurigana:B}=e,{furiganaStyle:L}=e,{loadingState:T}=e,{bookmarkData:I}=e,{pageManager:w}=e,{bookmarkManager:V}=e,{exploredCharCount:b}=e,{bookCharCount:A}=e,{isBookmarkScreen:Q=!1}=e,{avoidPageBreak:re=!0}=e,{pageColumns:pe}=e,{firstDimensionMargin:Ve}=e,{autoBookmark:Pe=!1}=e,{customReadingPointRange:_e}=e,{showCustomReadingPoint:Ie}=e;const ze=wn();let de,oe,ie,Fe=[],U,Z,Ne,ve=!1,ye="",_=!0,O=0,He=!1,j,Be,ke,Ae=!1;const dt=new nt,Ue=new nt,be=new gn(-1),me=new nt,Je=new gn(0),Qe=new nt,ge=new nt,at=be.pipe(Ke(d=>{var x;return((x=Fe[d])==null?void 0:x.innerHTML)||""})),Ge=new nt;Hn(()=>{document.body.classList.remove(vo),Ge.next(),Ge.complete()}),Zt([dt,Ue]).pipe(mn(1),Lt(()=>ge.pipe(Gt(1))),st(Ge)).subscribe(()=>{if(!ie||!U)return;const d=ie.getScrollPosByCharCount(O);d<0||U.scrollTo(d,!1)}),me.pipe(st(Ge)).subscribe(d=>{var x;!ie||(n(34,Ie=!1),qt((x=_e==null?void 0:_e.endContainer)==null?void 0:x.parentElement,"remove",1),n(29,_e=void 0),n(32,b=ie.calcExploredCharCount(_e)),d&&(O=b,g&&hi(window)),I.then(Re))}),Pe&&me.pipe(xt(3e3),st(Ge)).subscribe(d=>{d&&ze("bookmark")}),at.pipe(si(),st(Ge)).subscribe(()=>{n(19,ve=!1)}),at.pipe(st(Ge)).subscribe(d=>{const x=(h,lt)=>{if(lt===0){h();return}requestAnimationFrame(()=>x(h,lt-1))};x(()=>{n(20,ye=d)},2)}),It(()=>rt(document.body,"wheel",{passive:!0})).pipe($t(()=>!u&&!o),Ba(50),st(Ge)).subscribe(d=>{if(!r){let x=(d.deltaX<0?-1:1)*(s?-1:1);d.deltaX||(x=d.deltaY<0?-1:1),U==null||U.flipPage(x)}});function pt(d){!ie||(n(32,b=ie.calcExploredCharCount(d)),O=b,je(d))}function je(d){!U||!ie||U.updateSectionDataByOffset(ie.getOffsetToRange(d,i))}function Ze(){if(_){_=!1;return}if(!de)return;n(40,ie=new dl(de,Fe,Je,()=>m,()=>v,()=>Ot,s,de,document)),n(32,b=0),O=0,n(33,A=ie.charCount);let d=!1;try{d=document.fonts.check(`${z}px ${R||"Noto Serif JP"}`)}catch(x){mt.error(`Error checking Font Load: ${x.message}`),d=!0}if(d)Xe();else if(!Ae){Ae=!0;const x=ii(R,f)?3e4:1e4,h=setTimeout(()=>{mt.error(`Error loading primary Font: ${R}`),Xe()},x);document.fonts.addEventListener("loadingdone",()=>{clearTimeout(h),Xe()})}}function Xe(){!ie||(ie.updateCurrentSection(be.getValue()),ze("contentChange",de))}function gt(d){d.updateParagraphPos(),n(32,b=d.calcExploredCharCount(_e)),ge.next(d),I.then(Re),Ne&&(Ne=!1,I.then(x=>{!x||!V||(n(32,b=x.exploredCharCount||0),V.scrollToBookmark(x))})),n(19,ve=!0)}function Re(d){const x=d==null?void 0:d.exploredCharCount;if(!ie||!x)return;const h=ie.checkBookmarkOnScreen(x);if(de&&h.isBookmarkScreen){const lt=Number(getComputedStyle(de)[s?"marginTop":"marginRight"].replace(/px$/,""));h.bookmarkPos?s?(n(21,j=lt?`${lt}px`:"0.5rem"),n(22,Be=`${h.bookmarkPos.left}px`),n(23,ke=void 0)):(n(21,j=`${h.bookmarkPos.top}px`),n(23,ke=void 0),n(22,Be=h.bookmarkPos.left>0?`calc(${h.bookmarkPos.left}px - ${l?"15":"20"}px)`:`calc(${Math.max(l?15:20,lt)}px)`)):kt(lt)}else kt(0);h.isBookmarkScreen&&d.exploredCharCount&&(h.node&&!He&&!h.isFirstNode?je(Yn(h.node)):h.isFirstNode&&je(void 0),n(32,b=He?b:d.exploredCharCount),O=b,He=!0),n(0,Q=h.isBookmarkScreen)}function kt(d){s?(n(21,j=d?`${d}px`:"0.5rem"),n(22,Be=a?`${m-a}px`:void 0),n(23,ke=a?void 0:"0.75rem")):(n(21,j=a?`${a}px`:"0.5rem"),n(22,Be=d?`calc(${d}px + 0.75rem)`:"0.75rem"),n(23,ke=void 0))}function S(d){if(!U||r||o||d.detail.direction!=="left"&&d.detail.direction!=="right")return;const x=d.detail.direction==="left",h=s?!x:x;U.flipPage(h?1:-1)}function ae(d){if(!(!U||r||o))switch(d.code){case"ArrowLeft":U[s?"nextPage":"prevPage"]();break;case"ArrowRight":U[s?"prevPage":"nextPage"]();break;case"ArrowUp":U.prevPage();break;case"ArrowDown":U.nextPage();break}}rn.pipe(st(Ge)).subscribe(d=>{const x=Fe.findIndex(h=>h.id===d||h.querySelector(`[id="${d}"]`));x>-1&&(be.next(x),U==null||U.scrollTo(0,!0))});function We(d){ne[d?"unshift":"push"](()=>{oe=d,n(18,oe)})}function Oe(d){ne[d?"unshift":"push"](()=>{de=d,n(17,de)})}return t.$$set=d=>{"htmlContent"in d&&n(35,k=d.htmlContent),"width"in d&&n(1,m=d.width),"height"in d&&n(2,v=d.height),"verticalMode"in d&&n(3,s=d.verticalMode),"fontColor"in d&&n(4,C=d.fontColor),"backgroundColor"in d&&n(5,p=d.backgroundColor),"hintFuriganaFontColor"in d&&n(6,E=d.hintFuriganaFontColor),"hintFuriganaShadowColor"in d&&n(7,N=d.hintFuriganaShadowColor),"fontFamilyGroupOne"in d&&n(8,R=d.fontFamilyGroupOne),"fontFamilyGroupTwo"in d&&n(9,F=d.fontFamilyGroupTwo),"fontSize"in d&&n(10,z=d.fontSize),"lineHeight"in d&&n(11,K=d.lineHeight),"hideSpoilerImage"in d&&n(12,D=d.hideSpoilerImage),"hideFurigana"in d&&n(13,B=d.hideFurigana),"furiganaStyle"in d&&n(14,L=d.furiganaStyle),"loadingState"in d&&n(36,T=d.loadingState),"bookmarkData"in d&&n(37,I=d.bookmarkData),"pageManager"in d&&n(30,w=d.pageManager),"bookmarkManager"in d&&n(31,V=d.bookmarkManager),"exploredCharCount"in d&&n(32,b=d.exploredCharCount),"bookCharCount"in d&&n(33,A=d.bookCharCount),"isBookmarkScreen"in d&&n(0,Q=d.isBookmarkScreen),"avoidPageBreak"in d&&n(15,re=d.avoidPageBreak),"pageColumns"in d&&n(38,pe=d.pageColumns),"firstDimensionMargin"in d&&n(16,Ve=d.firstDimensionMargin),"autoBookmark"in d&&n(39,Pe=d.autoBookmark),"customReadingPointRange"in d&&n(29,_e=d.customReadingPointRange),"showCustomReadingPoint"in d&&n(34,Ie=d.showCustomReadingPoint)},t.$$.update=()=>{if(t.$$.dirty[1]&64&&I.then(d=>{He=!1,Re(d)}),t.$$.dirty[0]&2&&m&&dt.next(m),t.$$.dirty[0]&4&&v&&Ue.next(v),t.$$.dirty[0]&10|t.$$.dirty[1]&128&&n(24,i=s?1:pe||Math.ceil(m/1e3)),t.$$.dirty[1]&16&&k&&(Ne=!0),t.$$.dirty[1]&16){const d=document.createElement("div");d.innerHTML=k,n(41,Fe=Array.from(d.children)),be.next(0)}if(t.$$.dirty[0]&393230|t.$$.dirty[1]&3072&&oe&&de&&Fe&&(n(42,U=new hl(oe,de,Fe,be,Je,m,v,Ot,s,me,Qe)),n(30,w=U)),t.$$.dirty[0]&6|t.$$.dirty[1]&544&&ie&&m&&v&&!T){const d=ie;requestAnimationFrame(()=>{gt(d)})}t.$$.dirty[1]&544&&ie&&!T&&Qe.next(be.getValue()),t.$$.dirty[1]&6656&&ie&&U&&(n(43,Z=new cl(ie,U,ge,be,d=>O=d)),n(31,V=Z)),t.$$.dirty[0]&536870912&&pt(_e)},document.body.classList.add(vo),[Q,m,v,s,C,p,E,N,R,F,z,K,D,B,L,re,Ve,de,oe,ve,ye,j,Be,ke,i,P,Ze,S,ae,_e,w,V,b,A,Ie,k,T,I,pe,Pe,ie,Fe,U,Z,We,Oe]}class kl extends Mt{constructor(e){super(),Et(this,e,pl,ml,Dt,{htmlContent:35,width:1,height:2,verticalMode:3,fontColor:4,backgroundColor:5,hintFuriganaFontColor:6,hintFuriganaShadowColor:7,fontFamilyGroupOne:8,fontFamilyGroupTwo:9,fontSize:10,lineHeight:11,hideSpoilerImage:12,hideFurigana:13,furiganaStyle:14,loadingState:36,bookmarkData:37,pageManager:30,bookmarkManager:31,exploredCharCount:32,bookCharCount:33,isBookmarkScreen:0,avoidPageBreak:15,pageColumns:38,firstDimensionMargin:16,autoBookmark:39,customReadingPointRange:29,showCustomReadingPoint:34},null,[-1,-1,-1])}}function bl(t){let e,n,i,o,r,a,l,f,u,g;function P(R){t[59](R)}function k(R){t[60](R)}function m(R){t[61](R)}function v(R){t[62](R)}function s(R){t[63](R)}function C(R){t[64](R)}function p(R){t[65](R)}function E(R){t[66](R)}let N={htmlContent:t[13],width:t[35]??0,height:t[36]??0,verticalMode:t[14],fontColor:t[15],backgroundColor:t[16],hintFuriganaFontColor:t[17],hintFuriganaShadowColor:t[18],fontFamilyGroupOne:t[19],fontFamilyGroupTwo:t[20],fontSize:t[21],lineHeight:t[22],hideSpoilerImage:t[23],hideFurigana:t[24],furiganaStyle:t[25],loadingState:t[37]??!0,avoidPageBreak:t[29],pageColumns:t[30],autoBookmark:t[31],firstDimensionMargin:t[27]};return t[0]!==void 0&&(N.exploredCharCount=t[0]),t[1]!==void 0&&(N.bookCharCount=t[1]),t[6]!==void 0&&(N.isBookmarkScreen=t[6]),t[2]!==void 0&&(N.bookmarkData=t[2]),t[4]!==void 0&&(N.bookmarkManager=t[4]),t[5]!==void 0&&(N.pageManager=t[5]),t[11]!==void 0&&(N.customReadingPointRange=t[11]),t[12]!==void 0&&(N.showCustomReadingPoint=t[12]),e=new kl({props:N}),ne.push(()=>ce(e,"exploredCharCount",P,t[0])),ne.push(()=>ce(e,"bookCharCount",k,t[1])),ne.push(()=>ce(e,"isBookmarkScreen",m,t[6])),ne.push(()=>ce(e,"bookmarkData",v,t[2])),ne.push(()=>ce(e,"bookmarkManager",s,t[4])),ne.push(()=>ce(e,"pageManager",C,t[5])),ne.push(()=>ce(e,"customReadingPointRange",p,t[11])),ne.push(()=>ce(e,"showCustomReadingPoint",E,t[12])),e.$on("contentChange",t[67]),e.$on("bookmark",t[68]),{c(){Me(e.$$.fragment)},l(R){Ee(e.$$.fragment,R)},m(R,F){De(e,R,F),g=!0},p(R,F){const z={};F[0]&8192&&(z.htmlContent=R[13]),F[1]&16&&(z.width=R[35]??0),F[1]&32&&(z.height=R[36]??0),F[0]&16384&&(z.verticalMode=R[14]),F[0]&32768&&(z.fontColor=R[15]),F[0]&65536&&(z.backgroundColor=R[16]),F[0]&131072&&(z.hintFuriganaFontColor=R[17]),F[0]&262144&&(z.hintFuriganaShadowColor=R[18]),F[0]&524288&&(z.fontFamilyGroupOne=R[19]),F[0]&1048576&&(z.fontFamilyGroupTwo=R[20]),F[0]&2097152&&(z.fontSize=R[21]),F[0]&4194304&&(z.lineHeight=R[22]),F[0]&8388608&&(z.hideSpoilerImage=R[23]),F[0]&16777216&&(z.hideFurigana=R[24]),F[0]&33554432&&(z.furiganaStyle=R[25]),F[1]&64&&(z.loadingState=R[37]??!0),F[0]&536870912&&(z.avoidPageBreak=R[29]),F[0]&1073741824&&(z.pageColumns=R[30]),F[1]&1&&(z.autoBookmark=R[31]),F[0]&134217728&&(z.firstDimensionMargin=R[27]),!n&&F[0]&1&&(n=!0,z.exploredCharCount=R[0],he(()=>n=!1)),!i&&F[0]&2&&(i=!0,z.bookCharCount=R[1],he(()=>i=!1)),!o&&F[0]&64&&(o=!0,z.isBookmarkScreen=R[6],he(()=>o=!1)),!r&&F[0]&4&&(r=!0,z.bookmarkData=R[2],he(()=>r=!1)),!a&&F[0]&16&&(a=!0,z.bookmarkManager=R[4],he(()=>a=!1)),!l&&F[0]&32&&(l=!0,z.pageManager=R[5],he(()=>l=!1)),!f&&F[0]&2048&&(f=!0,z.customReadingPointRange=R[11],he(()=>f=!1)),!u&&F[0]&4096&&(u=!0,z.showCustomReadingPoint=R[12],he(()=>u=!1)),e.$set(z)},i(R){g||(q(e.$$.fragment,R),g=!0)},o(R){Y(e.$$.fragment,R),g=!1},d(R){Te(e,R)}}}function Cl(t){let e,n,i,o,r,a,l,f,u,g,P,k;function m(D){t[47](D)}function v(D){t[48](D)}function s(D){t[49](D)}function C(D){t[50](D)}function p(D){t[51](D)}function E(D){t[52](D)}function N(D){t[53](D)}function R(D){t[54](D)}function F(D){t[55](D)}function z(D){t[56](D)}let K={htmlContent:t[13],width:t[35]??0,height:t[36]??0,verticalMode:t[14],fontColor:t[15],backgroundColor:t[16],hintFuriganaFontColor:t[17],hintFuriganaShadowColor:t[18],fontFamilyGroupOne:t[19],fontFamilyGroupTwo:t[20],fontSize:t[21],lineHeight:t[22],hideSpoilerImage:t[23],hideFurigana:t[24],furiganaStyle:t[25],secondDimensionMaxValue:t[26],firstDimensionMargin:t[27],autoPositionOnResize:t[28],autoBookmark:t[31],multiplier:t[33],loadingState:t[37]??!0};return t[0]!==void 0&&(K.exploredCharCount=t[0]),t[1]!==void 0&&(K.bookCharCount=t[1]),t[2]!==void 0&&(K.bookmarkData=t[2]),t[3]!==void 0&&(K.autoScroller=t[3]),t[4]!==void 0&&(K.bookmarkManager=t[4]),t[5]!==void 0&&(K.pageManager=t[5]),t[7]!==void 0&&(K.customReadingPoint=t[7]),t[8]!==void 0&&(K.customReadingPointTop=t[8]),t[9]!==void 0&&(K.customReadingPointLeft=t[9]),t[10]!==void 0&&(K.customReadingPointScrollOffset=t[10]),e=new xa({props:K}),ne.push(()=>ce(e,"exploredCharCount",m,t[0])),ne.push(()=>ce(e,"bookCharCount",v,t[1])),ne.push(()=>ce(e,"bookmarkData",s,t[2])),ne.push(()=>ce(e,"autoScroller",C,t[3])),ne.push(()=>ce(e,"bookmarkManager",p,t[4])),ne.push(()=>ce(e,"pageManager",E,t[5])),ne.push(()=>ce(e,"customReadingPoint",N,t[7])),ne.push(()=>ce(e,"customReadingPointTop",R,t[8])),ne.push(()=>ce(e,"customReadingPointLeft",F,t[9])),ne.push(()=>ce(e,"customReadingPointScrollOffset",z,t[10])),e.$on("contentChange",t[57]),e.$on("bookmark",t[58]),{c(){Me(e.$$.fragment)},l(D){Ee(e.$$.fragment,D)},m(D,B){De(e,D,B),k=!0},p(D,B){const L={};B[0]&8192&&(L.htmlContent=D[13]),B[1]&16&&(L.width=D[35]??0),B[1]&32&&(L.height=D[36]??0),B[0]&16384&&(L.verticalMode=D[14]),B[0]&32768&&(L.fontColor=D[15]),B[0]&65536&&(L.backgroundColor=D[16]),B[0]&131072&&(L.hintFuriganaFontColor=D[17]),B[0]&262144&&(L.hintFuriganaShadowColor=D[18]),B[0]&524288&&(L.fontFamilyGroupOne=D[19]),B[0]&1048576&&(L.fontFamilyGroupTwo=D[20]),B[0]&2097152&&(L.fontSize=D[21]),B[0]&4194304&&(L.lineHeight=D[22]),B[0]&8388608&&(L.hideSpoilerImage=D[23]),B[0]&16777216&&(L.hideFurigana=D[24]),B[0]&33554432&&(L.furiganaStyle=D[25]),B[0]&67108864&&(L.secondDimensionMaxValue=D[26]),B[0]&134217728&&(L.firstDimensionMargin=D[27]),B[0]&268435456&&(L.autoPositionOnResize=D[28]),B[1]&1&&(L.autoBookmark=D[31]),B[1]&4&&(L.multiplier=D[33]),B[1]&64&&(L.loadingState=D[37]??!0),!n&&B[0]&1&&(n=!0,L.exploredCharCount=D[0],he(()=>n=!1)),!i&&B[0]&2&&(i=!0,L.bookCharCount=D[1],he(()=>i=!1)),!o&&B[0]&4&&(o=!0,L.bookmarkData=D[2],he(()=>o=!1)),!r&&B[0]&8&&(r=!0,L.autoScroller=D[3],he(()=>r=!1)),!a&&B[0]&16&&(a=!0,L.bookmarkManager=D[4],he(()=>a=!1)),!l&&B[0]&32&&(l=!0,L.pageManager=D[5],he(()=>l=!1)),!f&&B[0]&128&&(f=!0,L.customReadingPoint=D[7],he(()=>f=!1)),!u&&B[0]&256&&(u=!0,L.customReadingPointTop=D[8],he(()=>u=!1)),!g&&B[0]&512&&(g=!0,L.customReadingPointLeft=D[9],he(()=>g=!1)),!P&&B[0]&1024&&(P=!0,L.customReadingPointScrollOffset=D[10],he(()=>P=!1)),e.$set(L)},i(D){k||(q(e.$$.fragment,D),k=!0)},o(D){Y(e.$$.fragment,D),k=!1},d(D){Te(e,D)}}}function _l(t){let e,n,i,o,r=(t[38]??"")+"",a,l;const f=[Cl,bl],u=[];function g(P,k){return P[32]===Yt.Continuous?0:1}return n=g(t),i=u[n]=f[n](t),{c(){e=$("div"),i.c(),o=ue(),a=we(r),this.h()},l(P){e=ee(P,"DIV",{class:!0});var k=te(e);i.l(k),k.forEach(M),o=fe(P),a=Se(P,r),this.h()},h(){J(e,"class",$a+" py-8")},m(P,k){W(P,e,k),u[n].m(e,null),t[69](e),W(P,o,k),W(P,a,k),l=!0},p(P,k){let m=n;n=g(P),n===m?u[n].p(P,k):(ut(),Y(u[m],1,1,()=>{u[m]=null}),ft(),i=u[n],i?i.p(P,k):(i=u[n]=f[n](P),i.c()),q(i,1),i.m(e,null)),(!l||k[1]&128)&&r!==(r=(P[38]??"")+"")&&Ye(a,r)},i(P){l||(q(i),l=!0)},o(P){Y(i),l=!1},d(P){P&&M(e),u[n].d(),t[69](null),P&&M(o),P&&M(a)}}}function fn(t){return Number(t.replace(/px$/,""))}function wl(t,e,n){let i,o,r,a,l,f,{htmlContent:u}=e,{width:g}=e,{height:P}=e,{verticalMode:k}=e,{fontColor:m}=e,{backgroundColor:v}=e,{hintFuriganaFontColor:s}=e,{hintFuriganaShadowColor:C}=e,{fontFamilyGroupOne:p}=e,{fontFamilyGroupTwo:E}=e,{fontSize:N}=e,{lineHeight:R}=e,{hideSpoilerImage:F}=e,{hideFurigana:z}=e,{furiganaStyle:K}=e,{secondDimensionMaxValue:D}=e,{firstDimensionMargin:B}=e,{autoPositionOnResize:L}=e,{avoidPageBreak:T}=e,{pageColumns:I}=e,{autoBookmark:w}=e,{viewMode:V}=e,{exploredCharCount:b}=e,{bookCharCount:A}=e,{multiplier:Q}=e,{bookmarkData:re}=e,{autoScroller:pe}=e,{bookmarkManager:Ve}=e,{pageManager:Pe}=e,{isBookmarkScreen:_e}=e,{customReadingPoint:Ie}=e,{customReadingPointTop:ze}=e,{customReadingPointLeft:de}=e,{customReadingPointScrollOffset:oe}=e,{customReadingPointRange:ie}=e,{showCustomReadingPoint:Fe}=e;const U=new nt,Z=new nt,Ne=mr(null);G(t,Ne,h=>n(34,o=h));const ve=Zt([Ne.pipe($t(h=>!!h)),Zt([U,Z]).pipe(On(0))]).pipe(xt(0,Pn),Ke(([h])=>getComputedStyle(h)),Ln({refCount:!0,bufferSize:1})),ye=new pr(1),_=ve.pipe(Ke(h=>Be(g-fn(h.paddingLeft)-fn(h.paddingRight))));G(t,_,h=>n(35,r=h));const O=ve.pipe(Ke(h=>ke(P-fn(h.paddingTop)-fn(h.paddingBottom)-i)));G(t,O,h=>n(36,a=h));const He=It(()=>qn(document)).pipe(hn(h=>{const lt=nl(h,K);return ye.pipe(hn(an=>lt(an)))}),yt());G(t,He,h=>n(38,f=h));const j=ye.pipe(hn(h=>el(h)),Vn());G(t,j,h=>n(37,l=h));function Be(h){return Yt.Paginated===V&&!k&&D?Math.min(D,h):h}function ke(h){return Yt.Paginated===V&&k&&D?Math.min(D,h):h}function Ae(h){b=h,n(0,b)}function dt(h){A=h,n(1,A)}function Ue(h){re=h,n(2,re)}function be(h){pe=h,n(3,pe)}function me(h){Ve=h,n(4,Ve)}function Je(h){Pe=h,n(5,Pe)}function Qe(h){Ie=h,n(7,Ie)}function ge(h){ze=h,n(8,ze)}function at(h){de=h,n(9,de)}function Ge(h){oe=h,n(10,oe)}const pt=h=>ye.next(h.detail);function je(h){io.call(this,t,h)}function Ze(h){b=h,n(0,b)}function Xe(h){A=h,n(1,A)}function gt(h){_e=h,n(6,_e)}function Re(h){re=h,n(2,re)}function kt(h){Ve=h,n(4,Ve)}function S(h){Pe=h,n(5,Pe)}function ae(h){ie=h,n(11,ie)}function We(h){Fe=h,n(12,Fe)}const Oe=h=>ye.next(h.detail);function d(h){io.call(this,t,h)}function x(h){ne[h?"unshift":"push"](()=>{o=h,Ne.set(o)})}return t.$$set=h=>{"htmlContent"in h&&n(13,u=h.htmlContent),"width"in h&&n(45,g=h.width),"height"in h&&n(46,P=h.height),"verticalMode"in h&&n(14,k=h.verticalMode),"fontColor"in h&&n(15,m=h.fontColor),"backgroundColor"in h&&n(16,v=h.backgroundColor),"hintFuriganaFontColor"in h&&n(17,s=h.hintFuriganaFontColor),"hintFuriganaShadowColor"in h&&n(18,C=h.hintFuriganaShadowColor),"fontFamilyGroupOne"in h&&n(19,p=h.fontFamilyGroupOne),"fontFamilyGroupTwo"in h&&n(20,E=h.fontFamilyGroupTwo),"fontSize"in h&&n(21,N=h.fontSize),"lineHeight"in h&&n(22,R=h.lineHeight),"hideSpoilerImage"in h&&n(23,F=h.hideSpoilerImage),"hideFurigana"in h&&n(24,z=h.hideFurigana),"furiganaStyle"in h&&n(25,K=h.furiganaStyle),"secondDimensionMaxValue"in h&&n(26,D=h.secondDimensionMaxValue),"firstDimensionMargin"in h&&n(27,B=h.firstDimensionMargin),"autoPositionOnResize"in h&&n(28,L=h.autoPositionOnResize),"avoidPageBreak"in h&&n(29,T=h.avoidPageBreak),"pageColumns"in h&&n(30,I=h.pageColumns),"autoBookmark"in h&&n(31,w=h.autoBookmark),"viewMode"in h&&n(32,V=h.viewMode),"exploredCharCount"in h&&n(0,b=h.exploredCharCount),"bookCharCount"in h&&n(1,A=h.bookCharCount),"multiplier"in h&&n(33,Q=h.multiplier),"bookmarkData"in h&&n(2,re=h.bookmarkData),"autoScroller"in h&&n(3,pe=h.autoScroller),"bookmarkManager"in h&&n(4,Ve=h.bookmarkManager),"pageManager"in h&&n(5,Pe=h.pageManager),"isBookmarkScreen"in h&&n(6,_e=h.isBookmarkScreen),"customReadingPoint"in h&&n(7,Ie=h.customReadingPoint),"customReadingPointTop"in h&&n(8,ze=h.customReadingPointTop),"customReadingPointLeft"in h&&n(9,de=h.customReadingPointLeft),"customReadingPointScrollOffset"in h&&n(10,oe=h.customReadingPointScrollOffset),"customReadingPointRange"in h&&n(11,ie=h.customReadingPointRange),"showCustomReadingPoint"in h&&n(12,Fe=h.showCustomReadingPoint)},t.$$.update=()=>{t.$$.dirty[0]&134234112|t.$$.dirty[1]&2&&(i=B&&Yt.Paginated===V&&!k?B*2:0),t.$$.dirty[1]&16384&&U.next(g),t.$$.dirty[1]&32768&&Z.next(P)},[b,A,re,pe,Ve,Pe,_e,Ie,ze,de,oe,ie,Fe,u,k,m,v,s,C,p,E,N,R,F,z,K,D,B,L,T,I,w,V,Q,o,r,a,l,f,Ne,ye,_,O,He,j,g,P,Ae,dt,Ue,be,me,Je,Qe,ge,at,Ge,pt,je,Ze,Xe,gt,Re,kt,S,ae,We,Oe,d,x]}class Sl extends Mt{constructor(e){super(),Et(this,e,wl,_l,Dt,{htmlContent:13,width:45,height:46,verticalMode:14,fontColor:15,backgroundColor:16,hintFuriganaFontColor:17,hintFuriganaShadowColor:18,fontFamilyGroupOne:19,fontFamilyGroupTwo:20,fontSize:21,lineHeight:22,hideSpoilerImage:23,hideFurigana:24,furiganaStyle:25,secondDimensionMaxValue:26,firstDimensionMargin:27,autoPositionOnResize:28,avoidPageBreak:29,pageColumns:30,autoBookmark:31,viewMode:32,exploredCharCount:0,bookCharCount:1,multiplier:33,bookmarkData:2,autoScroller:3,bookmarkManager:4,pageManager:5,isBookmarkScreen:6,customReadingPoint:7,customReadingPointTop:8,customReadingPointLeft:9,customReadingPointScrollOffset:10,customReadingPointRange:11,showCustomReadingPoint:12},null,[-1,-1,-1])}}function Pl(t,e){const n=document.createTextNode(e);if(t.firstChild){t.replaceChild(n,t.firstChild);return}t.appendChild(n)}function vl(t,e,n){let{styleSheet:i}=e,o;return Xo(()=>{n(1,o=document.createElement("style")),document.head.appendChild(o)}),Hn(()=>{o&&document.head.removeChild(o)}),t.$$set=r=>{"styleSheet"in r&&n(0,i=r.styleSheet)},t.$$.update=()=>{t.$$.dirty&3&&o&&Pl(o,i)},[i,o]}class yl extends Mt{constructor(e){super(),Et(this,e,vl,null,Dt,{styleSheet:0})}}function yo(t){let e,n,i,o,r;return n=new ct({props:{icon:Zr}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(a){e=ee(a,"DIV",{role:!0,class:!0});var l=te(e);Ee(n.$$.fragment,l),l.forEach(M),this.h()},h(){J(e,"role","button"),J(e,"class",ti)},m(a,l){W(a,e,l),De(n,e,null),i=!0,o||(r=[Ce(e,"click",t[7]),Ce(e,"keyup",Rt)],o=!0)},p:Nt,i(a){i||(q(n.$$.fragment,a),i=!0)},o(a){Y(n.$$.fragment,a),i=!1},d(a){a&&M(e),Te(n),o=!1,Tt(r)}}}function Ro(t){let e,n,i;return{c(){e=$("div"),n=we(t[1]),i=we("x"),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);n=Se(r,t[1]),i=Se(r,"x"),r.forEach(M),this.h()},h(){J(e,"class","flex items-center px-4 text-xl xl:px-3 xl:text-lg")},m(o,r){W(o,e,r),le(e,n),le(e,i)},p(o,r){r&2&&Ye(n,o[1])},d(o){o&&M(e)}}}function Rl(t){let e,n,i,o,r,a,l,f,u,g,P,k,m=t[0]&&yo(t);r=new ct({props:{icon:t[2]?Jt:ho}});let v=!t[4]&&Ro(t);return u=new aa({props:{disableRouteNavigation:!0,items:t[3]?[qe.SETTINGS,qe.DOMAIN_HINT,qe.MANAGE]:[qe.SETTINGS,qe.MANAGE]}}),u.$on("action",t[9]),{c(){e=$("div"),n=$("div"),m&&m.c(),i=ue(),o=$("div"),Me(r.$$.fragment),a=ue(),v&&v.c(),l=ue(),f=$("div"),Me(u.$$.fragment),this.h()},l(s){e=ee(s,"DIV",{class:!0});var C=te(e);n=ee(C,"DIV",{class:!0});var p=te(n);m&&m.l(p),i=fe(p),o=ee(p,"DIV",{role:!0,class:!0});var E=te(o);Ee(r.$$.fragment,E),E.forEach(M),a=fe(p),v&&v.l(p),p.forEach(M),l=fe(C),f=ee(C,"DIV",{class:!0});var N=te(f);Ee(u.$$.fragment,N),N.forEach(M),C.forEach(M),this.h()},h(){J(o,"role","button"),J(o,"class",ti),J(n,"class","flex transform-gpu "+kr),J(f,"class","flex transform-gpu "+br),J(e,"class","flex justify-between bg-gray-700 px-4 md:px-8 "+Cr)},m(s,C){W(s,e,C),le(e,n),m&&m.m(n,null),le(n,i),le(n,o),De(r,o,null),le(n,a),v&&v.m(n,null),le(e,l),le(e,f),De(u,f,null),g=!0,P||(k=[Ce(o,"click",t[8]),Ce(o,"keyup",Rt)],P=!0)},p(s,[C]){s[0]?m?(m.p(s,C),C&1&&q(m,1)):(m=yo(s),m.c(),q(m,1),m.m(n,i)):m&&(ut(),Y(m,1,1,()=>{m=null}),ft());const p={};C&4&&(p.icon=s[2]?Jt:ho),r.$set(p),s[4]?v&&(v.d(1),v=null):v?v.p(s,C):(v=Ro(s),v.c(),v.m(n,null));const E={};C&8&&(E.items=s[3]?[qe.SETTINGS,qe.DOMAIN_HINT,qe.MANAGE]:[qe.SETTINGS,qe.MANAGE]),u.$set(E)},i(s){g||(q(m),q(r.$$.fragment,s),q(u.$$.fragment,s),g=!0)},o(s){Y(m),Y(r.$$.fragment,s),Y(u.$$.fragment,s),g=!1},d(s){s&&M(e),m&&m.d(),Te(r),v&&v.d(),Te(u),P=!1,Tt(k)}}}function Ml(t,e,n){let i,o;G(t,jn,m=>n(4,o=m));let{hasChapterData:r}=e,{autoScrollMultiplier:a}=e,{hasCustomReadingPoint:l}=e,{isBookmarkScreen:f}=e;const u=wn(),g=()=>u("tocClick"),P=()=>u("bookmarkClick"),k=({detail:m})=>{m===qe.SETTINGS.label?u("settingsClick"):m===qe.DOMAIN_HINT.label?u("domainHintClick"):m===qe.MANAGE.label&&u("bookManagerClick")};return t.$$set=m=>{"hasChapterData"in m&&n(0,r=m.hasChapterData),"autoScrollMultiplier"in m&&n(1,a=m.autoScrollMultiplier),"hasCustomReadingPoint"in m&&n(6,l=m.hasCustomReadingPoint),"isBookmarkScreen"in m&&n(2,f=m.isBookmarkScreen)},n(3,i=_r(window)),[r,a,f,i,o,u,l,g,P,k]}class El extends Mt{constructor(e){super(),Et(this,e,Ml,Rl,Dt,{hasChapterData:0,autoScrollMultiplier:1,hasCustomReadingPoint:6,isBookmarkScreen:2})}}function Mo(t,e,n){const i=t.slice();return i[16]=e[n],i}function Eo(t,e){let n,i,o=e[16].label+"",r,a,l,f,u=e[16].startCharacter+"",g,P,k,m;function v(){return e[13](e[16])}return{key:t,first:null,c(){n=$("div"),i=$("div"),r=we(o),l=ue(),f=$("div"),g=we(u),P=ue(),this.h()},l(s){n=ee(s,"DIV",{class:!0});var C=te(n);i=ee(C,"DIV",{id:!0,class:!0});var p=te(i);r=Se(p,o),p.forEach(M),l=fe(C),f=ee(C,"DIV",{});var E=te(f);g=Se(E,u),E.forEach(M),P=fe(C),C.forEach(M),this.h()},h(){J(i,"id",a=`for${e[16].reference}`),J(i,"class","mr-4 cursor-pointer"),X(i,"opacity-30",e[16].progress===100&&e[16]!==e[2]),X(i,"hover:opacity-100",e[16].progress===100&&e[16]!==e[2]),X(i,"hover:opacity-60",e[16].progress<100||e[16]===e[2]),X(f,"opacity-30",e[16].progress===100&&e[16]!==e[2]),J(n,"class","my-6 flex justify-between"),this.first=n},m(s,C){W(s,n,C),le(n,i),le(i,r),le(n,l),le(n,f),le(f,g),le(n,P),k||(m=[Ce(i,"click",v),Ce(i,"keydown",Rt)],k=!0)},p(s,C){e=s,C&2&&o!==(o=e[16].label+"")&&Ye(r,o),C&2&&a!==(a=`for${e[16].reference}`)&&J(i,"id",a),C&6&&X(i,"opacity-30",e[16].progress===100&&e[16]!==e[2]),C&6&&X(i,"hover:opacity-100",e[16].progress===100&&e[16]!==e[2]),C&6&&X(i,"hover:opacity-60",e[16].progress<100||e[16]===e[2]),C&2&&u!==(u=e[16].startCharacter+"")&&Ye(g,u),C&6&&X(f,"opacity-30",e[16].progress===100&&e[16]!==e[2])},d(s){s&&M(n),k=!1,Tt(m)}}}function Dl(t){let e,n,i,o,r,a,l,f,u,g,P,k,m=[],v=new Map,s,C,p,E,N,R,F,z,K,D;g=new ct({props:{icon:xr}});let B=t[1];const L=T=>T[16].reference;for(let T=0;T(o[0]+=t[a]*r,o[1]+=r,o),[0,0]);return n/i}function Do(t){!t||(t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView())}function Fl(t,e,n){let i,o,{sectionData:r=[]}=e,{exploredCharCount:a=0}=e,{verticalMode:l}=e,f=[],u,g=-1,P="0/0",k="0.00";Xo(()=>{tt.dialogs$.next([{component:"
"}]),u&&Do(document.getElementById(`for${u.reference}`))});function m(N,R){if(N){const F=f[g+R];v(F.reference,!1)}}function v(N,R=!1){rn.next(N),R&&s()}function s(){Vt.next(!1),tt.dialogs$.next([])}const C=N=>v(N.reference,!0),p=()=>m(i,l?1:-1),E=()=>m(o,l?-1:1);return t.$$set=N=>{"sectionData"in N&&n(10,r=N.sectionData),"exploredCharCount"in N&&n(11,a=N.exploredCharCount),"verticalMode"in N&&n(0,l=N.verticalMode)},t.$$.update=()=>{if(t.$$.dirty&5120&&r){const[N,R,F]=fi(r),z=r.filter(K=>K.reference===F||K.parentChapter===F);n(4,k=Tl(z.map(K=>K.progress),z.map(K=>K.charactersWeight)).toFixed(2)),n(1,f=N),n(12,g=R),n(2,u=N[g])}if(t.$$.dirty&4099&&n(6,i=l?gFo(t,e)??Fo(t,n)}function Fo(t,e){const n=t[e];return typeof n=="function"?n.bind(t):n}const dn=new Il(document);function Al(t,e){return Ol(t).pipe(Ke(n=>{const i=e.createElement("div");return i.innerHTML=n,Ll(i),Vl(i),zl(i,e),Nl(i),i.innerHTML}))}function Ol(t){return new St(e=>{const{blobs:n}=t;let{elementHtml:i}=t;const o=[];return Object.entries(n).forEach(([r,a])=>{const l=URL.createObjectURL(a);o.push(l),i=i.replaceAll(wr(r),l).replaceAll(`ttu:${r}`,l)}),e.next(i),()=>{o.forEach(r=>URL.revokeObjectURL(r))}})}function Ll(t){Array.from(t.getElementsByTagName("img")).map(e=>({parentEl:e.parentElement,isGaiji:ni(e)})).forEach(({parentEl:e,isGaiji:n})=>{e==null||e.classList.add("ttu-img-container"),n||e==null||e.classList.add("ttu-illustration-container")})}function Vl(t){Array.from(t.getElementsByTagName("svg")).forEach(e=>{e.removeAttribute("width"),e.removeAttribute("height")})}function zl(t,e){const n=()=>{let o=[...t.children];const r=o.findIndex(a=>a.getElementsByTagName("a").length>1)+1;return r>0&&r{const a=e.createElement("span");a.toggleAttribute("data-ttu-spoiler-img"),(o.parentElement||r).insertBefore(a,o),a.appendChild(o)};n().forEach(o=>{Array.from(o.getElementsByTagName("img")).filter(r=>!ni(r)).forEach(r=>i(r,o)),Array.from(o.getElementsByTagName("svg")).filter(r=>r.getElementsByTagName("image").length).forEach(r=>i(r,o))})}function Nl(t){t.querySelectorAll(".placeholder-br").forEach(e=>{e.parentElement.removeChild(e)})}var Hl=ki;function ki(t,e,n){t instanceof RegExp&&(t=Bo(t,n)),e instanceof RegExp&&(e=Bo(e,n));const i=bi(t,e,n);return i&&{start:i[0],end:i[1],pre:n.slice(0,i[0]),body:n.slice(i[0]+t.length,i[1]),post:n.slice(i[1]+e.length)}}function Bo(t,e){const n=e.match(t);return n?n[0]:null}ki.range=bi;function bi(t,e,n){let i,o,r,a,l,f=n.indexOf(t),u=n.indexOf(e,f+1),g=f;if(f>=0&&u>0){if(t===e)return[f,u];for(i=[],r=n.length;g>=0&&!l;)g===f?(i.push(g),f=n.indexOf(t,g+1)):i.length===1?l=[i.pop(),u]:(o=i.pop(),o=0?f:u;i.length&&(l=[r,a])}return l}function Gl(t,e={}){const i=Object.assign({},{preserveStatic:!0,removeComments:!1},e),o=[];function r(w){throw new Error(`CSS parse error: ${w}`)}function a(w){const V=w.exec(t);if(V)return t=t.slice(V[0].length),V}function l(){return a(/^{\s*/)}function f(){return a(/^}/)}function u(){a(/^\s*/)}function g(){if(u(),t[0]!=="/"||t[1]!=="*")return;let w=2;for(;t[w]&&(t[w]!=="*"||t[w+1]!=="/");)w++;if(!t[w])return r("end of comment is missing");const V=t.slice(2,w);return t=t.slice(w+2),{type:"comment",comment:V}}function P(){const w=[];let V;for(;V=g();)w.push(V);return i.removeComments?[]:w}function k(){for(u();t[0]==="}";)r("extra closing bracket");const w=a(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/);if(w)return w[0].trim().replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(V){return V.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(V){return V.replace(/\u200C/g,",")})}function m(){if(t[0]==="@")return L();a(/^([;\s]*)+/);const w=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;let V=a(/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!V)return;if(V=V[0].trim(),!a(/^:\s*/))return r("property missing ':'");const b=a(/^((?:\/\*.*?\*\/|'(?:\\'|.)*?'|"(?:\\"|.)*?"|\((\s*'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^)]*?)\s*\)|[^};])+)/),A={type:"declaration",property:V.replace(w,""),value:b?b[0].replace(w,"").trim():""};return a(/^[;\s]*/),A}function v(){if(!l())return r("missing '{'");let w,V=P();for(;w=m();)V.push(w),V=V.concat(P());return f()?V:r("missing '}'")}function s(){u();const w=[];let V;for(;V=a(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)w.push(V[1]),a(/^,\s*/);if(w.length)return{type:"keyframe",values:w,declarations:v()}}function C(){let w=a(/^@([-\w]+)?keyframes\s*/);if(!w)return;const V=w[1];if(w=a(/^([-\w]+)\s*/),!w)return r("@keyframes missing name");const b=w[1];if(!l())return r("@keyframes missing '{'");let A,Q=P();for(;A=s();)Q.push(A),Q=Q.concat(P());return f()?{type:"keyframes",name:b,vendor:V,keyframes:Q}:r("@keyframes missing '}'")}function p(){if(a(/^@page */))return{type:"page",selectors:k()||[],declarations:v()}}function E(){const w=a(/@(top|bottom|left|right)-(left|center|right|top|middle|bottom)-?(corner)?\s*/);if(w)return{type:"page-margin-box",name:`${w[1]}-${w[2]}`+(w[3]?`-${w[3]}`:""),declarations:v()}}function N(){if(a(/^@font-face\s*/))return{type:"font-face",declarations:v()}}function R(){const w=a(/^@supports *([^{]+)/);if(w)return{type:"supports",supports:w[1].trim(),rules:I()}}function F(){if(a(/^@host\s*/))return{type:"host",rules:I()}}function z(){const w=a(/^@media([^{]+)*/);if(w)return{type:"media",media:(w[1]||"").trim(),rules:I()}}function K(){const w=a(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(w)return{type:"custom-media",name:w[1].trim(),media:w[2].trim()}}function D(){const w=a(/^@([-\w]+)?document *([^{]+)/);if(w)return{type:"document",document:w[2].trim(),vendor:w[1]?w[1].trim():null,rules:I()}}function B(){const w=a(/^@(import|charset|namespace)\s*([^;]+);/);if(w)return{type:w[1],name:w[2].trim()}}function L(){if(u(),t[0]==="@"){const w=B()||N()||z()||C()||R()||D()||K()||F()||p()||E();if(w&&!i.preserveStatic){let V=!1;return w.declarations?V=w.declarations.some(b=>/var\(/.test(b.value)):V=(w.keyframes||w.rules||[]).some(A=>(A.declarations||[]).some(Q=>/var\(/.test(Q.value))),V?w:{}}return w}}function T(){if(!i.preserveStatic){const b=Hl("{","}",t);if(b){const A=/:(?:root|host)(?![.:#(])/.test(b.pre)&&/--\S*\s*:/.test(b.body),Q=/var\(/.test(b.body);if(!A&&!Q)return t=t.slice(b.end+1),{}}}const w=k()||[],V=i.preserveStatic?v():v().filter(b=>{const A=w.some(re=>/:(?:root|host)(?![.:#(])/.test(re))&&/^--\S/.test(b.property),Q=/var\(/.test(b.value);return A||Q});return w.length||r("selector missing"),{type:"rule",selectors:w,declarations:V}}function I(w){if(!w&&!l())return r("missing '{'");let V,b=P();for(;t.length&&(w||t[0]!=="}")&&(V=L()||T());)V.type&&b.push(V),b=b.concat(P());return!w&&!f()?r("missing '}'"):b}return{type:"stylesheet",stylesheet:{rules:I(!0),errors:o}}}function Wl(t,e="",n){const i={charset(r){return"@charset "+r.name+";"},comment(r){return r.comment.indexOf("__CSSVARSPONYFILL")===0?"/*"+r.comment+"*/":""},"custom-media"(r){return"@custom-media "+r.name+" "+r.media+";"},declaration(r){return r.property+":"+r.value+";"},document(r){return"@"+(r.vendor||"")+"document "+r.document+"{"+o(r.rules)+"}"},"font-face"(r){return"@font-face{"+o(r.declarations)+"}"},host(r){return"@host{"+o(r.rules)+"}"},import(r){return"@import "+r.name+";"},keyframe(r){return r.values.join(",")+"{"+o(r.declarations)+"}"},keyframes(r){return"@"+(r.vendor||"")+"keyframes "+r.name+"{"+o(r.keyframes)+"}"},media(r){return"@media "+r.media+"{"+o(r.rules)+"}"},namespace(r){return"@namespace "+r.name+";"},page(r){return"@page "+(r.selectors.length?r.selectors.join(", "):"")+"{"+o(r.declarations)+"}"},"page-margin-box"(r){return"@"+r.name+"{"+o(r.declarations)+"}"},rule(r){const a=r.declarations;if(a.length)return r.selectors.join(",")+"{"+o(a)+"}"},supports(r){return"@supports "+r.supports+"{"+o(r.rules)+"}"}};function o(r){let a="";for(let l=0;lo.type==="rule").filter(o=>!o.selectors.some(r=>jl.test(r)||Xl.test(r)));return i.forEach(o=>{const r={};o.declarations=o.declarations.filter(l=>!/line-height$/.test(l.property)&&!/text-indent$/.test(l.property));const a=new Jl(o.declarations,r);o.declarations.forEach(l=>{In(r,Yl(l)),In(r,Ul(l)),In(r,a.convert(l))}),Object.entries(r).forEach(([l,f])=>{o.declarations.push({type:"declaration",property:l,value:f})}),o.declarations=o.declarations.filter(l=>!/writing-mode\s*$/.test(l.property))}),i.push(Ql()),i.forEach(o=>{o.selectors=Kl(o.selectors,e)}),Wl({stylesheet:{rules:i},type:"stylesheet"})}function Kl(t,e){return t.map(n=>`${e} ${n}`)}function In(t,e){return e&&(t[e.key]=e.value),t}function Yl(t){const e=/(?:(?:-epub-)|(?:-webkit-))(.+)/i.exec(t.property);if(e)return{key:e[1],value:t.value}}function Ul(t){if(t.property==="font-family"){let e=t.value;return e.includes("sans-serif")?e="var(--font-family-sans-serif, Noto Sans JP, sans-serif)":e.includes("serif")&&(e="var(--font-family-serif, Noto Serif JP, serif)"),{key:t.property,value:e}}}class Jl{constructor(e,n){et(this,"hasLineBreakDefined");this.ruleDeclarations=e,this.newDeclarations=n}convert(e){if(/(?:(?:-epub-)|(?:-webkit-))?word-break$/i.exec(e.property)&&e.value==="break-all"&&(this.hasLineBreakDefined===void 0&&(this.hasLineBreakDefined=this.ruleDeclarations.some(n=>n.type==="declaration"&&n.property==="line-break")),!this.hasLineBreakDefined&&!this.newDeclarations["line-break"]))return{key:"line-break",value:"loose"}}}function Ql(){return{type:"rule",selectors:["br"],declarations:[{type:"declaration",property:"display",value:"inline!important"}]}}function Zl(t,e,n){return Al(t,n).pipe(Ke(i=>({htmlContent:i,styleSheet:ql(t,e)})))}function xl(t){return new St(e=>t.subscribe(n=>{e.next(n)}))}function cn(t=Pr){return e=>t?e:Sr}function Io(t,e,n){return i=>new St(o=>{const r=t();return i.pipe(xo(Pn),Ea(()=>n(r))).subscribe({next:a=>{e(a,r),o.next(a)},error:a=>o.error(a),complete:()=>o.complete()})})}function $l(t,e,n,i,o,r,a,l,f,u){switch(e[t.code]){case bt.BOOKMARK:return n(!0),!0;case bt.JUMP_TO_BOOKMARK:return i(),!0;case bt.AUTO_SCROLL_TOGGLE:return r==null||r.toggle(),!0;case bt.AUTO_SCROLL_INCREASE:return o(1),!0;case bt.AUTO_SCROLL_DECREASE:return o(-1),!0;case bt.NEXT_PAGE:return a==null||a.nextPage(),!0;case bt.PREV_PAGE:return a==null||a.prevPage(),!0;case bt.PREV_CHAPTER:return f(l?1:-1),!0;case bt.NEXT_CHAPTER:return f(l?-1:1),!0;case bt.SET_READING_POINT:return u(),!0;default:return!1}}const{document:An,window:Ao}=Gn;function Oo(t){var P;let e,n,i,o,r,a,l,f;function u(k){t[79](k)}let g={hasChapterData:!!((P=t[26])!=null&&P.length),hasCustomReadingPoint:!!(t[28]&&(t[22]&&t[4]||!t[22]&&t[15]>-1&&t[14]>-1)),showFullscreenButton:dn.fullscreenEnabled,autoScrollMultiplier:t[29]};return t[10]!==void 0&&(g.isBookmarkScreen=t[10]),n=new El({props:g}),ne.push(()=>ce(n,"isBookmarkScreen",u,t[10])),n.$on("tocClick",t[80]),n.$on("setCustomReadingPoint",t[75]),n.$on("showCustomReadingPoint",t[81]),n.$on("resetCustomReadingPoint",t[82]),n.$on("fullscreenClick",t[71]),n.$on("bookmarkClick",t[70]),n.$on("settingsClick",t[83]),n.$on("domainHintClick",t[72]),n.$on("bookManagerClick",t[84]),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(k){e=ee(k,"DIV",{class:!0});var m=te(e);Ee(n.$$.fragment,m),m.forEach(M),this.h()},h(){J(e,"class","elevation-4 writing-horizontal-tb fixed inset-x-0 top-0 z-10 w-full")},m(k,m){W(k,e,m),De(n,e,null),a=!0,l||(f=Wn(o=ri.call(null,e,t[85])),l=!0)},p(k,m){var s;t=k;const v={};m[0]&67108864&&(v.hasChapterData=!!((s=t[26])!=null&&s.length)),m[0]&272678928&&(v.hasCustomReadingPoint=!!(t[28]&&(t[22]&&t[4]||!t[22]&&t[15]>-1&&t[14]>-1))),m[0]&536870912&&(v.autoScrollMultiplier=t[29]),!i&&m[0]&1024&&(i=!0,v.isBookmarkScreen=t[10],he(()=>i=!1)),n.$set(v),o&&jo(o.update)&&m[0]&512&&o.update.call(null,t[85])},i(k){a||(q(n.$$.fragment,k),k&&qo(()=>{r||(r=ro(e,Nn,{y:-300,easing:zn},!0)),r.run(1)}),a=!0)},o(k){Y(n.$$.fragment,k),k&&(r||(r=ro(e,Nn,{y:-300,easing:zn},!1)),r.run(0)),a=!1},d(k){k&&M(e),Te(n),k&&r&&r.end(),l=!1,f()}}}function es(t){let e=(t[52]??"")+"",n;return{c(){n=we(e)},l(i){n=Se(i,e)},m(i,o){W(i,n,o)},p(i,o){o[1]&2097152&&e!==(e=(i[52]??"")+"")&&Ye(n,e)},i:Nt,o:Nt,d(i){i&&M(n)}}}function ts(t){var Ne,ve,ye;let e,n,i,o,r,a,l,f,u,g,P,k,m,v,s,C,p,E=(t[47]??"")+"",N,R,F=(t[48]??"")+"",z,K,D=(t[49]??"")+"",B,L,T=(t[50]??"")+"",I,w,V=(t[51]??"")+"",b,A;e=new yl({props:{styleSheet:t[30].styleSheet}});function Q(_){t[86](_)}function re(_){t[87](_)}function pe(_){t[88](_)}function Ve(_){t[89](_)}function Pe(_){t[90](_)}function _e(_){t[91](_)}function Ie(_){t[92](_)}function ze(_){t[93](_)}function de(_){t[94](_)}function oe(_){t[95](_)}function ie(_){t[96](_)}function Fe(_){t[97](_)}function U(_){t[98](_)}let Z={htmlContent:t[30].htmlContent,width:t[31]??0,height:t[32]??0,verticalMode:t[23],fontColor:(Ne=t[33])==null?void 0:Ne.fontColor,backgroundColor:t[34],hintFuriganaFontColor:(ve=t[33])==null?void 0:ve.hintFuriganaFontColor,hintFuriganaShadowColor:(ye=t[33])==null?void 0:ye.hintFuriganaShadowColor,fontFamilyGroupOne:t[35],fontFamilyGroupTwo:t[36],fontSize:t[37],lineHeight:t[38],hideSpoilerImage:t[39],hideFurigana:t[40],furiganaStyle:t[41],viewMode:t[6],secondDimensionMaxValue:t[42],firstDimensionMargin:t[24],autoPositionOnResize:t[43],avoidPageBreak:t[44],pageColumns:t[45],autoBookmark:t[46],multiplier:t[29]};return t[0]!==void 0&&(Z.exploredCharCount=t[0]),t[1]!==void 0&&(Z.bookCharCount=t[1]),t[10]!==void 0&&(Z.isBookmarkScreen=t[10]),t[3]!==void 0&&(Z.bookmarkData=t[3]),t[2]!==void 0&&(Z.autoScroller=t[2]),t[12]!==void 0&&(Z.bookmarkManager=t[12]),t[13]!==void 0&&(Z.pageManager=t[13]),t[16]!==void 0&&(Z.customReadingPoint=t[16]),t[14]!==void 0&&(Z.customReadingPointTop=t[14]),t[15]!==void 0&&(Z.customReadingPointLeft=t[15]),t[17]!==void 0&&(Z.customReadingPointScrollOffset=t[17]),t[4]!==void 0&&(Z.customReadingPointRange=t[4]),t[5]!==void 0&&(Z.showCustomReadingPoint=t[5]),i=new Sl({props:Z}),ne.push(()=>ce(i,"exploredCharCount",Q,t[0])),ne.push(()=>ce(i,"bookCharCount",re,t[1])),ne.push(()=>ce(i,"isBookmarkScreen",pe,t[10])),ne.push(()=>ce(i,"bookmarkData",Ve,t[3])),ne.push(()=>ce(i,"autoScroller",Pe,t[2])),ne.push(()=>ce(i,"bookmarkManager",_e,t[12])),ne.push(()=>ce(i,"pageManager",Ie,t[13])),ne.push(()=>ce(i,"customReadingPoint",ze,t[16])),ne.push(()=>ce(i,"customReadingPointTop",de,t[14])),ne.push(()=>ce(i,"customReadingPointLeft",oe,t[15])),ne.push(()=>ce(i,"customReadingPointScrollOffset",ie,t[17])),ne.push(()=>ce(i,"customReadingPointRange",Fe,t[4])),ne.push(()=>ce(i,"showCustomReadingPoint",U,t[5])),i.$on("bookmark",t[70]),{c(){Me(e.$$.fragment),n=ue(),Me(i.$$.fragment),p=ue(),N=we(E),R=ue(),z=we(F),K=ue(),B=we(D),L=ue(),I=we(T),w=ue(),b=we(V)},l(_){Ee(e.$$.fragment,_),n=fe(_),Ee(i.$$.fragment,_),p=fe(_),N=Se(_,E),R=fe(_),z=Se(_,F),K=fe(_),B=Se(_,D),L=fe(_),I=Se(_,T),w=fe(_),b=Se(_,V)},m(_,O){De(e,_,O),W(_,n,O),De(i,_,O),W(_,p,O),W(_,N,O),W(_,R,O),W(_,z,O),W(_,K,O),W(_,B,O),W(_,L,O),W(_,I,O),W(_,w,O),W(_,b,O),A=!0},p(_,O){var Be,ke,Ae;const He={};O[0]&1073741824&&(He.styleSheet=_[30].styleSheet),e.$set(He);const j={};O[0]&1073741824&&(j.htmlContent=_[30].htmlContent),O[1]&1&&(j.width=_[31]??0),O[1]&2&&(j.height=_[32]??0),O[0]&8388608&&(j.verticalMode=_[23]),O[1]&4&&(j.fontColor=(Be=_[33])==null?void 0:Be.fontColor),O[1]&8&&(j.backgroundColor=_[34]),O[1]&4&&(j.hintFuriganaFontColor=(ke=_[33])==null?void 0:ke.hintFuriganaFontColor),O[1]&4&&(j.hintFuriganaShadowColor=(Ae=_[33])==null?void 0:Ae.hintFuriganaShadowColor),O[1]&16&&(j.fontFamilyGroupOne=_[35]),O[1]&32&&(j.fontFamilyGroupTwo=_[36]),O[1]&64&&(j.fontSize=_[37]),O[1]&128&&(j.lineHeight=_[38]),O[1]&256&&(j.hideSpoilerImage=_[39]),O[1]&512&&(j.hideFurigana=_[40]),O[1]&1024&&(j.furiganaStyle=_[41]),O[0]&64&&(j.viewMode=_[6]),O[1]&2048&&(j.secondDimensionMaxValue=_[42]),O[0]&16777216&&(j.firstDimensionMargin=_[24]),O[1]&4096&&(j.autoPositionOnResize=_[43]),O[1]&8192&&(j.avoidPageBreak=_[44]),O[1]&16384&&(j.pageColumns=_[45]),O[1]&32768&&(j.autoBookmark=_[46]),O[0]&536870912&&(j.multiplier=_[29]),!o&&O[0]&1&&(o=!0,j.exploredCharCount=_[0],he(()=>o=!1)),!r&&O[0]&2&&(r=!0,j.bookCharCount=_[1],he(()=>r=!1)),!a&&O[0]&1024&&(a=!0,j.isBookmarkScreen=_[10],he(()=>a=!1)),!l&&O[0]&8&&(l=!0,j.bookmarkData=_[3],he(()=>l=!1)),!f&&O[0]&4&&(f=!0,j.autoScroller=_[2],he(()=>f=!1)),!u&&O[0]&4096&&(u=!0,j.bookmarkManager=_[12],he(()=>u=!1)),!g&&O[0]&8192&&(g=!0,j.pageManager=_[13],he(()=>g=!1)),!P&&O[0]&65536&&(P=!0,j.customReadingPoint=_[16],he(()=>P=!1)),!k&&O[0]&16384&&(k=!0,j.customReadingPointTop=_[14],he(()=>k=!1)),!m&&O[0]&32768&&(m=!0,j.customReadingPointLeft=_[15],he(()=>m=!1)),!v&&O[0]&131072&&(v=!0,j.customReadingPointScrollOffset=_[17],he(()=>v=!1)),!s&&O[0]&16&&(s=!0,j.customReadingPointRange=_[4],he(()=>s=!1)),!C&&O[0]&32&&(C=!0,j.showCustomReadingPoint=_[5],he(()=>C=!1)),i.$set(j),(!A||O[1]&65536)&&E!==(E=(_[47]??"")+"")&&Ye(N,E),(!A||O[1]&131072)&&F!==(F=(_[48]??"")+"")&&Ye(z,F),(!A||O[1]&262144)&&D!==(D=(_[49]??"")+"")&&Ye(B,D),(!A||O[1]&524288)&&T!==(T=(_[50]??"")+"")&&Ye(I,T),(!A||O[1]&1048576)&&V!==(V=(_[51]??"")+"")&&Ye(b,V)},i(_){A||(q(e.$$.fragment,_),q(i.$$.fragment,_),A=!0)},o(_){Y(e.$$.fragment,_),Y(i.$$.fragment,_),A=!1},d(_){Te(e,_),_&&M(n),Te(i,_),_&&M(p),_&&M(N),_&&M(R),_&&M(z),_&&M(K),_&&M(B),_&&M(L),_&&M(I),_&&M(w),_&&M(b)}}}function Lo(t){let e,n,i,o,r,a;return n=new Bl({props:{sectionData:t[26],verticalMode:t[23],exploredCharCount:t[0]}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(l){e=ee(l,"DIV",{class:!0});var f=te(e);Ee(n.$$.fragment,f),f.forEach(M),this.h()},h(){var l;J(e,"class","writing-horizontal-tb fixed top-0 left-0 z-[60] flex h-full w-full max-w-xl flex-col justify-between"),y(e,"color",(l=t[33])==null?void 0:l.fontColor),y(e,"background-color",t[34])},m(l,f){W(l,e,f),De(n,e,null),o=!0,r||(a=Wn(ri.call(null,e,t[99])),r=!0)},p(l,f){var g;t=l;const u={};f[0]&67108864&&(u.sectionData=t[26]),f[0]&8388608&&(u.verticalMode=t[23]),f[0]&1&&(u.exploredCharCount=t[0]),n.$set(u),f[1]&4&&y(e,"color",(g=t[33])==null?void 0:g.fontColor),f[1]&8&&y(e,"background-color",t[34])},i(l){o||(q(n.$$.fragment,l),l&&(i||qo(()=>{i=ar(e,Nn,{x:-100,duration:100,easing:zn}),i.start()})),o=!0)},o(l){Y(n.$$.fragment,l),o=!1},d(l){l&&M(e),Te(n),r=!1,a()}}}function Vo(t){let e,n,i;return{c(){e=$("div"),n=ue(),i=$("div"),this.h()},l(o){e=ee(o,"DIV",{class:!0}),te(e).forEach(M),n=fe(o),i=ee(o,"DIV",{class:!0}),te(i).forEach(M),this.h()},h(){J(e,"class","fixed left-0 z-20 h-[1px] w-full border border-red-500"),y(e,"top",`${t[14]}px`),J(i,"class","fixed top-0 z-20 h-full w-[1px] border border-red-500"),y(i,"left",`${t[15]}px`)},m(o,r){W(o,e,r),W(o,n,r),W(o,i,r)},p(o,r){r[0]&16384&&y(e,"top",`${o[14]}px`),r[0]&32768&&y(i,"left",`${o[15]}px`)},d(o){o&&M(e),o&&M(n),o&&M(i)}}}function zo(t){let e,n,i;return n=new ct({props:{icon:Xn,spin:!0}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed inset-0 flex h-full w-full items-center justify-center text-7xl")},m(o,r){W(o,e,r),De(n,e,null),i=!0},p:Nt,i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function No(t){let e,n,i,o,r;return n=new ct({props:{icon:ta}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(a){e=ee(a,"DIV",{class:!0});var l=te(e);Ee(n.$$.fragment,l),l.forEach(M),this.h()},h(){J(e,"class","flex h-full w-8 items-center justify-center text-lg"),X(e,"text-red-500",t[20]>1),X(e,"animate-pulse",t[20]>1||t[21])},m(a,l){W(a,e,l),De(n,e,null),i=!0,o||(r=[Ce(e,"click",lr(t[100])),Ce(e,"keyup",Rt)],o=!0)},p(a,l){(!i||l[0]&1048576)&&X(e,"text-red-500",a[20]>1),(!i||l[0]&3145728)&&X(e,"animate-pulse",a[20]>1||a[21])},i(a){i||(q(n.$$.fragment,a),i=!0)},o(a){Y(n.$$.fragment,a),i=!1},d(a){a&&M(e),Te(n),o=!1,Tt(r)}}}function Ho(t){let e,n,i,o,r,a=(t[0]/t[1]*100).toFixed(2)+"",l,f;return{c(){e=$("div"),n=we(t[0]),i=we(" / "),o=we(t[1]),r=we(" ("),l=we(a),f=we("%)"),this.h()},l(u){e=ee(u,"DIV",{class:!0});var g=te(e);n=Se(g,t[0]),i=Se(g," / "),o=Se(g,t[1]),r=Se(g," ("),l=Se(g,a),f=Se(g,"%)"),g.forEach(M),this.h()},h(){var u;J(e,"class","writing-horizontal-tb fixed bottom-2 right-2 z-10 text-xs leading-none"),y(e,"color",(u=t[33])==null?void 0:u.tooltipTextFontColor)},m(u,g){W(u,e,g),le(e,n),le(e,i),le(e,o),le(e,r),le(e,l),le(e,f)},p(u,g){var P;g[0]&1&&Ye(n,u[0]),g[0]&2&&Ye(o,u[1]),g[0]&3&&a!==(a=(u[0]/u[1]*100).toFixed(2)+"")&&Ye(l,a),g[1]&4&&y(e,"color",(P=u[33])==null?void 0:P.tooltipTextFontColor)},d(u){u&&M(e)}}}function ns(t){var V;let e,n,i=(t[27]??"")+"",o,r,a,l,f,u,g,P,k,m,v,s,C,p,E,N,R;An.title=e=fo(((V=t[25])==null?void 0:V.title)??"");let F=t[9]&&Oo(t);const z=[ts,es],K=[];function D(b,A){return b[30]?0:1}u=D(t),g=K[u]=z[u](t);let B=t[7]&&Lo(t),L=(t[18]&&!t[53]||!t[22]&&t[5])&&Vo(t),T=t[8]&&zo(),I=t[19].length&&No(t),w=t[11]&&t[1]&&Ho(t);return{c(){n=ue(),o=we(i),r=ue(),a=$("button"),l=ue(),F&&F.c(),f=ue(),g.c(),P=ue(),B&&B.c(),k=ue(),L&&L.c(),m=ue(),T&&T.c(),v=ue(),s=$("div"),C=$("div"),I&&I.c(),p=ue(),w&&w.c(),this.h()},l(b){rr("svelte-rnuhm6",An.head).forEach(M),n=fe(b),o=Se(b,i),r=fe(b),a=ee(b,"BUTTON",{class:!0}),te(a).forEach(M),l=fe(b),F&&F.l(b),f=fe(b),g.l(b),P=fe(b),B&&B.l(b),k=fe(b),L&&L.l(b),m=fe(b),T&&T.l(b),v=fe(b),s=ee(b,"DIV",{class:!0});var Q=te(s);C=ee(Q,"DIV",{class:!0});var re=te(C);I&&I.l(re),re.forEach(M),p=fe(Q),w&&w.l(Q),Q.forEach(M),this.h()},h(){var b;J(a,"class","fixed inset-x-0 top-0 z-10 h-8 w-full"),J(C,"class","h-full"),J(s,"class","writing-horizontal-tb fixed bottom-0 left-0 z-10 flex h-8 w-full cursor-pointer items-center justify-between text-xs leading-none"),y(s,"color",(b=t[33])==null?void 0:b.tooltipTextFontColor)},m(b,A){W(b,n,A),W(b,o,A),W(b,r,A),W(b,a,A),W(b,l,A),F&&F.m(b,A),W(b,f,A),K[u].m(b,A),W(b,P,A),B&&B.m(b,A),W(b,k,A),L&&L.m(b,A),W(b,m,A),T&&T.m(b,A),W(b,v,A),W(b,s,A),le(s,C),I&&I.m(C,null),le(s,p),w&&w.m(s,null),E=!0,N||(R=[Ce(Ao,"keydown",t[69]),Ce(Ao,"beforeunload",t[68]),Ce(a,"click",t[78]),Ce(s,"click",t[101]),Ce(s,"keyup",Rt)],N=!0)},p(b,A){var re,pe;(!E||A[0]&33554432)&&e!==(e=fo(((re=b[25])==null?void 0:re.title)??""))&&(An.title=e),(!E||A[0]&134217728)&&i!==(i=(b[27]??"")+"")&&Ye(o,i),b[9]?F?(F.p(b,A),A[0]&512&&q(F,1)):(F=Oo(b),F.c(),q(F,1),F.m(f.parentNode,f)):F&&(ut(),Y(F,1,1,()=>{F=null}),ft());let Q=u;u=D(b),u===Q?K[u].p(b,A):(ut(),Y(K[Q],1,1,()=>{K[Q]=null}),ft(),g=K[u],g?g.p(b,A):(g=K[u]=z[u](b),g.c()),q(g,1),g.m(P.parentNode,P)),b[7]?B?(B.p(b,A),A[0]&128&&q(B,1)):(B=Lo(b),B.c(),q(B,1),B.m(k.parentNode,k)):B&&(ut(),Y(B,1,1,()=>{B=null}),ft()),b[18]&&!b[53]||!b[22]&&b[5]?L?L.p(b,A):(L=Vo(b),L.c(),L.m(m.parentNode,m)):L&&(L.d(1),L=null),b[8]?T?(T.p(b,A),A[0]&256&&q(T,1)):(T=zo(),T.c(),q(T,1),T.m(v.parentNode,v)):T&&(ut(),Y(T,1,1,()=>{T=null}),ft()),b[19].length?I?(I.p(b,A),A[0]&524288&&q(I,1)):(I=No(b),I.c(),q(I,1),I.m(C,null)):I&&(ut(),Y(I,1,1,()=>{I=null}),ft()),b[11]&&b[1]?w?w.p(b,A):(w=Ho(b),w.c(),w.m(s,null)):w&&(w.d(1),w=null),A[1]&4&&y(s,"color",(pe=b[33])==null?void 0:pe.tooltipTextFontColor)},i(b){E||(q(F),q(g),q(B),q(T),q(I),E=!0)},o(b){Y(F),Y(g),Y(B),Y(T),Y(I),E=!1},d(b){b&&M(n),b&&M(o),b&&M(r),b&&M(a),b&&M(l),F&&F.d(b),b&&M(f),K[u].d(b),b&&M(P),B&&B.d(b),b&&M(k),L&&L.d(b),b&&M(m),T&&T.d(b),b&&M(v),b&&M(s),I&&I.d(),w&&w.d(),N=!1,Tt(R)}}}const Go="background-color",Wo="writing-mode";function os(t,e,n){let i,o,r,a,l,f,u,g,P,k,m,v,s,C,p,E,N,R,F,z,K,D,B,L,T,I,w,V,b,A,Q,re,pe,Ve,Pe,_e,Ie,ze,de,oe,ie,Fe,U,Z,Ne,ve;G(t,Dr,c=>n(23,r=c)),G(t,$o,c=>n(24,a=c)),G(t,Tr,c=>n(108,l=c)),G(t,Fr,c=>n(109,f=c)),G(t,Br,c=>n(110,g=c)),G(t,Ir,c=>n(111,P=c)),G(t,ei,c=>n(112,m=c)),G(t,Kt,c=>n(113,v=c)),G(t,Ar,c=>n(77,s=c)),G(t,Or,c=>n(114,C=c)),G(t,Lr,c=>n(115,p=c)),G(t,Vr,c=>n(6,E=c)),G(t,Vt,c=>n(7,N=c)),G(t,Dn,c=>n(116,R=c)),G(t,Tn,c=>n(117,F=c)),G(t,Zo,c=>n(28,K=c)),G(t,Fn,c=>n(29,D=c)),G(t,zr,c=>n(35,V=c)),G(t,Nr,c=>n(36,b=c)),G(t,Hr,c=>n(37,A=c)),G(t,Gr,c=>n(38,Q=c)),G(t,Wr,c=>n(39,re=c)),G(t,jr,c=>n(40,pe=c)),G(t,Xr,c=>n(41,Ve=c)),G(t,qr,c=>n(42,Pe=c)),G(t,Kr,c=>n(43,_e=c)),G(t,Yr,c=>n(44,Ie=c)),G(t,Ur,c=>n(45,ze=c)),G(t,Jr,c=>n(46,de=c)),G(t,jn,c=>n(53,ve=c));let ye=!0,_=!0,O=!1,He=!0,j=0,Be=0,ke,Ae,dt,Ue=Promise.resolve(void 0),be=-2,me=-2,Je=r?F:R,Qe=0,ge,at,Ge=!0,pt=!1,je=!1,Ze,Xe=[],gt=[],Re,kt=0,S=!1,ae=0;const We=nn(2500).pipe(_t(()=>n(9,_=!1)),yt());G(t,We,c=>n(27,z=c));const Oe=It(()=>xl(Qr)).pipe(Ke(c=>Number(c.url.searchParams.get("id"))),Ln({refCount:!0,bufferSize:1})),d=Oe.pipe(Lt(async c=>{let H;try{if(Ze=ln(window,sn.BROWSER,void 0,!0,l,f),Ze.startContext({id:c,title:""}),H=await Ze.getBook(),!H)return H;Ze.startContext({id:H.id,title:H.title,imagePath:H.coverImage}),H.storageSource?n(76,Re=await to(H.storageSource,!0)):s!==jt.Off&&n(76,Re=await to(P)),H.lastBookOpen=new Date().getTime(),await Ze.updateLastRead(H),H=await _i(Re,H),await wi(Re)}catch(se){const Le=`Error loading book: ${se.message}`;mt.warn(Le),tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:Le}}]);return}finally{n(8,ye=!1)}return Re&&Re.updateSettings(window,!0,f,l,!1,H.storageSource||P),H}),Vn());G(t,d,c=>n(25,u=c));const x=d.pipe(_t(c=>{c||co(`${so}${qe.MANAGE.routeId}`)}),yt());G(t,x,c=>n(52,Ne=c));const h=d.pipe(_t(c=>{!c||n(3,Ue=En.getBookmark(c.id))}),yt());G(t,h,c=>n(47,oe=c));const lt=d.pipe(Lt(c=>c?(Kn.next(c.sections||[]),Zl(c,".book-content",document)):Ht),Ln({refCount:!0,bufferSize:1}));G(t,lt,c=>n(30,B=c));const an=It(()=>visualViewport?rt(visualViewport,"resize"):qn()).pipe(Vn()),Un=an.pipe(On(0),Ke(()=>(visualViewport==null?void 0:visualViewport.width)||0),cn());G(t,Un,c=>n(31,L=c));const Jn=an.pipe(On(0),Ke(()=>(visualViewport==null?void 0:visualViewport.height)||0),cn());G(t,Jn,c=>n(32,T=c));const vn=vr.pipe(Ke(c=>la.get(c)),$t(c=>!!c));G(t,vn,c=>n(33,I=c));const yn=vn.pipe(Ke(c=>c.backgroundColor));G(t,yn,c=>n(34,w=c));const Qn=yn.pipe(Io(()=>document.body,(c,H)=>H.style.setProperty(Go,c),c=>c.style.removeProperty(Go)),yt(),cn());G(t,Qn,c=>n(48,ie=c));const Zn=yr.pipe(Io(()=>document.documentElement,(c,H)=>H.style.setProperty(Wo,c),c=>c.style.removeProperty(Wo)),yt(),cn());G(t,Zn,c=>n(49,Fe=c));const xn=It(()=>bn).pipe(Ke(c=>[...c.values()]));G(t,xn,c=>n(26,k=c));const $n=It(()=>rt(document,"selectionchange")).pipe(xt(200),_t(()=>{var H,se;const c=((H=window.getSelection())==null?void 0:H.toString())||"";!c&&Ge?at=void 0:c?(at=(se=window.getSelection())==null?void 0:se.getRangeAt(0),Ge=!1):Ge=!0}),yt());G(t,$n,c=>n(50,U=c));const eo=Bn.pipe(ya(6e4),Lt(()=>Wt()),yt());G(t,eo,c=>n(51,Z=c));function Ci(c){return p&&(S||ae!==j||o&&Xe.length||o&>.length)?(c.preventDefault(),c.returnValue="Are you sure you want to exit?"):c}async function to(c,H=!1){if(!c){if(H)throw new Error("No storage source found");return}if(c===lo.GDRIVE_DEFAULT){if(!C){tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:"Sync disabled due to missing Online Connection - refresh Page after going Online to try again"}}]);return}return ln(window,sn.GDRIVE,c,!0,l,f)}if(c===lo.ONEDRIVE_DEFAULT){if(!C){tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:"Sync disabled due to missing Online Connection - refresh Page after going Online to try again"}}]);return}return ln(window,sn.ONEDRIVE,c,!0,l,f)}if(c){const xe=await(await En.db).get("storageSource",c);if(xe){if(xe.type!==sn.FS&&!C){tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:"Sync disabled due to missing Online Connection - refresh Page after going Online to try again"}}]);return}return ln(window,xe.type,c,!0,l,f)}if(H)throw new Error(`No storage source with name ${c} found`)}const se=`No storage source with name ${c} found - skipping auto import/export`;mt.warn(se),tt.dialogs$.next([{component:Ct,props:{title:"Configuration Error",message:se}}])}async function _i(c,H){if(!c)return H;l||c.clearData(!1),c.startContext({id:H.id,title:H.title,imagePath:H.coverImage||""});let{id:se,...Le}=H;if(H.storageSource){const ot=await c.getBook();ot&&!(ot instanceof File)&&(Le={...ot,id:H.id,lastBookOpen:H.lastBookOpen,storageSource:H.storageSource})}else if(!H.elementHtml)throw new Error("Book has no data stored");const xe={id:se,...Le};return await c.updateLastRead(xe).catch(ot=>{const $e=`Failed to update last read on external storage: ${ot.message}`;mt.warn($e),tt.dialogs$.next([{component:Ct,props:{title:"Update Error",message:$e}}])}),xe}async function wi(c){if(Ze&&c&&(s===jt.Down||s===jt.All)){const H=await c.getProgress();H&&!(H instanceof File)&&(await Ze.saveProgress(H),ae=H.exploredCharCount||0)}}function Si(c){v||!$l(c,Er.getValue(),Rn,vi,se=>Fn.next(Fn.getValue()+se),ke,dt,r,Mi,oo)||(document.activeElement instanceof HTMLElement&&document.activeElement.blur(),c.preventDefault())}function Pi(){let c;return Oe.subscribe(H=>c=H).unsubscribe(),c}async function Rn(c){var Le;const H=Pi();if(!H||!Ae)return;let se;if(n(9,_=!1),i){const xe=m?La(window,at):void 0,ot=xe||ge;qt((Le=ot==null?void 0:ot.endContainer)==null?void 0:Le.parentElement,"add",.5,500),se=Ae.formatBookmarkDataByRange(H,ot),xe&&hi(window)}else se=Ae.formatBookmarkData(H,Qe);if(await Ze.saveProgress(se),o){const xe=S?gt:Xe;xe.includes(uo.PROGRESS)||xe.push(uo.PROGRESS),c&&Bn.next()}n(3,Ue=Promise.resolve(se))}async function vi(){const c=await Ue;!c||!Ae||Ae.scrollToBookmark(c,Qe)}function yi(){if(n(9,_=!1),!dn.fullscreenElement){dn.requestFullscreen(document.documentElement);return}dn.exitFullscreen()}function Ri(){tt.dialogs$.next([{component:Ct,props:{title:"Old Domain",message:"You are currently using the old domain of ッツ Reader - consider switching to https://reader.ttsu.app to prevent issues and to ensure full features"},disableCloseOnClick:!0}])}function Mi(c){if(!(k!=null&&k.length))return;const[H,se]=fi(k);!se&&c===-1||c===1&&se===H.length-1||rn.next(H[se+c].reference)}async function Wt(c=!0){if(S||!Xe.length||!u||!Re)return;n(21,S=!0),c||(Kt.next(!0),mt.clearHistory(),no());const H=u.storageSource||P;Re.updateSettings(window,!1,f,l,!c,H);const se=await Rr(Ze,Re,!c&&g===Re.storageType,[{id:u.id,title:u.title,imagePath:u.coverImage}],Xe).catch(Le=>Le.message);if(Re.updateSettings(window,!0,f,l,!1,H),n(21,S=!1),se){if(!c){const Le=mt.errorCount>1;mt.warn(se),tt.dialogs$.next([{component:Le?Mr:Ct,props:{title:"Error Processing Data",message:Le?"Some or all data could not be stored on an external storage":se}}])}n(20,kt+=1)}else n(20,kt=0),c||tt.dialogs$.next([]),gt.length?(n(19,Xe=JSON.parse(JSON.stringify(gt))),gt=[],c?Bn.next():await Wt(!1)):n(19,Xe=[]);c||Kt.next(!1)}function no(){tt.dialogs$.next([{component:"
",disableCloseOnClick:!0}])}async function Mn(c,H=!0){no();let se;try{H&&await En.deleteLastItem(),await Rn(!1),tt.dialogs$.next([]),o&&await Wt(!1)}catch(Le){se=Le.message}se&&(mt.warn(se),tt.dialogs$.next([{component:Ct,props:{title:"Error",message:se},disableCloseOnClick:!0}])),co(`${so}${c}`)}function oo(){const c=document.querySelector(".book-content");if(!c)return;i&&(n(14,be=window.innerHeight/2-2),n(15,me=window.innerWidth/2-2)),n(9,_=!1),n(18,pt=!0),document.body.classList.add("cursor-crosshair");const{elLeftReferencePoint:H,elTopReferencePoint:se,elRightReferencePoint:Le,elBottomReferencePoint:xe,pointGap:ot}=di(window,c,r,a);on(rt(document,"pointerup"),rt(document,"pointermove")).pipe(Ta(()=>pt)).subscribe($e=>{if($e instanceof PointerEvent)if($e.type==="pointerup")document.body.classList.remove("cursor-crosshair"),n(18,pt=!1),sr().then(()=>{n(15,me=r?$e.x:me),n(14,be=r?be:$e.y);const Pt=Oa(me,be);if(Pt&&qt(Pt.parent,"add",.5,500),i)n(4,ge=Pt==null?void 0:Pt.range);else{let vt=0;r?(vt=Math.ceil(Math.max(0,me-H)/(Le-H)*100),Tn.next(vt)):(vt=Math.ceil(Math.max(0,be-se)/(xe-se)*100),Dn.next(vt)),n(16,Je=vt)}});else{const Pt=$e.x>=H+ot&&$e.x<=Le,vt=$e.y>=se&&$e.y<=xe-ot;i?(n(14,be=vt?$e.y:be),n(15,me=Pt?$e.x:me)):r&&Pt?n(15,me=$e.x):!r&&vt&&n(14,be=$e.y)}})}const Ei=()=>n(9,_=!0);function Di(c){O=c,n(10,O)}const Ti=()=>{n(9,_=!1),Vt.next(!0)},Fi=()=>{n(9,_=!1),n(5,je=!0)},Bi=()=>{n(9,_=!1),i?n(4,ge=void 0):r?(Tn.next(100),n(16,Je=100)):(Dn.next(0),n(16,Je=0))},Ii=()=>Mn(qe.SETTINGS.routeId,!1),Ai=()=>Mn(qe.MANAGE.routeId),Oi=()=>n(9,_=!1);function Li(c){j=c,n(0,j)}function Vi(c){Be=c,n(1,Be)}function zi(c){O=c,n(10,O)}function Ni(c){Ue=c,n(3,Ue)}function Hi(c){ke=c,n(2,ke)}function Gi(c){Ae=c,n(12,Ae)}function Wi(c){dt=c,n(13,dt)}function ji(c){Je=c,n(16,Je)}function Xi(c){be=c,n(14,be)}function qi(c){me=c,n(15,me)}function Ki(c){Qe=c,n(17,Qe)}function Yi(c){ge=c,n(4,ge)}function Ui(c){je=c,n(5,je),n(4,ge)}const Ji=()=>Vt.next(!1),Qi=()=>Wt(!1),Zi=()=>n(11,He=!He);return t.$$.update=()=>{var c;t.$$.dirty[0]&132&&N&&(ke==null||ke.off()),t.$$.dirty[0]&3&&Be&&document.dispatchEvent(new CustomEvent("ttsu:page.change",{detail:{exploredCharCount:j}})),t.$$.dirty[0]&2&&document.dispatchEvent(new CustomEvent("ttsu:page.change",{detail:{bookCharCount:Be}})),t.$$.dirty[0]&48&&je&&(qt((c=ge==null?void 0:ge.endContainer)==null?void 0:c.parentElement,"add",1),rt(document,"click").pipe(mn(1),Gt(1)).subscribe(()=>{var H;n(5,je=!1),qt((H=ge==null?void 0:ge.endContainer)==null?void 0:H.parentElement,"remove",1)})),t.$$.dirty[0]&64&&n(22,i=E===Yt.Paginated),t.$$.dirty[2]&49152&&(o=Re&&(s===jt.Up||s===jt.All)),t.$$.dirty[0]&8&&Ue.then(H=>ae=(H==null?void 0:H.exploredCharCount)||0)},[j,Be,ke,Ue,ge,je,E,N,ye,_,O,He,Ae,dt,be,me,Je,Qe,pt,Xe,kt,S,i,r,a,u,k,z,K,D,B,L,T,I,w,V,b,A,Q,re,pe,Ve,Pe,_e,Ie,ze,de,oe,ie,Fe,U,Z,Ne,ve,We,d,x,h,lt,Un,Jn,vn,yn,Qn,Zn,xn,$n,eo,Ci,Si,Rn,yi,Ri,Wt,Mn,oo,Re,s,Ei,Di,Ti,Fi,Bi,Ii,Ai,Oi,Li,Vi,zi,Ni,Hi,Gi,Wi,ji,Xi,qi,Ki,Yi,Ui,Ji,Qi,Zi]}class ms extends Mt{constructor(e){super(),Et(this,e,os,ns,Dt,{},null,[-1,-1,-1,-1,-1])}}export{ms as default}; +var xi=Object.defineProperty;var $i=(t,e,n)=>e in t?xi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var et=(t,e,n)=>($i(t,typeof e!="symbol"?e+"":e,n),n);import{S as Mt,i as Et,n as Dt,V as er,e as zt,W as tr,a as W,B as Nt,f as M,a2 as wn,h as nr,j as $,w as Me,s as ue,k as ee,l as te,x as Ee,c as fe,m as J,a8 as X,p as y,y as De,N as Ce,d as q,g as ut,t as Y,b as ft,z as Te,R as Tt,D as G,_ as Hn,T as Gn,a1 as ne,G as le,a5 as Wn,a9 as jo,q as we,r as Se,u as Ye,aa as io,ab as ce,ac as he,o as Xo,Y as or,Z as ir,F as rr,L as qo,a0 as ro,$ as ar,ad as lr,A as sr}from"../../../chunks/index-be8ea2fc.js";import{k as ur,l as Ko,n as Yo,o as fr,q as hn,r as Bt,s as cr,v as hr,w as dr,x as ht,y as wt,B as gn,z as Sn,A as Lt,m as Ke,C as $t,D as Uo,F as it,u as Jo,E as Kt,G as Qo,H as Zo,I as mn,J as xo,K as ao,t as _t,L as $o,c as jn,N as ei,O as gr,P as It,Q as mr,R as On,S as Ln,T as pr,U as Vn,V as Yt,W as ti,X as kr,Y as br,Z as Cr,f as Rt,i as _r,a as tt,_ as wr,$ as ni,a0 as Sr,a1 as Pr,a2 as bt,a3 as ln,a4 as sn,a5 as jt,M as Ct,a6 as vr,a7 as yr,a8 as lo,j as En,a9 as Rr,aa as Mr,p as so,ab as Er,ac as Dn,ad as zn,ae as Nn,af as Dr,ag as Tr,ah as Fr,ai as Br,aj as Ir,ak as Ar,g as Or,al as Lr,am as Vr,an as Tn,ao as Fn,h as zr,ap as Nr,aq as Hr,ar as Gr,as as Wr,at as jr,au as Xr,av as qr,aw as Kr,ax as Yr,ay as Ur,az as Jr,aA as uo}from"../../../chunks/store-fb60485f.js";import{p as Qr}from"../../../chunks/stores-6a6870f3.js";import{f as fo,g as co}from"../../../chunks/format-page-title-2ca75b98.js";import{F as ct,f as Xn,a as Jt,b as Zr,c as xr,d as $r,e as ea,g as ta}from"../../../chunks/fa-33dddbd3.js";import{t as oi,k as pn,l as Qt,_ as en,u as na,O as St,i as Ft,n as oa,h as ia,a as nt,m as mt,v as Bn}from"../../../chunks/error-handler-df8dffd6.js";import{i as ii}from"../../../chunks/fonts-e5a631ed.js";import{m as ra,t as st,c as Zt,f as ho}from"../../../chunks/index-61bb0c2c.js";import{r as yt,M as aa,m as qe,c as ri}from"../../../chunks/merged-header-icon-5b1d438d.js";import{a as la}from"../../../chunks/theme-option-f9f8f697.js";var Ut={schedule:function(t){var e=requestAnimationFrame,n=cancelAnimationFrame,i=Ut.delegate;i&&(e=i.requestAnimationFrame,n=i.cancelAnimationFrame);var o=e(function(r){n=void 0,t(r)});return new oi(function(){return n==null?void 0:n(o)})},requestAnimationFrame:function(){for(var t=[],e=0;e0?t.prototype.requestAsyncId.call(this,n,i,o):(n.actions.push(this),n._scheduled||(n._scheduled=Ut.requestAnimationFrame(function(){return n.flush(void 0)})))},e.prototype.recycleAsyncId=function(n,i,o){var r;if(o===void 0&&(o=0),o!=null?o>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,n,i,o);var a=n.actions;i!=null&&((r=a[a.length-1])===null||r===void 0?void 0:r.id)!==i&&(Ut.cancelAnimationFrame(i),n._scheduled=void 0)},e}(ai),ca=function(t){en(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.flush=function(n){this._active=!0;var i=this._scheduled;this._scheduled=void 0;var o=this.actions,r;n=n||o.shift();do if(r=n.execute(n.state,n.delay))break;while((n=o[0])&&n.id===i&&o.shift());if(this._active=!1,r){for(;(n=o[0])&&n.id===i&&o.shift();)n.unsubscribe();throw r}},e}(li),Pn=new ca(fa),Ht=new St(function(t){return t.complete()});function qn(){for(var t=[],e=0;e!r.parentChapter);let n=t.find(r=>r.progress<100);n||(n=t[t.length-1]);const i=n.parentChapter||n.reference,o=e.findIndex(r=>r.reference===i);return[e,o,i]}function Ia(t){let e,n;return{c(){e=new er(!1),n=zt(),this.h()},l(i){e=tr(i,!1),n=zt(),this.h()},h(){e.a=n},m(i,o){e.m(t[0],i,o),W(i,n,o)},p(i,[o]){o&1&&e.p(i[0])},i:Nt,o:Nt,d(i){i&&M(n),i&&e.d()}}}function Aa(t,e,n){let{html:i}=e;const o=wn();return nr(()=>{o("load")}),t.$$set=r=>{"html"in r&&n(0,i=r.html)},[i]}class ci extends Mt{constructor(e){super(),Et(this,e,Aa,Ia,Dt,{html:0})}}function Oa(t,e){var o;const n=(o=document.elementFromPoint(t,e))==null?void 0:o.closest("p");if(!n)return;const i=Sn(n);if(!!i.length)return{range:Yn(i[0]),parent:n}}function Yn(t,e=0,n=0){const i=new Range;return i.setStart(t,e),i.setEnd(t,n),i}function La(t,e){var a,l,f;const n=(a=t.getSelection())!=null&&a.toString().trim()?(l=t.getSelection())==null?void 0:l.getRangeAt(0):void 0;let i;if(n?i=n:i=e,!i)return;const o=(f=i.endContainer.parentElement)==null?void 0:f.closest("p");if(!o)return;const r=Sn(o);if(!!r.length)return Yn(r[0])}function po(t,e){const n=t.createRange();return n.selectNode(e),n.getBoundingClientRect()}function hi(t,e=250){var n;(n=t.getSelection())==null||n.removeAllRanges(),setTimeout(()=>{var i;(i=t.getSelection())==null||i.addRange(new Range)},e)}function di(t,e,n,i){const o=Math.min(Math.max(i,0),n?t.innerWidth/4:t.innerHeight/4),r=e.getBoundingClientRect(),a=n?o:r.left,l=n?t.innerWidth-o:r.right,f=n?r.top:o,u=n?r.bottom:t.innerHeight-o,g=Number(getComputedStyle(e).lineHeight.replace(/px$/,""));return{elLeftReferencePoint:a,elRightReferencePoint:l,elTopReferencePoint:f,elBottomReferencePoint:u,firstDimensionMargin:o,pointGap:g}}function qt(t,e,n,i=0){if(!t)return;const o=`animate-[pulse_${n}s_cubic-bezier(0.4,0,0.6,1)_${i?"1":"infinite"}]`;t.classList[e](o),i&&setTimeout(()=>t.classList.remove(o),i)}class Va{constructor(e,n,i,o,r=Pn){et(this,"enabled$",new gn(!1));this.multiplier=e,this.verticalMode=n,this.enabled$.pipe(Lt(a=>{if(!a)return Ht;let l=0;return Ca(0,r).pipe(Ke(()=>Date.now()),Da(),Ke(f=>this.calcNewPos(f)),Ke(f=>{l+=f;const u=Math.trunc(l);return l-=u,u}),$t(f=>f!==0))}),st(i)).subscribe(a=>{let l="top";n&&(l="left"),o.documentElement.scrollBy({[l]:a})})}toggle(){this.enabled$.next(!this.enabled$.getValue())}off(){this.enabled$.next(!1)}calcNewPos([e,n]){let i=.00365956;return this.verticalMode&&(i=-91489e-8),i*this.multiplier*(n-e)}}function At(t,e){return e==="rtl"?-t:t}class za{constructor(e,n,i){this.calculator=e,this.window=n,this.firstDimensionMargin=i}scrollToBookmark(e,n=0){const i=this.getBookmarkPosition(e);if(!i)return;const{scrollToData:o}=ko(i,this.firstDimensionMargin),r=this.calculator.verticalMode?"left":"top";o.left!==void 0&&r==="left"?o.left+=n:o.top!==void 0&&r==="top"&&(o.top-=n),this.window.scrollTo(o)}formatBookmarkData(e,n=0){const i=this.calculator.calcExploredCharCount(n),o=this.calculator.charCount,{verticalMode:r}=this.calculator,a=r?"scrollX":"scrollY";return{dataId:e,exploredCharCount:i,progress:i/o,[a]:this.window[a],lastBookmarkModified:new Date().getTime()}}formatBookmarkDataByRange(e){return this.formatBookmarkData(e)}getBookmarkBarPosition(e){const n=this.getBookmarkPosition(e);if(!!n)return ko(n,this.firstDimensionMargin).bookmarkPosData}getBookmarkPosition(e){if(!e.exploredCharCount)return;const{verticalMode:n}=this.calculator,i=this.getBookmarkTargetPosByScrollValue(e);if(i)return i;const o=this.calculator.getScrollPosByCharCount(e.exploredCharCount);return n?{scrollX:o}:{scrollY:o}}getBookmarkTargetPosByScrollValue(e){const{exploredCharCount:n}=e,i=o=>{const r=e[o];if(!r)return;const a=At(r,this.calculator.direction);if(this.calculator.getCharCountByScrollPos(a)===n)return{[o]:r}};return this.calculator.verticalMode?i("scrollX"):i("scrollY")}}function ko(t,e){return"scrollX"in t?{scrollToData:{left:t.scrollX},bookmarkPosData:{right:`${-t.scrollX+e}px`}}:{scrollToData:{top:t.scrollY},bookmarkPosData:{top:`${t.scrollY+e}px`}}}function gi(t){const e=(n,i,o,r)=>{if(or?e(n,i,a-1,r):e(n,a+1,o,r)};return(n,i)=>e(n,0,n.length-1,i)}function Na(){const t=(e,n,i,o)=>{if(i0?t(e,n,r-1,o):t(e,r+1,i,o)};return(e,n)=>t(e,0,e.length-1,n)}const Ha=Na(),Ga=gi(-1),Cn=gi(void 0);class mi{constructor(e,n,i,o,r){et(this,"charCount");et(this,"accumulatedCharCount");et(this,"paragraphPos");et(this,"paragraphs");et(this,"paragraphPosToAccCharCount",new Map);this.containerEl=e,this.axis=n,this.direction=i,this.scrollEl=o,this.document=r,this.paragraphs=Sn(e),this.paragraphPos=Array(this.paragraphs.length),this.accumulatedCharCount=[];let a=0;this.paragraphs.forEach(l=>{a+=Uo(l),this.accumulatedCharCount.push(a)}),this.charCount=a}get verticalMode(){return this.axis==="vertical"}updateParagraphPos(e=0){const n=this.scrollEl.getBoundingClientRect(),i=At(this.verticalMode?n.right:n.top,this.direction),o=Number(getComputedStyle(this.containerEl)[this.verticalMode?"paddingRight":"paddingTop"].replace(/px$/,"")),r=new Map;for(let a=0;a(this.verticalMode?f.width:f.height)<=0?this.paragraphPos[a-1]||0:At(this.verticalMode?f.left:f.bottom,this.direction)-i-o+e)();this.paragraphPos[a]=g;const P=r.get(g)||[];r.set(g,P),P.push(a)}this.paragraphPosToAccCharCount=new Map(Array.from(r.entries()).map(([a,l])=>[a,Math.max(...l.map(f=>this.accumulatedCharCount[f]))]))}calcExploredCharCount(e=0){return this.getCharCountByScrollPos(this.scrollPos+e)}getCharCountByScrollPos(e){const n=Cn(this.paragraphPos,e);return this.paragraphPosToAccCharCount.get(this.paragraphPos[n])||0}getBookMarkPosForSection(e,n){const i=Math.max(0,Ga(this.accumulatedCharCount,n-e));let o=i,r=this.processSectionBookmarkIteration(i,e,n);if(!r){for(let a=i+1,{length:l}=this.accumulatedCharCount;ai){let a=this.paragraphs[e];a.parentElement&&(a=a.parentElement.closest("p")||a.parentElement);const{top:l,right:f,left:u}=po(this.document,a);r=this.axis==="horizontal"?{left:f}:{top:l,left:u}}return r}get scrollPos(){return At(this.scrollEl[this.scrollPosProp],this.direction)}get scrollPosProp(){return this.verticalMode?"scrollLeft":"scrollTop"}}function Wa(t,e,n){const i=qa(e,n)(t,"scrollLeft");return(o,r,a)=>{if(!ja(o))return;const l=Xa(o,r,a);i(-l),o.preventDefault()}}function ja(t){return!(!t.deltaY||t.deltaX||t.altKey||t.shiftKey||t.ctrlKey||t.metaKey)}function Xa(t,e,n){switch(t.deltaMode){case 0:return t.deltaY;case 1:return t.deltaY*e*1.75;default:return t.deltaY*n}}function qa(t,e){return(n,i)=>{let o=!1,r=t[i],a=t[i];const l=()=>{o=!0;const f=Math.trunc((r-t[i])/n);if(t[i]!==a){o=!1;return}if(a+=f,t.scrollBy(f,0),Math.abs(f)>0){e(l);return}o=!1};return f=>{o||(r=t[i],a=t[i]),r+=f,o||e(l)}}}class Ka{constructor(e,n,i){this.verticalMode=e,this.firstDimensionMargin=n,this.window=i}nextPage(){this.scrollByPercent(.95)}prevPage(){this.scrollByPercent(-.95)}updateSectionDataByOffset(){}scrollTo(e){this.window.scrollTo({[this.verticalMode?"left":"top"]:e})}scrollByPercent(e){let n=this.window.innerHeight,i="top",o=1;this.verticalMode&&(n=this.window.innerWidth,i="left",o=-1);const r=n-this.firstDimensionMargin*2;this.window.scrollBy({[i]:r*e*o,behavior:"smooth"})}}const{document:bo,window:Ya}=Gn;function Co(t){let e,n,i,o,r;return{c(){e=$("div"),i=ue(),o=$("div"),this.h()},l(a){e=ee(a,"DIV",{class:!0,style:!0}),te(e).forEach(M),i=fe(a),o=ee(a,"DIV",{class:!0,style:!0}),te(o).forEach(M),this.h()},h(){J(e,"class","fixed z-[5]"),J(e,"style",n=t[23]+": 100%; "+t[22]+": "+t[15]+"px; "+t[21][0]+": 0"),X(e,"inset-y-0",t[2]),X(e,"inset-x-0",!t[2]),y(e,"background-color",t[4]),J(o,"class","fixed z-[5]"),J(o,"style",r=t[23]+": 100%; "+t[22]+": "+t[15]+"px; "+t[21][1]+": 0"),X(o,"inset-y-0",t[2]),X(o,"inset-x-0",!t[2]),y(o,"background-color",t[4])},m(a,l){W(a,e,l),W(a,i,l),W(a,o,l)},p(a,l){l[0]&14712832&&n!==(n=a[23]+": 100%; "+a[22]+": "+a[15]+"px; "+a[21][0]+": 0")&&J(e,"style",n),l[0]&4&&X(e,"inset-y-0",a[2]),l[0]&4&&X(e,"inset-x-0",!a[2]),l[0]&16&&y(e,"background-color",a[4]),l[0]&14712832&&r!==(r=a[23]+": 100%; "+a[22]+": "+a[15]+"px; "+a[21][1]+": 0")&&J(o,"style",r),l[0]&4&&X(o,"inset-y-0",a[2]),l[0]&4&&X(o,"inset-x-0",!a[2]),l[0]&16&&y(o,"background-color",a[4])},d(a){a&&M(e),a&&M(i),a&&M(o)}}}function _o(t){let e,n,i,o;const r=[Ja,Ua],a=[];function l(f,u){return f[2]?0:1}return e=l(t),n=a[e]=r[e](t),{c(){n.c(),i=zt()},l(f){n.l(f),i=zt()},m(f,u){a[e].m(f,u),W(f,i,u),o=!0},p(f,u){let g=e;e=l(f),e===g?a[e].p(f,u):(ut(),Y(a[g],1,1,()=>{a[g]=null}),ft(),n=a[e],n?n.p(f,u):(n=a[e]=r[e](f),n.c()),q(n,1),n.m(i.parentNode,i))},i(f){o||(q(n),o=!0)},o(f){Y(n),o=!1},d(f){a[e].d(f),f&&M(i)}}}function Ua(t){let e,n,i;return n=new ct({props:{icon:Jt}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","pointer-events-none absolute text-sm opacity-25 sm:text-xl"),y(e,"color",t[3]),y(e,"left",t[17]),y(e,"top",`calc(${t[19].top} + 1.5rem)`)},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&8&&y(e,"color",o[3]),r[0]&131072&&y(e,"left",o[17]),r[0]&524288&&y(e,"top",`calc(${o[19].top} + 1.5rem)`)},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function Ja(t){let e,n,i;return n=new ct({props:{icon:Jt}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","pointer-events-none absolute text-xl opacity-25"),y(e,"color",t[3]),y(e,"right",`calc(${t[19].right} + 1rem)`),y(e,"top",t[17])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&8&&y(e,"color",o[3]),r[0]&524288&&y(e,"right",`calc(${o[19].right} + 1rem)`),r[0]&131072&&y(e,"top",o[17])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function wo(t){let e,n,i;return n=new ct({props:{icon:Xn,spin:!0}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed inset-0 flex h-full w-full items-center justify-center text-7xl"),y(e,"color",t[3]),y(e,"background-color",t[4])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&8&&y(e,"color",o[3]),r[0]&16&&y(e,"background-color",o[4])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function Qa(t){let e,n,i=`${t[9]}px`,o=`${t[20]||t[1]}px`,r,a,l,f,u,g,P;n=new ci({props:{html:t[0]}}),n.$on("load",t[27]);let k=t[15]&&Co(t),m=t[19]&&_o(t),v=!t[18]&&wo(t);return{c(){e=$("div"),Me(n.$$.fragment),r=ue(),k&&k.c(),a=ue(),m&&m.c(),l=ue(),v&&v.c(),f=ue(),this.h()},l(s){e=ee(s,"DIV",{class:!0});var C=te(e);Ee(n.$$.fragment,C),C.forEach(M),r=fe(s),k&&k.l(s),a=fe(s),m&&m.l(s),l=fe(s),v&&v.l(s),f=fe(s),this.h()},h(){J(e,"class","book-content m-auto svelte-1ouz3ba"),X(e,"book-content--writing-vertical-rl",t[2]),X(e,"book-content--writing-horizontal-rl",!t[2]),X(e,"book-content--hide-furigana",t[12]),X(e,"book-content--hide-spoiler-image",t[11]),X(e,"book-content--furigana-style-partial",t[13]===it.Partial),X(e,"book-content--furigana-style-full",t[13]===it.Full),X(e,"book-content--furigana-style-toggle",t[13]===it.Toggle),y(e,"color",t[3]),y(e,"font-size",i),y(e,"line-height",t[10]),y(e,"max-width",!t[2]&&t[14]?`${t[14]}px`:void 0),y(e,"max-height",t[20]?`${t[20]}px`:void 0),y(e,"padding-left",t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"padding-right",t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"padding-top",!t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"padding-bottom",!t[2]&&t[15]?`${t[15]}px`:void 0),y(e,"--font-family-serif",t[7]),y(e,"--font-family-sans-serif",t[8]),y(e,"--book-content-hint-furigana-font-color",t[5]),y(e,"--book-content-hint-furigana-shadow-color",t[6]),y(e,"--book-content-child-height",o)},m(s,C){W(s,e,C),De(n,e,null),t[49](e),W(s,r,C),k&&k.m(s,C),W(s,a,C),m&&m.m(s,C),W(s,l,C),v&&v.m(s,C),W(s,f,C),u=!0,g||(P=[Ce(Ya,"scroll",t[26]),Ce(bo.body,"wheel",t[25],{passive:!1}),Ce(bo.body,"mousedown",t[50])],g=!0)},p(s,C){const p={};C[0]&1&&(p.html=s[0]),n.$set(p),(!u||C[0]&4)&&X(e,"book-content--writing-vertical-rl",s[2]),(!u||C[0]&4)&&X(e,"book-content--writing-horizontal-rl",!s[2]),(!u||C[0]&4096)&&X(e,"book-content--hide-furigana",s[12]),(!u||C[0]&2048)&&X(e,"book-content--hide-spoiler-image",s[11]),(!u||C[0]&8192)&&X(e,"book-content--furigana-style-partial",s[13]===it.Partial),(!u||C[0]&8192)&&X(e,"book-content--furigana-style-full",s[13]===it.Full),(!u||C[0]&8192)&&X(e,"book-content--furigana-style-toggle",s[13]===it.Toggle),C[0]&8&&y(e,"color",s[3]),C[0]&512&&i!==(i=`${s[9]}px`)&&y(e,"font-size",i),C[0]&1024&&y(e,"line-height",s[10]),C[0]&16388&&y(e,"max-width",!s[2]&&s[14]?`${s[14]}px`:void 0),C[0]&1048576&&y(e,"max-height",s[20]?`${s[20]}px`:void 0),C[0]&32772&&y(e,"padding-left",s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&32772&&y(e,"padding-right",s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&32772&&y(e,"padding-top",!s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&32772&&y(e,"padding-bottom",!s[2]&&s[15]?`${s[15]}px`:void 0),C[0]&128&&y(e,"--font-family-serif",s[7]),C[0]&256&&y(e,"--font-family-sans-serif",s[8]),C[0]&32&&y(e,"--book-content-hint-furigana-font-color",s[5]),C[0]&64&&y(e,"--book-content-hint-furigana-shadow-color",s[6]),C[0]&1048578&&o!==(o=`${s[20]||s[1]}px`)&&y(e,"--book-content-child-height",o),s[15]?k?k.p(s,C):(k=Co(s),k.c(),k.m(a.parentNode,a)):k&&(k.d(1),k=null),s[19]?m?(m.p(s,C),C[0]&524288&&q(m,1)):(m=_o(s),m.c(),q(m,1),m.m(l.parentNode,l)):m&&(ut(),Y(m,1,1,()=>{m=null}),ft()),s[18]?v&&(ut(),Y(v,1,1,()=>{v=null}),ft()):v?(v.p(s,C),C[0]&262144&&q(v,1)):(v=wo(s),v.c(),q(v,1),v.m(f.parentNode,f))},i(s){u||(q(n.$$.fragment,s),q(m),q(v),u=!0)},o(s){Y(n.$$.fragment,s),Y(m),Y(v),u=!1},d(s){s&&M(e),Te(n),t[49](null),s&&M(r),k&&k.d(s),s&&M(a),m&&m.d(s),s&&M(l),v&&v.d(s),s&&M(f),g=!1,Tt(P)}}}function Za(t,e,n){let i,o,r,a,l,f,u,g,P;G(t,Jo,S=>n(57,l=S)),G(t,Kt,S=>n(58,f=S)),G(t,Qo,S=>n(24,u=S)),G(t,Vt,S=>n(59,g=S)),G(t,Zo,S=>n(48,P=S));let{htmlContent:k}=e,{width:m}=e,{height:v}=e,{verticalMode:s}=e,{fontColor:C}=e,{backgroundColor:p}=e,{hintFuriganaFontColor:E}=e,{hintFuriganaShadowColor:N}=e,{fontFamilyGroupOne:R}=e,{fontFamilyGroupTwo:F}=e,{fontSize:z}=e,{lineHeight:K}=e,{hideSpoilerImage:D}=e,{hideFurigana:B}=e,{furiganaStyle:L}=e,{secondDimensionMaxValue:T}=e,{firstDimensionMargin:I}=e,{autoPositionOnResize:w}=e,{autoBookmark:V}=e,{loadingState:b}=e,{multiplier:A}=e,{bookmarkData:Q}=e,{exploredCharCount:re}=e,{bookCharCount:pe}=e,{autoScroller:Ve}=e,{bookmarkManager:Pe}=e,{pageManager:_e}=e,{customReadingPoint:Ie}=e,{customReadingPointLeft:ze}=e,{customReadingPointTop:de}=e,{customReadingPointScrollOffset:oe}=e;const ie=wn();let Fe=!1,U,Z,Ne={},ve,ye,_,O,He,j=0,Be=!1,ke=window.matchMedia("(min-width: 640px)").matches?"0.5rem":"0.25rem",Ae=!1;const dt=Wa(4,document.documentElement,requestAnimationFrame),Ue=new nt,be=new nt,me=new nt,Je=new Map,Qe=new Map;let ge=0,at=!1;Hn(()=>{me.next(),me.complete()}),ve=new Va(A,s,me,document),Ve=ve,Zt([Ue,be]).pipe($t(()=>w),mn(1),Ke(([S,ae])=>s?ae:S),si(),xt(10),xo(Pn),st(me)).subscribe(()=>{if(!Z||!_)return;const S=Z.getScrollPosByCharCount(j)+(s?oe:-oe);Be=!0,_.scrollTo(S)});function Ge(){if(!P||!U)return;const{elLeftReferencePoint:S,elTopReferencePoint:ae,elRightReferencePoint:We,elBottomReferencePoint:Oe,firstDimensionMargin:d,pointGap:x}=di(window,U,s,I);if(s){n(34,de=ae),n(33,ze=Math.min(Math.max(d+(We-S)*(Ie/100)-2,S+x),We-2)),n(35,oe=window.innerWidth-d-ze);return}n(34,de=Math.min(Math.max(d+(Oe-ae)*(Ie/100),d),Oe-x*1.5)),n(33,ze=S),n(35,oe=de-d)}function pt(S){S.updateParagraphPos(),Ge(),n(28,re=S.calcExploredCharCount(oe)),He&&(He=!1,Q.then(ae=>{!ae||!Pe||(j=ae.exploredCharCount||0,Pe.scrollToBookmark(ae,oe))}).finally(()=>{V&&rt(window,"scroll").pipe(mn(1),xt(3e3),st(me)).subscribe(()=>{ie("bookmark")}),Kn.pipe(Gt(1),Lt(ae=>ae.length?(ae.forEach(We=>{const Oe=We.reference,d=document.getElementById(Oe);d&&(ge||(ge=Number(getComputedStyle(d)[s?"marginLeft":"marginBottom"].replace(/px$/,""))/2),Qe.set(Oe,{...We,progress:0}),Je.set(Oe,d))}),Je.size?(je(),rt(window,"scroll")):Ht):Ht),Ra(()=>nn(at?100:500)),st(me)).subscribe(je)})),n(44,Ne={}),n(18,Fe=!0)}function je(){const S=[...Qe.entries()];for(let ae=0,{length:We}=S;ae{!Z||(n(28,re=Z.calcExploredCharCount(oe)),!Be&&re&&(j=re),Be=!1)})}function gt(){if(!U)return;n(43,Z=new mi(U,s?"vertical":"horizontal",s?"rtl":"ltr",document.documentElement,document)),n(28,re=0),j=re,n(29,pe=Z.charCount);let S=!1;try{S=document.fonts.check(`${z}px ${R||"Noto Serif JP"}`)}catch(ae){mt.error(`Error checking Font Load: ${ae.message}`),S=!0}if(S)ie("contentChange",U);else if(!Ae){Ae=!0;const ae=ii(R,l)?3e4:1e4,We=setTimeout(()=>{mt.error(`Error loading primary Font: ${R}`),ie("contentChange",U)},ae);document.fonts.addEventListener("loadingdone",()=>{clearTimeout(We),ie("contentChange",U)})}}rn.pipe(st(me)).subscribe(S=>{let ae=document.getElementById(S);if(!ae)return;ae=!S.startsWith(ao)&&ae.closest(`div[id^="${ao}"]`)||ae,at=!0;const Oe=ae.getBoundingClientRect();s?window.scrollBy(-(window.innerWidth-Oe.right-(I||0)-oe-(!oe||oe&&ge>oe?ge:0)),0):window.scrollBy(0,Oe.top-(I||0)-oe-(!oe||oe&&ge>oe?ge:0))});function Re(S){ne[S?"unshift":"push"](()=>{U=S,n(16,U)})}const kt=S=>{u&&S.button===1&&S.preventDefault()};return t.$$set=S=>{"htmlContent"in S&&n(0,k=S.htmlContent),"width"in S&&n(36,m=S.width),"height"in S&&n(1,v=S.height),"verticalMode"in S&&n(2,s=S.verticalMode),"fontColor"in S&&n(3,C=S.fontColor),"backgroundColor"in S&&n(4,p=S.backgroundColor),"hintFuriganaFontColor"in S&&n(5,E=S.hintFuriganaFontColor),"hintFuriganaShadowColor"in S&&n(6,N=S.hintFuriganaShadowColor),"fontFamilyGroupOne"in S&&n(7,R=S.fontFamilyGroupOne),"fontFamilyGroupTwo"in S&&n(8,F=S.fontFamilyGroupTwo),"fontSize"in S&&n(9,z=S.fontSize),"lineHeight"in S&&n(10,K=S.lineHeight),"hideSpoilerImage"in S&&n(11,D=S.hideSpoilerImage),"hideFurigana"in S&&n(12,B=S.hideFurigana),"furiganaStyle"in S&&n(13,L=S.furiganaStyle),"secondDimensionMaxValue"in S&&n(14,T=S.secondDimensionMaxValue),"firstDimensionMargin"in S&&n(15,I=S.firstDimensionMargin),"autoPositionOnResize"in S&&n(37,w=S.autoPositionOnResize),"autoBookmark"in S&&n(38,V=S.autoBookmark),"loadingState"in S&&n(39,b=S.loadingState),"multiplier"in S&&n(40,A=S.multiplier),"bookmarkData"in S&&n(41,Q=S.bookmarkData),"exploredCharCount"in S&&n(28,re=S.exploredCharCount),"bookCharCount"in S&&n(29,pe=S.bookCharCount),"autoScroller"in S&&n(30,Ve=S.autoScroller),"bookmarkManager"in S&&n(31,Pe=S.bookmarkManager),"pageManager"in S&&n(32,_e=S.pageManager),"customReadingPoint"in S&&n(42,Ie=S.customReadingPoint),"customReadingPointLeft"in S&&n(33,ze=S.customReadingPointLeft),"customReadingPointTop"in S&&n(34,de=S.customReadingPointTop),"customReadingPointScrollOffset"in S&&n(35,oe=S.customReadingPointScrollOffset)},t.$$.update=()=>{if(t.$$.dirty[0]&4&&n(23,i=s?"height":"width"),t.$$.dirty[0]&4&&n(22,o=s?"width":"height"),t.$$.dirty[0]&4&&n(21,r=s?["left","right"]:["top","bottom"]),t.$$.dirty[1]&32&&Ue.next(m),t.$$.dirty[0]&2&&be.next(v),t.$$.dirty[0]&16388&&n(20,a=s&&T?T:void 0),t.$$.dirty[0]&212996&&T&&U){const S=Number(getComputedStyle(U)[s?"marginTop":"marginRight"].replace(/px$/,""));n(17,ke=`min(max(calc(${`${S}px - ${ke}`}), ${ke}), ${S?`${S}px`:ke})`)}if(t.$$.dirty[0]&1&&k&&(He=!0),t.$$.dirty[0]&2|t.$$.dirty[1]&4384&&Z&&m&&v&&!b){const S=Z;requestAnimationFrame(()=>{pt(S)})}t.$$.dirty[0]&4|t.$$.dirty[1]&16896&&ve&&(n(45,ve.multiplier=A,ve),n(45,ve.verticalMode=s,ve)),t.$$.dirty[0]&32768|t.$$.dirty[1]&36864&&Z&&(n(46,ye=Z&&new za(Z,window,I||0)),n(31,Pe=ye)),t.$$.dirty[1]&41984&&Ne&&(n(19,O=void 0),Q.then(S=>{!S||n(19,O=ye==null?void 0:ye.getBookmarkBarPosition(S))})),t.$$.dirty[0]&32772|t.$$.dirty[1]&65536&&(n(47,_=new Ka(s,I,window)),n(32,_e=_)),t.$$.dirty[0]&65536|t.$$.dirty[1]&133120&&P&&U&&Number.isFinite(Ie)&&(Ge(),Xe(),je())},[k,v,s,C,p,E,N,R,F,z,K,D,B,L,T,I,U,ke,Fe,O,a,r,o,i,u,Ze,Xe,gt,re,pe,Ve,Pe,_e,ze,de,oe,m,w,V,b,A,Q,Ie,Z,Ne,ve,ye,_,P,Re,kt]}class xa extends Mt{constructor(e){super(),Et(this,e,Za,Qa,Dt,{htmlContent:0,width:36,height:1,verticalMode:2,fontColor:3,backgroundColor:4,hintFuriganaFontColor:5,hintFuriganaShadowColor:6,fontFamilyGroupOne:7,fontFamilyGroupTwo:8,fontSize:9,lineHeight:10,hideSpoilerImage:11,hideFurigana:12,furiganaStyle:13,secondDimensionMaxValue:14,firstDimensionMargin:15,autoPositionOnResize:37,autoBookmark:38,loadingState:39,multiplier:40,bookmarkData:41,exploredCharCount:28,bookCharCount:29,autoScroller:30,bookmarkManager:31,pageManager:32,customReadingPoint:42,customReadingPointLeft:33,customReadingPointTop:34,customReadingPointScrollOffset:35},null,[-1,-1,-1])}}const $a="px-4 md:px-8";function el(t){const e=Array.from(t.getElementsByTagName("img"));return new St(n=>{const i=e.filter(r=>r.src).map(tl);if(i.length<=0){n.next(!1),n.complete();return}const o=Zt(i).subscribe(()=>{n.next(!1),n.complete()});return n.next(!0),o})}function tl(t){return t.complete?qn(1):Sa(rt(t,"load"),rt(t,"error"))}function nl(t,e){const n=ol(t),i=rl(t);return o=>on(n(o),il(o,e),i(o))}function ol(t){return e=>{const n=Array.from(e.getElementsByTagName("a"));n.forEach(o=>{o.href=t.location.pathname+o.hash});const i=n.map(o=>_n(o).pipe(_t(()=>rn.next(o.hash.substring(1)))));return on(...i)}}function il(t,e){const n=e===it.Toggle,o=Array.from(t.getElementsByTagName("ruby")).map(r=>n?_n(r).pipe(_t(()=>{r.classList.toggle("reveal-rt")})):_n(r).pipe(Gt(1),_t(()=>{r.classList.add("reveal-rt")})));return on(...o)}function rl(t){return e=>{const i=Array.from(e.querySelectorAll("[data-ttu-spoiler-img]")).map(o=>{const r=t.createElement("span");return r.classList.add("spoiler-label"),r.setAttribute("aria-hidden","true"),r.innerText="SPOILER",o.appendChild(r),_n(o).pipe(Gt(1),_t(()=>{o.removeChild(r),o.removeAttribute("data-ttu-spoiler-img")}))});return on(...i)}}function _n(t){return rt(t,"click").pipe(_t(e=>{e.preventDefault(),e.stopImmediatePropagation()}))}const al=300,ll=60,pi="none";function Xt(t,e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}function sl(t,e){return e.filter(n=>t.pointerId!==n.pointerId)}function un(t,e,n,i,o){t.dispatchEvent(new CustomEvent(`${e}${o}`,{detail:{event:n,pointersCount:i.length}}))}function ul(t,e,n,i,o,r=pi){e.style.touchAction=r;let a=[];function l(u){a.push(u),un(e,t,u,a,"down"),i==null||i(a,u);const g=u.pointerId;function P(p){g===p.pointerId&&(a=sl(p,a),a.length||k(),un(e,t,p,a,"up"),o==null||o(a,p))}function k(){m(),v(),s(),C()}const m=Xt(e,"pointermove",p=>{a=a.map(E=>p.pointerId===E.pointerId?p:E),un(e,t,p,a,"move"),n==null||n(a,p)}),v=Xt(e,"lostpointercapture",p=>{P(p)}),s=Xt(e,"pointerup",p=>{P(p)}),C=Xt(e,"pointerleave",p=>{a=[],k(),un(e,t,p,a,"up"),o==null||o(a,p)})}const f=Xt(e,"pointerdown",l);return{destroy:()=>{f()}}}function fl(t,e={timeframe:al,minSwipeDistance:ll,touchAction:pi}){const n="swipe";let i,o,r,a;function l(u,g){o=g.clientX,r=g.clientY,i=Date.now(),u.length===1&&(a=g.target)}function f(u,g){if(g.type==="pointerup"&&u.length===0&&Date.now()-i=2*v&&m>e.minSwipeDistance?s=P>0?"right":"left":v>=2*m&&v>e.minSwipeDistance&&(s=k>0?"bottom":"top"),s&&t.dispatchEvent(new CustomEvent(n,{detail:{direction:s,target:a}}))}}return ul(n,t,null,l,f,e.touchAction)}class cl{constructor(e,n,i,o,r){this.calculator=e,this.pageManager=n,this.sectionReady$=i,this.sectionIndex$=o,this.setIntendedCharCount=r}scrollToBookmark(e){const n=e.exploredCharCount;if(!n)return;const i=this.calculator.getSectionIndexByCharCount(n),o=l=>{const f=l.getScrollPosByCharCount(n);this.pageManager.scrollTo(f,!1),this.setIntendedCharCount(n)};if(this.sectionIndex$.getValue()===i){o(this.calculator);return}const a=this.sectionReady$.subscribe(l=>{o(l),a.unsubscribe()});this.sectionIndex$.next(i)}formatBookmarkData(e){return this.formatBookmarkDataByRange(e,void 0)}formatBookmarkDataByRange(e,n){const i=this.calculator.calcExploredCharCount(n),o=this.calculator.charCount;return{dataId:e,exploredCharCount:i,progress:i/o,lastBookmarkModified:new Date().getTime()}}}class hl{constructor(e,n,i,o,r,a,l,f,u,g,P){et(this,"translateX",0);et(this,"sectionData",new Map);this.contentEl=e,this.scrollEl=n,this.sections=i,this.sectionIndex$=o,this.virtualScrollPos$=r,this.width=a,this.height=l,this.pageGap=f,this.verticalMode=u,this.pageChange$=g,this.sectionRenderComplete$=P,Kn.pipe(Gt(1)).subscribe(k=>{!k.length||(k.forEach(m=>{this.sectionData.set(m.reference,{...m,progress:0})}),bn.next(this.sectionData))})}nextPage(){this.flipPage(1)}prevPage(){this.flipPage(-1)}updateSectionDataByOffset(e=0){var o,r;const n=this.verticalMode?this.height:this.width,i=this.virtualScrollPos$.getValue()/this.scrollEl[this.verticalMode?"scrollHeight":"scrollWidth"]*100;if(e){const l=(this.virtualScrollPos$.getValue()+n+this.pageGap)/this.scrollEl[this.verticalMode?"scrollHeight":"scrollWidth"]*100-i;this.updateSectionData((o=this.sections[this.sectionIndex$.getValue()])==null?void 0:o.id,i+l*e)}else this.updateSectionData((r=this.sections[this.sectionIndex$.getValue()])==null?void 0:r.id,i)}flipPage(e){const n=this.verticalMode?"scrollHeight":"scrollWidth",i=this.verticalMode?this.height:this.width,o=i+this.pageGap,r=!0;if(this.translateX){const P=()=>{this.contentEl.style.removeProperty("transform"),this.translateX=0};if(e<0){const k=this.translateX;P(),this.scrollToPos(-k-o,r);return}if(this.nextSection(r)){P();return}return}const a=0,l=this.scrollEl[n],f=this.virtualScrollPos$.getValue(),u=f+o*e,g=Math.ceil(u);if(g=l){this.nextSection(r);return}this.scrollOrTranslateToPos(u,l,i,r)}scrollTo(e,n){const i=this.verticalMode?"scrollHeight":"scrollWidth",o=this.verticalMode?this.height:this.width;this.scrollOrTranslateToPos(e,this.scrollEl[i],o,n)}prevSection(e,n,i,o){const r=this.sectionIndex$.getValue()-1;return r<0?!1:(this.updateSectionIndex(r).subscribe(()=>{const a=this.scrollEl[n];let l=e*(Math.ceil(a/e)-1);Math.ceil(l)>=a&&(l-=e),this.scrollOrTranslateToPos(l,a,i,o)}),!0)}nextSection(e){const n=this.sectionIndex$.getValue()+1;return n>=this.sections.length?!1:(this.updateSectionIndex(n).subscribe(()=>{var i,o;this.scrollToPos(0,e),this.updateSectionData((i=this.sections[n-1])==null?void 0:i.id,100,!1),this.updateSectionData((o=this.sections[n])==null?void 0:o.id,0)}),!0)}scrollOrTranslateToPos(e,n,i,o){var a;if(this.updateSectionData((a=this.sections[this.sectionIndex$.getValue()])==null?void 0:a.id,e/n*100),this.verticalMode){this.scrollToPos(e,o);return}if(e+i<=n){this.scrollToPos(e,o);return}this.translateXToPos(-e,o)}scrollToPos(e,n){this.virtualScrollPos$.next(e),this.scrollEl.scrollTo({[this.verticalMode?"top":"left"]:e}),this.pageChange$.next(n)}translateXToPos(e,n){this.virtualScrollPos$.next(-e),this.contentEl.style.transform=`translateX(${e}px)`,this.translateX=e,this.pageChange$.next(n)}updateSectionIndex(e){return new St(n=>{if(this.sectionIndex$.getValue()===e){n.next(),n.complete();return}const i=this.sectionRenderComplete$.subscribe(o=>{o===e&&n.next(),n.complete(),i.unsubscribe()});return this.sectionIndex$.next(e),i})}updateSectionData(e,n,i=!0){if(!e||!this.sectionData.has(e))return;const o=[...this.sectionData.values()];let r=!1;o.forEach(a=>{const l=this.sectionData.get(a.reference),f=a.reference===e;f?l.progress=n:r?l.progress=0:l.progress=100,!r&&f&&(r=!0),this.sectionData.set(a.reference,l)}),i&&bn.next(this.sectionData)}}class dl{constructor(e,n,i,o,r,a,l,f,u){et(this,"charCount");et(this,"sectionAccCharCounts");et(this,"sectionIndex",-1);et(this,"calculator");this.containerEl=e,this.sections=n,this.virtualScrollPos$=i,this.getWidth=o,this.getHeight=r,this.getPageGap=a,this.verticalMode=l,this.scrollEl=f,this.document=u;const g=k=>Sn(k).reduce((v,s)=>v+Uo(s),0);let P=0;this.sectionAccCharCounts=n.map(k=>(P+=g(k),P)),this.charCount=P}updateCurrentSection(e){this.calculator=new mi(this.containerEl,this.verticalMode?"horizontal":"vertical","ltr",this.scrollEl,this.document),this.sectionIndex=e}updateParagraphPos(){!this.calculator||this.calculator.updateParagraphPos(this.virtualScrollPos$.getValue())}calcExploredCharCount(e){if(e&&this.calculator)return this.getSectionStartCount()+this.calculator.getCharCountToPoint(e);const n=this.verticalMode?0:-this.screenSize;return this.getCharCountByScrollPos(this.virtualScrollPos$.getValue()+n)}getCharCountByScrollPos(e){if(!this.calculator)return-1;const n=this.getSectionStartCount();return this.calculator.getCharCountByScrollPos(e)+n}getSectionIndexByCharCount(e){return Cn(this.sectionAccCharCounts,e)+1}getScrollPosByCharCount(e){if(!this.calculator)return-1;const n=this.getSectionStartCount(),i=this.sectionAccCharCounts[this.sectionIndex],o=e-n,r=e===i&&i-n>0;if(o<0||e>i||r)return-1;if(o===0)return 0;const a=Cn(this.calculator.accumulatedCharCount,o),{accumulatedCharCount:l,paragraphPos:f}=this.calculator,u=l[a];if(Number.isNaN(Number(f[a])))return-1;const g=(s,C)=>s>=C?C:l[s]>u?s:g(s+1,C),P=f[g(a+1,l.length-1)],{screenSize:k}=this,m=this.verticalMode?-1:0,v=k*(Math.ceil(P/k)+m);return At(v,this.calculator.direction)}checkBookmarkOnScreen(e){const n=this.getScrollPosByCharCount(e),i=this.virtualScrollPos$.getValue();return n===i&&this.calculator?{isBookmarkScreen:!0,...this.calculator.getBookMarkPosForSection(this.getSectionStartCount(),e)}:{isBookmarkScreen:n===i,bookmarkPos:void 0,node:void 0,isFirstNode:!0}}getOffsetToRange(e,n){if(!e)return 0;const i=e.getBoundingClientRect();if(this.verticalMode)return 1-i.left/this.screenSizeMirrored;const o=Math.floor(100/n),r=Math.floor(this.screenSize/n),a=o*i.bottom/this.screenSizeMirrored;let l=a,f=0;for(let u=0;u=u;u+=r)l=f*o+a,f+=1;return l/100}getSectionStartCount(){return this.sectionAccCharCounts[this.sectionIndex-1]||0}get screenSize(){return(this.verticalMode?this.getHeight():this.getWidth())+this.getPageGap()}get screenSizeMirrored(){return(this.verticalMode?this.getWidth():this.getHeight())+this.getPageGap()}}const{window:gl}=Gn;function So(t){let e,n,i;return n=new ct({props:{icon:Xn,spin:!0}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed inset-0 flex h-full w-full items-center justify-center text-7xl"),y(e,"color",t[4]),y(e,"background-color",t[5])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&16&&y(e,"color",o[4]),r[0]&32&&y(e,"background-color",o[5])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function Po(t){let e,n,i;return n=new ct({props:{icon:Jt}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed h-3 w-3 text-base opacity-25 sm:text-xl"),y(e,"color",t[4]),y(e,"top",t[21]),y(e,"left",t[22]),y(e,"right",t[23])},m(o,r){W(o,e,r),De(n,e,null),i=!0},p(o,r){r[0]&16&&y(e,"color",o[4]),r[0]&2097152&&y(e,"top",o[21]),r[0]&4194304&&y(e,"left",o[22]),r[0]&8388608&&y(e,"right",o[23])},i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function ml(t){let e,n,i,o,r=`${t[10]}px`,a=`${t[1]}px`,l=`${t[2]}px`,f=`${t[3]?t[1]:(t[1]+Ot)/t[24]-Ot}px`,u,g,P,k,m,v;i=new ci({props:{html:t[20]}}),i.$on("load",t[26]);let s=!t[19]&&So(t),C=t[0]&&Po(t);return{c(){e=$("div"),n=$("div"),Me(i.$$.fragment),u=ue(),s&&s.c(),g=ue(),C&&C.c(),P=zt(),this.h()},l(p){e=ee(p,"DIV",{class:!0});var E=te(e);n=ee(E,"DIV",{class:!0});var N=te(n);Ee(i.$$.fragment,N),N.forEach(M),E.forEach(M),u=fe(p),s&&s.l(p),g=fe(p),C&&C.l(p),P=zt(),this.h()},h(){J(n,"class","book-content-container svelte-u9j5ct"),J(e,"class","book-content m-auto svelte-u9j5ct"),X(e,"book-content--avoid-page-break",t[15]),X(e,"book-content--writing-vertical-rl",t[3]),X(e,"book-content--writing-horizontal-rl",!t[3]),X(e,"book-content--hide-furigana",t[13]),X(e,"book-content--hide-spoiler-image",t[12]),X(e,"book-content--furigana-style-partial",t[14]===it.Partial),X(e,"book-content--furigana-style-full",t[14]===it.Full),X(e,"book-content--furigana-style-toggle",t[14]===it.Toggle),y(e,"color",t[4]),y(e,"font-size",r),y(e,"line-height",t[11]),y(e,"padding-top",!t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"padding-bottom",!t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"padding-left",t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"padding-right",t[3]&&t[16]?`${t[16]}px`:void 0),y(e,"max-width",t[1]?`${t[1]}px`:void 0),y(e,"max-height",t[3]&&t[2]?`${t[2]}px`:void 0),y(e,"--font-family-serif",t[8]),y(e,"--font-family-sans-serif",t[9]),y(e,"--book-content-hint-furigana-font-color",t[6]),y(e,"--book-content-hint-furigana-shadow-color",t[7]),y(e,"--book-content-child-width",a),y(e,"--book-content-child-height",l),y(e,"--book-content-child-column-width",!t[3]&&t[24]===1?`${t[1]}px`:""),y(e,"--book-content-column-count",t[24]),y(e,"--book-content-image-max-width",f)},m(p,E){W(p,e,E),le(e,n),De(i,n,null),t[44](n),t[45](e),W(p,u,E),s&&s.m(p,E),W(p,g,E),C&&C.m(p,E),W(p,P,E),k=!0,m||(v=[Ce(gl,"keydown",t[28]),Wn(o=fl.call(null,e,{timeframe:500,minSwipeDistance:t[25],touchAction:"pan-y"})),Ce(e,"swipe",t[27])],m=!0)},p(p,E){const N={};E[0]&1048576&&(N.html=p[20]),i.$set(N),o&&jo(o.update)&&E[0]&33554432&&o.update.call(null,{timeframe:500,minSwipeDistance:p[25],touchAction:"pan-y"}),(!k||E[0]&32768)&&X(e,"book-content--avoid-page-break",p[15]),(!k||E[0]&8)&&X(e,"book-content--writing-vertical-rl",p[3]),(!k||E[0]&8)&&X(e,"book-content--writing-horizontal-rl",!p[3]),(!k||E[0]&8192)&&X(e,"book-content--hide-furigana",p[13]),(!k||E[0]&4096)&&X(e,"book-content--hide-spoiler-image",p[12]),(!k||E[0]&16384)&&X(e,"book-content--furigana-style-partial",p[14]===it.Partial),(!k||E[0]&16384)&&X(e,"book-content--furigana-style-full",p[14]===it.Full),(!k||E[0]&16384)&&X(e,"book-content--furigana-style-toggle",p[14]===it.Toggle),E[0]&16&&y(e,"color",p[4]),E[0]&1024&&r!==(r=`${p[10]}px`)&&y(e,"font-size",r),E[0]&2048&&y(e,"line-height",p[11]),E[0]&65544&&y(e,"padding-top",!p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&65544&&y(e,"padding-bottom",!p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&65544&&y(e,"padding-left",p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&65544&&y(e,"padding-right",p[3]&&p[16]?`${p[16]}px`:void 0),E[0]&2&&y(e,"max-width",p[1]?`${p[1]}px`:void 0),E[0]&12&&y(e,"max-height",p[3]&&p[2]?`${p[2]}px`:void 0),E[0]&256&&y(e,"--font-family-serif",p[8]),E[0]&512&&y(e,"--font-family-sans-serif",p[9]),E[0]&64&&y(e,"--book-content-hint-furigana-font-color",p[6]),E[0]&128&&y(e,"--book-content-hint-furigana-shadow-color",p[7]),E[0]&2&&a!==(a=`${p[1]}px`)&&y(e,"--book-content-child-width",a),E[0]&4&&l!==(l=`${p[2]}px`)&&y(e,"--book-content-child-height",l),E[0]&16777226&&y(e,"--book-content-child-column-width",!p[3]&&p[24]===1?`${p[1]}px`:""),E[0]&16777216&&y(e,"--book-content-column-count",p[24]),E[0]&16777226&&f!==(f=`${p[3]?p[1]:(p[1]+Ot)/p[24]-Ot}px`)&&y(e,"--book-content-image-max-width",f),p[19]?s&&(ut(),Y(s,1,1,()=>{s=null}),ft()):s?(s.p(p,E),E[0]&524288&&q(s,1)):(s=So(p),s.c(),q(s,1),s.m(g.parentNode,g)),p[0]?C?(C.p(p,E),E[0]&1&&q(C,1)):(C=Po(p),C.c(),q(C,1),C.m(P.parentNode,P)):C&&(ut(),Y(C,1,1,()=>{C=null}),ft())},i(p){k||(q(i.$$.fragment,p),q(s),q(C),k=!0)},o(p){Y(i.$$.fragment,p),Y(s),Y(C),k=!1},d(p){p&&M(e),Te(i),t[44](null),t[45](null),p&&M(u),s&&s.d(p),p&&M(g),C&&C.d(p),p&&M(P),m=!1,Tt(v)}}}const vo="overflow-hidden",Ot=40;function pl(t,e,n){let i,o,r,a,l,f,u,g,P;G(t,Kt,d=>n(51,o=d)),G(t,Vt,d=>n(52,r=d)),G(t,$o,d=>n(53,a=d)),G(t,jn,d=>n(54,l=d)),G(t,Jo,d=>n(55,f=d)),G(t,Qo,d=>n(56,u=d)),G(t,ei,d=>n(57,g=d)),G(t,gr,d=>n(25,P=d));let{htmlContent:k}=e,{width:m}=e,{height:v}=e,{verticalMode:s}=e,{fontColor:C}=e,{backgroundColor:p}=e,{hintFuriganaFontColor:E}=e,{hintFuriganaShadowColor:N}=e,{fontFamilyGroupOne:R}=e,{fontFamilyGroupTwo:F}=e,{fontSize:z}=e,{lineHeight:K}=e,{hideSpoilerImage:D}=e,{hideFurigana:B}=e,{furiganaStyle:L}=e,{loadingState:T}=e,{bookmarkData:I}=e,{pageManager:w}=e,{bookmarkManager:V}=e,{exploredCharCount:b}=e,{bookCharCount:A}=e,{isBookmarkScreen:Q=!1}=e,{avoidPageBreak:re=!0}=e,{pageColumns:pe}=e,{firstDimensionMargin:Ve}=e,{autoBookmark:Pe=!1}=e,{customReadingPointRange:_e}=e,{showCustomReadingPoint:Ie}=e;const ze=wn();let de,oe,ie,Fe=[],U,Z,Ne,ve=!1,ye="",_=!0,O=0,He=!1,j,Be,ke,Ae=!1;const dt=new nt,Ue=new nt,be=new gn(-1),me=new nt,Je=new gn(0),Qe=new nt,ge=new nt,at=be.pipe(Ke(d=>{var x;return((x=Fe[d])==null?void 0:x.innerHTML)||""})),Ge=new nt;Hn(()=>{document.body.classList.remove(vo),Ge.next(),Ge.complete()}),Zt([dt,Ue]).pipe(mn(1),Lt(()=>ge.pipe(Gt(1))),st(Ge)).subscribe(()=>{if(!ie||!U)return;const d=ie.getScrollPosByCharCount(O);d<0||U.scrollTo(d,!1)}),me.pipe(st(Ge)).subscribe(d=>{var x;!ie||(n(34,Ie=!1),qt((x=_e==null?void 0:_e.endContainer)==null?void 0:x.parentElement,"remove",1),n(29,_e=void 0),n(32,b=ie.calcExploredCharCount(_e)),d&&(O=b,g&&hi(window)),I.then(Re))}),Pe&&me.pipe(xt(3e3),st(Ge)).subscribe(d=>{d&&ze("bookmark")}),at.pipe(si(),st(Ge)).subscribe(()=>{n(19,ve=!1)}),at.pipe(st(Ge)).subscribe(d=>{const x=(h,lt)=>{if(lt===0){h();return}requestAnimationFrame(()=>x(h,lt-1))};x(()=>{n(20,ye=d)},2)}),It(()=>rt(document.body,"wheel",{passive:!0})).pipe($t(()=>!u&&!o),Ba(50),st(Ge)).subscribe(d=>{if(!r){let x=(d.deltaX<0?-1:1)*(s?-1:1);d.deltaX||(x=d.deltaY<0?-1:1),U==null||U.flipPage(x)}});function pt(d){!ie||(n(32,b=ie.calcExploredCharCount(d)),O=b,je(d))}function je(d){!U||!ie||U.updateSectionDataByOffset(ie.getOffsetToRange(d,i))}function Ze(){if(_){_=!1;return}if(!de)return;n(40,ie=new dl(de,Fe,Je,()=>m,()=>v,()=>Ot,s,de,document)),n(32,b=0),O=0,n(33,A=ie.charCount);let d=!1;try{d=document.fonts.check(`${z}px ${R||"Noto Serif JP"}`)}catch(x){mt.error(`Error checking Font Load: ${x.message}`),d=!0}if(d)Xe();else if(!Ae){Ae=!0;const x=ii(R,f)?3e4:1e4,h=setTimeout(()=>{mt.error(`Error loading primary Font: ${R}`),Xe()},x);document.fonts.addEventListener("loadingdone",()=>{clearTimeout(h),Xe()})}}function Xe(){!ie||(ie.updateCurrentSection(be.getValue()),ze("contentChange",de))}function gt(d){d.updateParagraphPos(),n(32,b=d.calcExploredCharCount(_e)),ge.next(d),I.then(Re),Ne&&(Ne=!1,I.then(x=>{!x||!V||(n(32,b=x.exploredCharCount||0),V.scrollToBookmark(x))})),n(19,ve=!0)}function Re(d){const x=d==null?void 0:d.exploredCharCount;if(!ie||!x)return;const h=ie.checkBookmarkOnScreen(x);if(de&&h.isBookmarkScreen){const lt=Number(getComputedStyle(de)[s?"marginTop":"marginRight"].replace(/px$/,""));h.bookmarkPos?s?(n(21,j=lt?`${lt}px`:"0.5rem"),n(22,Be=`${h.bookmarkPos.left}px`),n(23,ke=void 0)):(n(21,j=`${h.bookmarkPos.top}px`),n(23,ke=void 0),n(22,Be=h.bookmarkPos.left>0?`calc(${h.bookmarkPos.left}px - ${l?"15":"20"}px)`:`calc(${Math.max(l?15:20,lt)}px)`)):kt(lt)}else kt(0);h.isBookmarkScreen&&d.exploredCharCount&&(h.node&&!He&&!h.isFirstNode?je(Yn(h.node)):h.isFirstNode&&je(void 0),n(32,b=He?b:d.exploredCharCount),O=b,He=!0),n(0,Q=h.isBookmarkScreen)}function kt(d){s?(n(21,j=d?`${d}px`:"0.5rem"),n(22,Be=a?`${m-a}px`:void 0),n(23,ke=a?void 0:"0.75rem")):(n(21,j=a?`${a}px`:"0.5rem"),n(22,Be=d?`calc(${d}px + 0.75rem)`:"0.75rem"),n(23,ke=void 0))}function S(d){if(!U||r||o||d.detail.direction!=="left"&&d.detail.direction!=="right")return;const x=d.detail.direction==="left",h=s?!x:x;U.flipPage(h?1:-1)}function ae(d){if(!(!U||r||o))switch(d.code){case"ArrowLeft":U[s?"nextPage":"prevPage"]();break;case"ArrowRight":U[s?"prevPage":"nextPage"]();break;case"ArrowUp":U.prevPage();break;case"ArrowDown":U.nextPage();break}}rn.pipe(st(Ge)).subscribe(d=>{const x=Fe.findIndex(h=>h.id===d||h.querySelector(`[id="${d}"]`));x>-1&&(be.next(x),U==null||U.scrollTo(0,!0))});function We(d){ne[d?"unshift":"push"](()=>{oe=d,n(18,oe)})}function Oe(d){ne[d?"unshift":"push"](()=>{de=d,n(17,de)})}return t.$$set=d=>{"htmlContent"in d&&n(35,k=d.htmlContent),"width"in d&&n(1,m=d.width),"height"in d&&n(2,v=d.height),"verticalMode"in d&&n(3,s=d.verticalMode),"fontColor"in d&&n(4,C=d.fontColor),"backgroundColor"in d&&n(5,p=d.backgroundColor),"hintFuriganaFontColor"in d&&n(6,E=d.hintFuriganaFontColor),"hintFuriganaShadowColor"in d&&n(7,N=d.hintFuriganaShadowColor),"fontFamilyGroupOne"in d&&n(8,R=d.fontFamilyGroupOne),"fontFamilyGroupTwo"in d&&n(9,F=d.fontFamilyGroupTwo),"fontSize"in d&&n(10,z=d.fontSize),"lineHeight"in d&&n(11,K=d.lineHeight),"hideSpoilerImage"in d&&n(12,D=d.hideSpoilerImage),"hideFurigana"in d&&n(13,B=d.hideFurigana),"furiganaStyle"in d&&n(14,L=d.furiganaStyle),"loadingState"in d&&n(36,T=d.loadingState),"bookmarkData"in d&&n(37,I=d.bookmarkData),"pageManager"in d&&n(30,w=d.pageManager),"bookmarkManager"in d&&n(31,V=d.bookmarkManager),"exploredCharCount"in d&&n(32,b=d.exploredCharCount),"bookCharCount"in d&&n(33,A=d.bookCharCount),"isBookmarkScreen"in d&&n(0,Q=d.isBookmarkScreen),"avoidPageBreak"in d&&n(15,re=d.avoidPageBreak),"pageColumns"in d&&n(38,pe=d.pageColumns),"firstDimensionMargin"in d&&n(16,Ve=d.firstDimensionMargin),"autoBookmark"in d&&n(39,Pe=d.autoBookmark),"customReadingPointRange"in d&&n(29,_e=d.customReadingPointRange),"showCustomReadingPoint"in d&&n(34,Ie=d.showCustomReadingPoint)},t.$$.update=()=>{if(t.$$.dirty[1]&64&&I.then(d=>{He=!1,Re(d)}),t.$$.dirty[0]&2&&m&&dt.next(m),t.$$.dirty[0]&4&&v&&Ue.next(v),t.$$.dirty[0]&10|t.$$.dirty[1]&128&&n(24,i=s?1:pe||Math.ceil(m/1e3)),t.$$.dirty[1]&16&&k&&(Ne=!0),t.$$.dirty[1]&16){const d=document.createElement("div");d.innerHTML=k,n(41,Fe=Array.from(d.children)),be.next(0)}if(t.$$.dirty[0]&393230|t.$$.dirty[1]&3072&&oe&&de&&Fe&&(n(42,U=new hl(oe,de,Fe,be,Je,m,v,Ot,s,me,Qe)),n(30,w=U)),t.$$.dirty[0]&6|t.$$.dirty[1]&544&&ie&&m&&v&&!T){const d=ie;requestAnimationFrame(()=>{gt(d)})}t.$$.dirty[1]&544&&ie&&!T&&Qe.next(be.getValue()),t.$$.dirty[1]&6656&&ie&&U&&(n(43,Z=new cl(ie,U,ge,be,d=>O=d)),n(31,V=Z)),t.$$.dirty[0]&536870912&&pt(_e)},document.body.classList.add(vo),[Q,m,v,s,C,p,E,N,R,F,z,K,D,B,L,re,Ve,de,oe,ve,ye,j,Be,ke,i,P,Ze,S,ae,_e,w,V,b,A,Ie,k,T,I,pe,Pe,ie,Fe,U,Z,We,Oe]}class kl extends Mt{constructor(e){super(),Et(this,e,pl,ml,Dt,{htmlContent:35,width:1,height:2,verticalMode:3,fontColor:4,backgroundColor:5,hintFuriganaFontColor:6,hintFuriganaShadowColor:7,fontFamilyGroupOne:8,fontFamilyGroupTwo:9,fontSize:10,lineHeight:11,hideSpoilerImage:12,hideFurigana:13,furiganaStyle:14,loadingState:36,bookmarkData:37,pageManager:30,bookmarkManager:31,exploredCharCount:32,bookCharCount:33,isBookmarkScreen:0,avoidPageBreak:15,pageColumns:38,firstDimensionMargin:16,autoBookmark:39,customReadingPointRange:29,showCustomReadingPoint:34},null,[-1,-1,-1])}}function bl(t){let e,n,i,o,r,a,l,f,u,g;function P(R){t[59](R)}function k(R){t[60](R)}function m(R){t[61](R)}function v(R){t[62](R)}function s(R){t[63](R)}function C(R){t[64](R)}function p(R){t[65](R)}function E(R){t[66](R)}let N={htmlContent:t[13],width:t[35]??0,height:t[36]??0,verticalMode:t[14],fontColor:t[15],backgroundColor:t[16],hintFuriganaFontColor:t[17],hintFuriganaShadowColor:t[18],fontFamilyGroupOne:t[19],fontFamilyGroupTwo:t[20],fontSize:t[21],lineHeight:t[22],hideSpoilerImage:t[23],hideFurigana:t[24],furiganaStyle:t[25],loadingState:t[37]??!0,avoidPageBreak:t[29],pageColumns:t[30],autoBookmark:t[31],firstDimensionMargin:t[27]};return t[0]!==void 0&&(N.exploredCharCount=t[0]),t[1]!==void 0&&(N.bookCharCount=t[1]),t[6]!==void 0&&(N.isBookmarkScreen=t[6]),t[2]!==void 0&&(N.bookmarkData=t[2]),t[4]!==void 0&&(N.bookmarkManager=t[4]),t[5]!==void 0&&(N.pageManager=t[5]),t[11]!==void 0&&(N.customReadingPointRange=t[11]),t[12]!==void 0&&(N.showCustomReadingPoint=t[12]),e=new kl({props:N}),ne.push(()=>ce(e,"exploredCharCount",P,t[0])),ne.push(()=>ce(e,"bookCharCount",k,t[1])),ne.push(()=>ce(e,"isBookmarkScreen",m,t[6])),ne.push(()=>ce(e,"bookmarkData",v,t[2])),ne.push(()=>ce(e,"bookmarkManager",s,t[4])),ne.push(()=>ce(e,"pageManager",C,t[5])),ne.push(()=>ce(e,"customReadingPointRange",p,t[11])),ne.push(()=>ce(e,"showCustomReadingPoint",E,t[12])),e.$on("contentChange",t[67]),e.$on("bookmark",t[68]),{c(){Me(e.$$.fragment)},l(R){Ee(e.$$.fragment,R)},m(R,F){De(e,R,F),g=!0},p(R,F){const z={};F[0]&8192&&(z.htmlContent=R[13]),F[1]&16&&(z.width=R[35]??0),F[1]&32&&(z.height=R[36]??0),F[0]&16384&&(z.verticalMode=R[14]),F[0]&32768&&(z.fontColor=R[15]),F[0]&65536&&(z.backgroundColor=R[16]),F[0]&131072&&(z.hintFuriganaFontColor=R[17]),F[0]&262144&&(z.hintFuriganaShadowColor=R[18]),F[0]&524288&&(z.fontFamilyGroupOne=R[19]),F[0]&1048576&&(z.fontFamilyGroupTwo=R[20]),F[0]&2097152&&(z.fontSize=R[21]),F[0]&4194304&&(z.lineHeight=R[22]),F[0]&8388608&&(z.hideSpoilerImage=R[23]),F[0]&16777216&&(z.hideFurigana=R[24]),F[0]&33554432&&(z.furiganaStyle=R[25]),F[1]&64&&(z.loadingState=R[37]??!0),F[0]&536870912&&(z.avoidPageBreak=R[29]),F[0]&1073741824&&(z.pageColumns=R[30]),F[1]&1&&(z.autoBookmark=R[31]),F[0]&134217728&&(z.firstDimensionMargin=R[27]),!n&&F[0]&1&&(n=!0,z.exploredCharCount=R[0],he(()=>n=!1)),!i&&F[0]&2&&(i=!0,z.bookCharCount=R[1],he(()=>i=!1)),!o&&F[0]&64&&(o=!0,z.isBookmarkScreen=R[6],he(()=>o=!1)),!r&&F[0]&4&&(r=!0,z.bookmarkData=R[2],he(()=>r=!1)),!a&&F[0]&16&&(a=!0,z.bookmarkManager=R[4],he(()=>a=!1)),!l&&F[0]&32&&(l=!0,z.pageManager=R[5],he(()=>l=!1)),!f&&F[0]&2048&&(f=!0,z.customReadingPointRange=R[11],he(()=>f=!1)),!u&&F[0]&4096&&(u=!0,z.showCustomReadingPoint=R[12],he(()=>u=!1)),e.$set(z)},i(R){g||(q(e.$$.fragment,R),g=!0)},o(R){Y(e.$$.fragment,R),g=!1},d(R){Te(e,R)}}}function Cl(t){let e,n,i,o,r,a,l,f,u,g,P,k;function m(D){t[47](D)}function v(D){t[48](D)}function s(D){t[49](D)}function C(D){t[50](D)}function p(D){t[51](D)}function E(D){t[52](D)}function N(D){t[53](D)}function R(D){t[54](D)}function F(D){t[55](D)}function z(D){t[56](D)}let K={htmlContent:t[13],width:t[35]??0,height:t[36]??0,verticalMode:t[14],fontColor:t[15],backgroundColor:t[16],hintFuriganaFontColor:t[17],hintFuriganaShadowColor:t[18],fontFamilyGroupOne:t[19],fontFamilyGroupTwo:t[20],fontSize:t[21],lineHeight:t[22],hideSpoilerImage:t[23],hideFurigana:t[24],furiganaStyle:t[25],secondDimensionMaxValue:t[26],firstDimensionMargin:t[27],autoPositionOnResize:t[28],autoBookmark:t[31],multiplier:t[33],loadingState:t[37]??!0};return t[0]!==void 0&&(K.exploredCharCount=t[0]),t[1]!==void 0&&(K.bookCharCount=t[1]),t[2]!==void 0&&(K.bookmarkData=t[2]),t[3]!==void 0&&(K.autoScroller=t[3]),t[4]!==void 0&&(K.bookmarkManager=t[4]),t[5]!==void 0&&(K.pageManager=t[5]),t[7]!==void 0&&(K.customReadingPoint=t[7]),t[8]!==void 0&&(K.customReadingPointTop=t[8]),t[9]!==void 0&&(K.customReadingPointLeft=t[9]),t[10]!==void 0&&(K.customReadingPointScrollOffset=t[10]),e=new xa({props:K}),ne.push(()=>ce(e,"exploredCharCount",m,t[0])),ne.push(()=>ce(e,"bookCharCount",v,t[1])),ne.push(()=>ce(e,"bookmarkData",s,t[2])),ne.push(()=>ce(e,"autoScroller",C,t[3])),ne.push(()=>ce(e,"bookmarkManager",p,t[4])),ne.push(()=>ce(e,"pageManager",E,t[5])),ne.push(()=>ce(e,"customReadingPoint",N,t[7])),ne.push(()=>ce(e,"customReadingPointTop",R,t[8])),ne.push(()=>ce(e,"customReadingPointLeft",F,t[9])),ne.push(()=>ce(e,"customReadingPointScrollOffset",z,t[10])),e.$on("contentChange",t[57]),e.$on("bookmark",t[58]),{c(){Me(e.$$.fragment)},l(D){Ee(e.$$.fragment,D)},m(D,B){De(e,D,B),k=!0},p(D,B){const L={};B[0]&8192&&(L.htmlContent=D[13]),B[1]&16&&(L.width=D[35]??0),B[1]&32&&(L.height=D[36]??0),B[0]&16384&&(L.verticalMode=D[14]),B[0]&32768&&(L.fontColor=D[15]),B[0]&65536&&(L.backgroundColor=D[16]),B[0]&131072&&(L.hintFuriganaFontColor=D[17]),B[0]&262144&&(L.hintFuriganaShadowColor=D[18]),B[0]&524288&&(L.fontFamilyGroupOne=D[19]),B[0]&1048576&&(L.fontFamilyGroupTwo=D[20]),B[0]&2097152&&(L.fontSize=D[21]),B[0]&4194304&&(L.lineHeight=D[22]),B[0]&8388608&&(L.hideSpoilerImage=D[23]),B[0]&16777216&&(L.hideFurigana=D[24]),B[0]&33554432&&(L.furiganaStyle=D[25]),B[0]&67108864&&(L.secondDimensionMaxValue=D[26]),B[0]&134217728&&(L.firstDimensionMargin=D[27]),B[0]&268435456&&(L.autoPositionOnResize=D[28]),B[1]&1&&(L.autoBookmark=D[31]),B[1]&4&&(L.multiplier=D[33]),B[1]&64&&(L.loadingState=D[37]??!0),!n&&B[0]&1&&(n=!0,L.exploredCharCount=D[0],he(()=>n=!1)),!i&&B[0]&2&&(i=!0,L.bookCharCount=D[1],he(()=>i=!1)),!o&&B[0]&4&&(o=!0,L.bookmarkData=D[2],he(()=>o=!1)),!r&&B[0]&8&&(r=!0,L.autoScroller=D[3],he(()=>r=!1)),!a&&B[0]&16&&(a=!0,L.bookmarkManager=D[4],he(()=>a=!1)),!l&&B[0]&32&&(l=!0,L.pageManager=D[5],he(()=>l=!1)),!f&&B[0]&128&&(f=!0,L.customReadingPoint=D[7],he(()=>f=!1)),!u&&B[0]&256&&(u=!0,L.customReadingPointTop=D[8],he(()=>u=!1)),!g&&B[0]&512&&(g=!0,L.customReadingPointLeft=D[9],he(()=>g=!1)),!P&&B[0]&1024&&(P=!0,L.customReadingPointScrollOffset=D[10],he(()=>P=!1)),e.$set(L)},i(D){k||(q(e.$$.fragment,D),k=!0)},o(D){Y(e.$$.fragment,D),k=!1},d(D){Te(e,D)}}}function _l(t){let e,n,i,o,r=(t[38]??"")+"",a,l;const f=[Cl,bl],u=[];function g(P,k){return P[32]===Yt.Continuous?0:1}return n=g(t),i=u[n]=f[n](t),{c(){e=$("div"),i.c(),o=ue(),a=we(r),this.h()},l(P){e=ee(P,"DIV",{class:!0});var k=te(e);i.l(k),k.forEach(M),o=fe(P),a=Se(P,r),this.h()},h(){J(e,"class",$a+" py-8")},m(P,k){W(P,e,k),u[n].m(e,null),t[69](e),W(P,o,k),W(P,a,k),l=!0},p(P,k){let m=n;n=g(P),n===m?u[n].p(P,k):(ut(),Y(u[m],1,1,()=>{u[m]=null}),ft(),i=u[n],i?i.p(P,k):(i=u[n]=f[n](P),i.c()),q(i,1),i.m(e,null)),(!l||k[1]&128)&&r!==(r=(P[38]??"")+"")&&Ye(a,r)},i(P){l||(q(i),l=!0)},o(P){Y(i),l=!1},d(P){P&&M(e),u[n].d(),t[69](null),P&&M(o),P&&M(a)}}}function fn(t){return Number(t.replace(/px$/,""))}function wl(t,e,n){let i,o,r,a,l,f,{htmlContent:u}=e,{width:g}=e,{height:P}=e,{verticalMode:k}=e,{fontColor:m}=e,{backgroundColor:v}=e,{hintFuriganaFontColor:s}=e,{hintFuriganaShadowColor:C}=e,{fontFamilyGroupOne:p}=e,{fontFamilyGroupTwo:E}=e,{fontSize:N}=e,{lineHeight:R}=e,{hideSpoilerImage:F}=e,{hideFurigana:z}=e,{furiganaStyle:K}=e,{secondDimensionMaxValue:D}=e,{firstDimensionMargin:B}=e,{autoPositionOnResize:L}=e,{avoidPageBreak:T}=e,{pageColumns:I}=e,{autoBookmark:w}=e,{viewMode:V}=e,{exploredCharCount:b}=e,{bookCharCount:A}=e,{multiplier:Q}=e,{bookmarkData:re}=e,{autoScroller:pe}=e,{bookmarkManager:Ve}=e,{pageManager:Pe}=e,{isBookmarkScreen:_e}=e,{customReadingPoint:Ie}=e,{customReadingPointTop:ze}=e,{customReadingPointLeft:de}=e,{customReadingPointScrollOffset:oe}=e,{customReadingPointRange:ie}=e,{showCustomReadingPoint:Fe}=e;const U=new nt,Z=new nt,Ne=mr(null);G(t,Ne,h=>n(34,o=h));const ve=Zt([Ne.pipe($t(h=>!!h)),Zt([U,Z]).pipe(On(0))]).pipe(xt(0,Pn),Ke(([h])=>getComputedStyle(h)),Ln({refCount:!0,bufferSize:1})),ye=new pr(1),_=ve.pipe(Ke(h=>Be(g-fn(h.paddingLeft)-fn(h.paddingRight))));G(t,_,h=>n(35,r=h));const O=ve.pipe(Ke(h=>ke(P-fn(h.paddingTop)-fn(h.paddingBottom)-i)));G(t,O,h=>n(36,a=h));const He=It(()=>qn(document)).pipe(hn(h=>{const lt=nl(h,K);return ye.pipe(hn(an=>lt(an)))}),yt());G(t,He,h=>n(38,f=h));const j=ye.pipe(hn(h=>el(h)),Vn());G(t,j,h=>n(37,l=h));function Be(h){return Yt.Paginated===V&&!k&&D?Math.min(D,h):h}function ke(h){return Yt.Paginated===V&&k&&D?Math.min(D,h):h}function Ae(h){b=h,n(0,b)}function dt(h){A=h,n(1,A)}function Ue(h){re=h,n(2,re)}function be(h){pe=h,n(3,pe)}function me(h){Ve=h,n(4,Ve)}function Je(h){Pe=h,n(5,Pe)}function Qe(h){Ie=h,n(7,Ie)}function ge(h){ze=h,n(8,ze)}function at(h){de=h,n(9,de)}function Ge(h){oe=h,n(10,oe)}const pt=h=>ye.next(h.detail);function je(h){io.call(this,t,h)}function Ze(h){b=h,n(0,b)}function Xe(h){A=h,n(1,A)}function gt(h){_e=h,n(6,_e)}function Re(h){re=h,n(2,re)}function kt(h){Ve=h,n(4,Ve)}function S(h){Pe=h,n(5,Pe)}function ae(h){ie=h,n(11,ie)}function We(h){Fe=h,n(12,Fe)}const Oe=h=>ye.next(h.detail);function d(h){io.call(this,t,h)}function x(h){ne[h?"unshift":"push"](()=>{o=h,Ne.set(o)})}return t.$$set=h=>{"htmlContent"in h&&n(13,u=h.htmlContent),"width"in h&&n(45,g=h.width),"height"in h&&n(46,P=h.height),"verticalMode"in h&&n(14,k=h.verticalMode),"fontColor"in h&&n(15,m=h.fontColor),"backgroundColor"in h&&n(16,v=h.backgroundColor),"hintFuriganaFontColor"in h&&n(17,s=h.hintFuriganaFontColor),"hintFuriganaShadowColor"in h&&n(18,C=h.hintFuriganaShadowColor),"fontFamilyGroupOne"in h&&n(19,p=h.fontFamilyGroupOne),"fontFamilyGroupTwo"in h&&n(20,E=h.fontFamilyGroupTwo),"fontSize"in h&&n(21,N=h.fontSize),"lineHeight"in h&&n(22,R=h.lineHeight),"hideSpoilerImage"in h&&n(23,F=h.hideSpoilerImage),"hideFurigana"in h&&n(24,z=h.hideFurigana),"furiganaStyle"in h&&n(25,K=h.furiganaStyle),"secondDimensionMaxValue"in h&&n(26,D=h.secondDimensionMaxValue),"firstDimensionMargin"in h&&n(27,B=h.firstDimensionMargin),"autoPositionOnResize"in h&&n(28,L=h.autoPositionOnResize),"avoidPageBreak"in h&&n(29,T=h.avoidPageBreak),"pageColumns"in h&&n(30,I=h.pageColumns),"autoBookmark"in h&&n(31,w=h.autoBookmark),"viewMode"in h&&n(32,V=h.viewMode),"exploredCharCount"in h&&n(0,b=h.exploredCharCount),"bookCharCount"in h&&n(1,A=h.bookCharCount),"multiplier"in h&&n(33,Q=h.multiplier),"bookmarkData"in h&&n(2,re=h.bookmarkData),"autoScroller"in h&&n(3,pe=h.autoScroller),"bookmarkManager"in h&&n(4,Ve=h.bookmarkManager),"pageManager"in h&&n(5,Pe=h.pageManager),"isBookmarkScreen"in h&&n(6,_e=h.isBookmarkScreen),"customReadingPoint"in h&&n(7,Ie=h.customReadingPoint),"customReadingPointTop"in h&&n(8,ze=h.customReadingPointTop),"customReadingPointLeft"in h&&n(9,de=h.customReadingPointLeft),"customReadingPointScrollOffset"in h&&n(10,oe=h.customReadingPointScrollOffset),"customReadingPointRange"in h&&n(11,ie=h.customReadingPointRange),"showCustomReadingPoint"in h&&n(12,Fe=h.showCustomReadingPoint)},t.$$.update=()=>{t.$$.dirty[0]&134234112|t.$$.dirty[1]&2&&(i=B&&Yt.Paginated===V&&!k?B*2:0),t.$$.dirty[1]&16384&&U.next(g),t.$$.dirty[1]&32768&&Z.next(P)},[b,A,re,pe,Ve,Pe,_e,Ie,ze,de,oe,ie,Fe,u,k,m,v,s,C,p,E,N,R,F,z,K,D,B,L,T,I,w,V,Q,o,r,a,l,f,Ne,ye,_,O,He,j,g,P,Ae,dt,Ue,be,me,Je,Qe,ge,at,Ge,pt,je,Ze,Xe,gt,Re,kt,S,ae,We,Oe,d,x]}class Sl extends Mt{constructor(e){super(),Et(this,e,wl,_l,Dt,{htmlContent:13,width:45,height:46,verticalMode:14,fontColor:15,backgroundColor:16,hintFuriganaFontColor:17,hintFuriganaShadowColor:18,fontFamilyGroupOne:19,fontFamilyGroupTwo:20,fontSize:21,lineHeight:22,hideSpoilerImage:23,hideFurigana:24,furiganaStyle:25,secondDimensionMaxValue:26,firstDimensionMargin:27,autoPositionOnResize:28,avoidPageBreak:29,pageColumns:30,autoBookmark:31,viewMode:32,exploredCharCount:0,bookCharCount:1,multiplier:33,bookmarkData:2,autoScroller:3,bookmarkManager:4,pageManager:5,isBookmarkScreen:6,customReadingPoint:7,customReadingPointTop:8,customReadingPointLeft:9,customReadingPointScrollOffset:10,customReadingPointRange:11,showCustomReadingPoint:12},null,[-1,-1,-1])}}function Pl(t,e){const n=document.createTextNode(e);if(t.firstChild){t.replaceChild(n,t.firstChild);return}t.appendChild(n)}function vl(t,e,n){let{styleSheet:i}=e,o;return Xo(()=>{n(1,o=document.createElement("style")),document.head.appendChild(o)}),Hn(()=>{o&&document.head.removeChild(o)}),t.$$set=r=>{"styleSheet"in r&&n(0,i=r.styleSheet)},t.$$.update=()=>{t.$$.dirty&3&&o&&Pl(o,i)},[i,o]}class yl extends Mt{constructor(e){super(),Et(this,e,vl,null,Dt,{styleSheet:0})}}function yo(t){let e,n,i,o,r;return n=new ct({props:{icon:Zr}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(a){e=ee(a,"DIV",{role:!0,class:!0});var l=te(e);Ee(n.$$.fragment,l),l.forEach(M),this.h()},h(){J(e,"role","button"),J(e,"class",ti)},m(a,l){W(a,e,l),De(n,e,null),i=!0,o||(r=[Ce(e,"click",t[7]),Ce(e,"keyup",Rt)],o=!0)},p:Nt,i(a){i||(q(n.$$.fragment,a),i=!0)},o(a){Y(n.$$.fragment,a),i=!1},d(a){a&&M(e),Te(n),o=!1,Tt(r)}}}function Ro(t){let e,n,i;return{c(){e=$("div"),n=we(t[1]),i=we("x"),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);n=Se(r,t[1]),i=Se(r,"x"),r.forEach(M),this.h()},h(){J(e,"class","flex items-center px-4 text-xl xl:px-3 xl:text-lg")},m(o,r){W(o,e,r),le(e,n),le(e,i)},p(o,r){r&2&&Ye(n,o[1])},d(o){o&&M(e)}}}function Rl(t){let e,n,i,o,r,a,l,f,u,g,P,k,m=t[0]&&yo(t);r=new ct({props:{icon:t[2]?Jt:ho}});let v=!t[4]&&Ro(t);return u=new aa({props:{disableRouteNavigation:!0,items:t[3]?[qe.SETTINGS,qe.DOMAIN_HINT,qe.MANAGE]:[qe.SETTINGS,qe.MANAGE]}}),u.$on("action",t[9]),{c(){e=$("div"),n=$("div"),m&&m.c(),i=ue(),o=$("div"),Me(r.$$.fragment),a=ue(),v&&v.c(),l=ue(),f=$("div"),Me(u.$$.fragment),this.h()},l(s){e=ee(s,"DIV",{class:!0});var C=te(e);n=ee(C,"DIV",{class:!0});var p=te(n);m&&m.l(p),i=fe(p),o=ee(p,"DIV",{role:!0,class:!0});var E=te(o);Ee(r.$$.fragment,E),E.forEach(M),a=fe(p),v&&v.l(p),p.forEach(M),l=fe(C),f=ee(C,"DIV",{class:!0});var N=te(f);Ee(u.$$.fragment,N),N.forEach(M),C.forEach(M),this.h()},h(){J(o,"role","button"),J(o,"class",ti),J(n,"class","flex transform-gpu "+kr),J(f,"class","flex transform-gpu "+br),J(e,"class","flex justify-between bg-gray-700 px-4 md:px-8 "+Cr)},m(s,C){W(s,e,C),le(e,n),m&&m.m(n,null),le(n,i),le(n,o),De(r,o,null),le(n,a),v&&v.m(n,null),le(e,l),le(e,f),De(u,f,null),g=!0,P||(k=[Ce(o,"click",t[8]),Ce(o,"keyup",Rt)],P=!0)},p(s,[C]){s[0]?m?(m.p(s,C),C&1&&q(m,1)):(m=yo(s),m.c(),q(m,1),m.m(n,i)):m&&(ut(),Y(m,1,1,()=>{m=null}),ft());const p={};C&4&&(p.icon=s[2]?Jt:ho),r.$set(p),s[4]?v&&(v.d(1),v=null):v?v.p(s,C):(v=Ro(s),v.c(),v.m(n,null));const E={};C&8&&(E.items=s[3]?[qe.SETTINGS,qe.DOMAIN_HINT,qe.MANAGE]:[qe.SETTINGS,qe.MANAGE]),u.$set(E)},i(s){g||(q(m),q(r.$$.fragment,s),q(u.$$.fragment,s),g=!0)},o(s){Y(m),Y(r.$$.fragment,s),Y(u.$$.fragment,s),g=!1},d(s){s&&M(e),m&&m.d(),Te(r),v&&v.d(),Te(u),P=!1,Tt(k)}}}function Ml(t,e,n){let i,o;G(t,jn,m=>n(4,o=m));let{hasChapterData:r}=e,{autoScrollMultiplier:a}=e,{hasCustomReadingPoint:l}=e,{isBookmarkScreen:f}=e;const u=wn(),g=()=>u("tocClick"),P=()=>u("bookmarkClick"),k=({detail:m})=>{m===qe.SETTINGS.label?u("settingsClick"):m===qe.DOMAIN_HINT.label?u("domainHintClick"):m===qe.MANAGE.label&&u("bookManagerClick")};return t.$$set=m=>{"hasChapterData"in m&&n(0,r=m.hasChapterData),"autoScrollMultiplier"in m&&n(1,a=m.autoScrollMultiplier),"hasCustomReadingPoint"in m&&n(6,l=m.hasCustomReadingPoint),"isBookmarkScreen"in m&&n(2,f=m.isBookmarkScreen)},n(3,i=_r(window)),[r,a,f,i,o,u,l,g,P,k]}class El extends Mt{constructor(e){super(),Et(this,e,Ml,Rl,Dt,{hasChapterData:0,autoScrollMultiplier:1,hasCustomReadingPoint:6,isBookmarkScreen:2})}}function Mo(t,e,n){const i=t.slice();return i[16]=e[n],i}function Eo(t,e){let n,i,o=e[16].label+"",r,a,l,f,u=e[16].startCharacter+"",g,P,k,m;function v(){return e[13](e[16])}return{key:t,first:null,c(){n=$("div"),i=$("div"),r=we(o),l=ue(),f=$("div"),g=we(u),P=ue(),this.h()},l(s){n=ee(s,"DIV",{class:!0});var C=te(n);i=ee(C,"DIV",{id:!0,class:!0});var p=te(i);r=Se(p,o),p.forEach(M),l=fe(C),f=ee(C,"DIV",{});var E=te(f);g=Se(E,u),E.forEach(M),P=fe(C),C.forEach(M),this.h()},h(){J(i,"id",a=`for${e[16].reference}`),J(i,"class","mr-4 cursor-pointer"),X(i,"opacity-30",e[16].progress===100&&e[16]!==e[2]),X(i,"hover:opacity-100",e[16].progress===100&&e[16]!==e[2]),X(i,"hover:opacity-60",e[16].progress<100||e[16]===e[2]),X(f,"opacity-30",e[16].progress===100&&e[16]!==e[2]),J(n,"class","my-6 flex justify-between"),this.first=n},m(s,C){W(s,n,C),le(n,i),le(i,r),le(n,l),le(n,f),le(f,g),le(n,P),k||(m=[Ce(i,"click",v),Ce(i,"keydown",Rt)],k=!0)},p(s,C){e=s,C&2&&o!==(o=e[16].label+"")&&Ye(r,o),C&2&&a!==(a=`for${e[16].reference}`)&&J(i,"id",a),C&6&&X(i,"opacity-30",e[16].progress===100&&e[16]!==e[2]),C&6&&X(i,"hover:opacity-100",e[16].progress===100&&e[16]!==e[2]),C&6&&X(i,"hover:opacity-60",e[16].progress<100||e[16]===e[2]),C&2&&u!==(u=e[16].startCharacter+"")&&Ye(g,u),C&6&&X(f,"opacity-30",e[16].progress===100&&e[16]!==e[2])},d(s){s&&M(n),k=!1,Tt(m)}}}function Dl(t){let e,n,i,o,r,a,l,f,u,g,P,k,m=[],v=new Map,s,C,p,E,N,R,F,z,K,D;g=new ct({props:{icon:xr}});let B=t[1];const L=T=>T[16].reference;for(let T=0;T(o[0]+=t[a]*r,o[1]+=r,o),[0,0]);return n/i}function Do(t){!t||(t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView())}function Fl(t,e,n){let i,o,{sectionData:r=[]}=e,{exploredCharCount:a=0}=e,{verticalMode:l}=e,f=[],u,g=-1,P="0/0",k="0.00";Xo(()=>{tt.dialogs$.next([{component:"
"}]),u&&Do(document.getElementById(`for${u.reference}`))});function m(N,R){if(N){const F=f[g+R];v(F.reference,!1)}}function v(N,R=!1){rn.next(N),R&&s()}function s(){Vt.next(!1),tt.dialogs$.next([])}const C=N=>v(N.reference,!0),p=()=>m(i,l?1:-1),E=()=>m(o,l?-1:1);return t.$$set=N=>{"sectionData"in N&&n(10,r=N.sectionData),"exploredCharCount"in N&&n(11,a=N.exploredCharCount),"verticalMode"in N&&n(0,l=N.verticalMode)},t.$$.update=()=>{if(t.$$.dirty&5120&&r){const[N,R,F]=fi(r),z=r.filter(K=>K.reference===F||K.parentChapter===F);n(4,k=Tl(z.map(K=>K.progress),z.map(K=>K.charactersWeight)).toFixed(2)),n(1,f=N),n(12,g=R),n(2,u=N[g])}if(t.$$.dirty&4099&&n(6,i=l?gFo(t,e)??Fo(t,n)}function Fo(t,e){const n=t[e];return typeof n=="function"?n.bind(t):n}const dn=new Il(document);function Al(t,e){return Ol(t).pipe(Ke(n=>{const i=e.createElement("div");return i.innerHTML=n,Ll(i),Vl(i),zl(i,e),Nl(i),i.innerHTML}))}function Ol(t){return new St(e=>{const{blobs:n}=t;let{elementHtml:i}=t;const o=[];return Object.entries(n).forEach(([r,a])=>{const l=URL.createObjectURL(a);o.push(l),i=i.replaceAll(wr(r),l).replaceAll(`ttu:${r}`,l)}),e.next(i),()=>{o.forEach(r=>URL.revokeObjectURL(r))}})}function Ll(t){Array.from(t.getElementsByTagName("img")).map(e=>({parentEl:e.parentElement,isGaiji:ni(e)})).forEach(({parentEl:e,isGaiji:n})=>{e==null||e.classList.add("ttu-img-container"),n||e==null||e.classList.add("ttu-illustration-container")})}function Vl(t){Array.from(t.getElementsByTagName("svg")).forEach(e=>{e.removeAttribute("width"),e.removeAttribute("height")})}function zl(t,e){const n=()=>{let o=[...t.children];const r=o.findIndex(a=>a.getElementsByTagName("a").length>1)+1;return r>0&&r{const a=e.createElement("span");a.toggleAttribute("data-ttu-spoiler-img"),(o.parentElement||r).insertBefore(a,o),a.appendChild(o)};n().forEach(o=>{Array.from(o.getElementsByTagName("img")).filter(r=>!ni(r)).forEach(r=>i(r,o)),Array.from(o.getElementsByTagName("svg")).filter(r=>r.getElementsByTagName("image").length).forEach(r=>i(r,o))})}function Nl(t){t.querySelectorAll(".placeholder-br").forEach(e=>{e.parentElement.removeChild(e)})}var Hl=ki;function ki(t,e,n){t instanceof RegExp&&(t=Bo(t,n)),e instanceof RegExp&&(e=Bo(e,n));const i=bi(t,e,n);return i&&{start:i[0],end:i[1],pre:n.slice(0,i[0]),body:n.slice(i[0]+t.length,i[1]),post:n.slice(i[1]+e.length)}}function Bo(t,e){const n=e.match(t);return n?n[0]:null}ki.range=bi;function bi(t,e,n){let i,o,r,a,l,f=n.indexOf(t),u=n.indexOf(e,f+1),g=f;if(f>=0&&u>0){if(t===e)return[f,u];for(i=[],r=n.length;g>=0&&!l;)g===f?(i.push(g),f=n.indexOf(t,g+1)):i.length===1?l=[i.pop(),u]:(o=i.pop(),o=0?f:u;i.length&&(l=[r,a])}return l}function Gl(t,e={}){const i=Object.assign({},{preserveStatic:!0,removeComments:!1},e),o=[];function r(w){throw new Error(`CSS parse error: ${w}`)}function a(w){const V=w.exec(t);if(V)return t=t.slice(V[0].length),V}function l(){return a(/^{\s*/)}function f(){return a(/^}/)}function u(){a(/^\s*/)}function g(){if(u(),t[0]!=="/"||t[1]!=="*")return;let w=2;for(;t[w]&&(t[w]!=="*"||t[w+1]!=="/");)w++;if(!t[w])return r("end of comment is missing");const V=t.slice(2,w);return t=t.slice(w+2),{type:"comment",comment:V}}function P(){const w=[];let V;for(;V=g();)w.push(V);return i.removeComments?[]:w}function k(){for(u();t[0]==="}";)r("extra closing bracket");const w=a(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/);if(w)return w[0].trim().replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(V){return V.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(V){return V.replace(/\u200C/g,",")})}function m(){if(t[0]==="@")return L();a(/^([;\s]*)+/);const w=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;let V=a(/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!V)return;if(V=V[0].trim(),!a(/^:\s*/))return r("property missing ':'");const b=a(/^((?:\/\*.*?\*\/|'(?:\\'|.)*?'|"(?:\\"|.)*?"|\((\s*'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^)]*?)\s*\)|[^};])+)/),A={type:"declaration",property:V.replace(w,""),value:b?b[0].replace(w,"").trim():""};return a(/^[;\s]*/),A}function v(){if(!l())return r("missing '{'");let w,V=P();for(;w=m();)V.push(w),V=V.concat(P());return f()?V:r("missing '}'")}function s(){u();const w=[];let V;for(;V=a(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)w.push(V[1]),a(/^,\s*/);if(w.length)return{type:"keyframe",values:w,declarations:v()}}function C(){let w=a(/^@([-\w]+)?keyframes\s*/);if(!w)return;const V=w[1];if(w=a(/^([-\w]+)\s*/),!w)return r("@keyframes missing name");const b=w[1];if(!l())return r("@keyframes missing '{'");let A,Q=P();for(;A=s();)Q.push(A),Q=Q.concat(P());return f()?{type:"keyframes",name:b,vendor:V,keyframes:Q}:r("@keyframes missing '}'")}function p(){if(a(/^@page */))return{type:"page",selectors:k()||[],declarations:v()}}function E(){const w=a(/@(top|bottom|left|right)-(left|center|right|top|middle|bottom)-?(corner)?\s*/);if(w)return{type:"page-margin-box",name:`${w[1]}-${w[2]}`+(w[3]?`-${w[3]}`:""),declarations:v()}}function N(){if(a(/^@font-face\s*/))return{type:"font-face",declarations:v()}}function R(){const w=a(/^@supports *([^{]+)/);if(w)return{type:"supports",supports:w[1].trim(),rules:I()}}function F(){if(a(/^@host\s*/))return{type:"host",rules:I()}}function z(){const w=a(/^@media([^{]+)*/);if(w)return{type:"media",media:(w[1]||"").trim(),rules:I()}}function K(){const w=a(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(w)return{type:"custom-media",name:w[1].trim(),media:w[2].trim()}}function D(){const w=a(/^@([-\w]+)?document *([^{]+)/);if(w)return{type:"document",document:w[2].trim(),vendor:w[1]?w[1].trim():null,rules:I()}}function B(){const w=a(/^@(import|charset|namespace)\s*([^;]+);/);if(w)return{type:w[1],name:w[2].trim()}}function L(){if(u(),t[0]==="@"){const w=B()||N()||z()||C()||R()||D()||K()||F()||p()||E();if(w&&!i.preserveStatic){let V=!1;return w.declarations?V=w.declarations.some(b=>/var\(/.test(b.value)):V=(w.keyframes||w.rules||[]).some(A=>(A.declarations||[]).some(Q=>/var\(/.test(Q.value))),V?w:{}}return w}}function T(){if(!i.preserveStatic){const b=Hl("{","}",t);if(b){const A=/:(?:root|host)(?![.:#(])/.test(b.pre)&&/--\S*\s*:/.test(b.body),Q=/var\(/.test(b.body);if(!A&&!Q)return t=t.slice(b.end+1),{}}}const w=k()||[],V=i.preserveStatic?v():v().filter(b=>{const A=w.some(re=>/:(?:root|host)(?![.:#(])/.test(re))&&/^--\S/.test(b.property),Q=/var\(/.test(b.value);return A||Q});return w.length||r("selector missing"),{type:"rule",selectors:w,declarations:V}}function I(w){if(!w&&!l())return r("missing '{'");let V,b=P();for(;t.length&&(w||t[0]!=="}")&&(V=L()||T());)V.type&&b.push(V),b=b.concat(P());return!w&&!f()?r("missing '}'"):b}return{type:"stylesheet",stylesheet:{rules:I(!0),errors:o}}}function Wl(t,e="",n){const i={charset(r){return"@charset "+r.name+";"},comment(r){return r.comment.indexOf("__CSSVARSPONYFILL")===0?"/*"+r.comment+"*/":""},"custom-media"(r){return"@custom-media "+r.name+" "+r.media+";"},declaration(r){return r.property+":"+r.value+";"},document(r){return"@"+(r.vendor||"")+"document "+r.document+"{"+o(r.rules)+"}"},"font-face"(r){return"@font-face{"+o(r.declarations)+"}"},host(r){return"@host{"+o(r.rules)+"}"},import(r){return"@import "+r.name+";"},keyframe(r){return r.values.join(",")+"{"+o(r.declarations)+"}"},keyframes(r){return"@"+(r.vendor||"")+"keyframes "+r.name+"{"+o(r.keyframes)+"}"},media(r){return"@media "+r.media+"{"+o(r.rules)+"}"},namespace(r){return"@namespace "+r.name+";"},page(r){return"@page "+(r.selectors.length?r.selectors.join(", "):"")+"{"+o(r.declarations)+"}"},"page-margin-box"(r){return"@"+r.name+"{"+o(r.declarations)+"}"},rule(r){const a=r.declarations;if(a.length)return r.selectors.join(",")+"{"+o(a)+"}"},supports(r){return"@supports "+r.supports+"{"+o(r.rules)+"}"}};function o(r){let a="";for(let l=0;lo.type==="rule").filter(o=>!o.selectors.some(r=>jl.test(r)||Xl.test(r)));return i.forEach(o=>{const r={};o.declarations=o.declarations.filter(l=>!/line-height$/.test(l.property)&&!/text-indent$/.test(l.property));const a=new Jl(o.declarations,r);o.declarations.forEach(l=>{In(r,Yl(l)),In(r,Ul(l)),In(r,a.convert(l))}),Object.entries(r).forEach(([l,f])=>{o.declarations.push({type:"declaration",property:l,value:f})}),o.declarations=o.declarations.filter(l=>!/writing-mode\s*$/.test(l.property))}),i.push(Ql()),i.forEach(o=>{o.selectors=Kl(o.selectors,e)}),Wl({stylesheet:{rules:i},type:"stylesheet"})}function Kl(t,e){return t.map(n=>`${e} ${n}`)}function In(t,e){return e&&(t[e.key]=e.value),t}function Yl(t){const e=/(?:(?:-epub-)|(?:-webkit-))(.+)/i.exec(t.property);if(e)return{key:e[1],value:t.value}}function Ul(t){if(t.property==="font-family"){let e=t.value;return e.includes("sans-serif")?e="var(--font-family-sans-serif, Noto Sans JP, sans-serif)":e.includes("serif")&&(e="var(--font-family-serif, Noto Serif JP, serif)"),{key:t.property,value:e}}}class Jl{constructor(e,n){et(this,"hasLineBreakDefined");this.ruleDeclarations=e,this.newDeclarations=n}convert(e){if(/(?:(?:-epub-)|(?:-webkit-))?word-break$/i.exec(e.property)&&e.value==="break-all"&&(this.hasLineBreakDefined===void 0&&(this.hasLineBreakDefined=this.ruleDeclarations.some(n=>n.type==="declaration"&&n.property==="line-break")),!this.hasLineBreakDefined&&!this.newDeclarations["line-break"]))return{key:"line-break",value:"loose"}}}function Ql(){return{type:"rule",selectors:["br"],declarations:[{type:"declaration",property:"display",value:"inline!important"}]}}function Zl(t,e,n){return Al(t,n).pipe(Ke(i=>({htmlContent:i,styleSheet:ql(t,e)})))}function xl(t){return new St(e=>t.subscribe(n=>{e.next(n)}))}function cn(t=Pr){return e=>t?e:Sr}function Io(t,e,n){return i=>new St(o=>{const r=t();return i.pipe(xo(Pn),Ea(()=>n(r))).subscribe({next:a=>{e(a,r),o.next(a)},error:a=>o.error(a),complete:()=>o.complete()})})}function $l(t,e,n,i,o,r,a,l,f,u){switch(e[t.code]){case bt.BOOKMARK:return n(!0),!0;case bt.JUMP_TO_BOOKMARK:return i(),!0;case bt.AUTO_SCROLL_TOGGLE:return r==null||r.toggle(),!0;case bt.AUTO_SCROLL_INCREASE:return o(1),!0;case bt.AUTO_SCROLL_DECREASE:return o(-1),!0;case bt.NEXT_PAGE:return a==null||a.nextPage(),!0;case bt.PREV_PAGE:return a==null||a.prevPage(),!0;case bt.PREV_CHAPTER:return f(l?1:-1),!0;case bt.NEXT_CHAPTER:return f(l?-1:1),!0;case bt.SET_READING_POINT:return u(),!0;default:return!1}}const{document:An,window:Ao}=Gn;function Oo(t){var P;let e,n,i,o,r,a,l,f;function u(k){t[79](k)}let g={hasChapterData:!!((P=t[26])!=null&&P.length),hasCustomReadingPoint:!!(t[28]&&(t[22]&&t[4]||!t[22]&&t[15]>-1&&t[14]>-1)),showFullscreenButton:dn.fullscreenEnabled,autoScrollMultiplier:t[29]};return t[10]!==void 0&&(g.isBookmarkScreen=t[10]),n=new El({props:g}),ne.push(()=>ce(n,"isBookmarkScreen",u,t[10])),n.$on("tocClick",t[80]),n.$on("setCustomReadingPoint",t[75]),n.$on("showCustomReadingPoint",t[81]),n.$on("resetCustomReadingPoint",t[82]),n.$on("fullscreenClick",t[71]),n.$on("bookmarkClick",t[70]),n.$on("settingsClick",t[83]),n.$on("domainHintClick",t[72]),n.$on("bookManagerClick",t[84]),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(k){e=ee(k,"DIV",{class:!0});var m=te(e);Ee(n.$$.fragment,m),m.forEach(M),this.h()},h(){J(e,"class","elevation-4 writing-horizontal-tb fixed inset-x-0 top-0 z-10 w-full")},m(k,m){W(k,e,m),De(n,e,null),a=!0,l||(f=Wn(o=ri.call(null,e,t[85])),l=!0)},p(k,m){var s;t=k;const v={};m[0]&67108864&&(v.hasChapterData=!!((s=t[26])!=null&&s.length)),m[0]&272678928&&(v.hasCustomReadingPoint=!!(t[28]&&(t[22]&&t[4]||!t[22]&&t[15]>-1&&t[14]>-1))),m[0]&536870912&&(v.autoScrollMultiplier=t[29]),!i&&m[0]&1024&&(i=!0,v.isBookmarkScreen=t[10],he(()=>i=!1)),n.$set(v),o&&jo(o.update)&&m[0]&512&&o.update.call(null,t[85])},i(k){a||(q(n.$$.fragment,k),k&&qo(()=>{r||(r=ro(e,Nn,{y:-300,easing:zn},!0)),r.run(1)}),a=!0)},o(k){Y(n.$$.fragment,k),k&&(r||(r=ro(e,Nn,{y:-300,easing:zn},!1)),r.run(0)),a=!1},d(k){k&&M(e),Te(n),k&&r&&r.end(),l=!1,f()}}}function es(t){let e=(t[52]??"")+"",n;return{c(){n=we(e)},l(i){n=Se(i,e)},m(i,o){W(i,n,o)},p(i,o){o[1]&2097152&&e!==(e=(i[52]??"")+"")&&Ye(n,e)},i:Nt,o:Nt,d(i){i&&M(n)}}}function ts(t){var Ne,ve,ye;let e,n,i,o,r,a,l,f,u,g,P,k,m,v,s,C,p,E=(t[47]??"")+"",N,R,F=(t[48]??"")+"",z,K,D=(t[49]??"")+"",B,L,T=(t[50]??"")+"",I,w,V=(t[51]??"")+"",b,A;e=new yl({props:{styleSheet:t[30].styleSheet}});function Q(_){t[86](_)}function re(_){t[87](_)}function pe(_){t[88](_)}function Ve(_){t[89](_)}function Pe(_){t[90](_)}function _e(_){t[91](_)}function Ie(_){t[92](_)}function ze(_){t[93](_)}function de(_){t[94](_)}function oe(_){t[95](_)}function ie(_){t[96](_)}function Fe(_){t[97](_)}function U(_){t[98](_)}let Z={htmlContent:t[30].htmlContent,width:t[31]??0,height:t[32]??0,verticalMode:t[23],fontColor:(Ne=t[33])==null?void 0:Ne.fontColor,backgroundColor:t[34],hintFuriganaFontColor:(ve=t[33])==null?void 0:ve.hintFuriganaFontColor,hintFuriganaShadowColor:(ye=t[33])==null?void 0:ye.hintFuriganaShadowColor,fontFamilyGroupOne:t[35],fontFamilyGroupTwo:t[36],fontSize:t[37],lineHeight:t[38],hideSpoilerImage:t[39],hideFurigana:t[40],furiganaStyle:t[41],viewMode:t[6],secondDimensionMaxValue:t[42],firstDimensionMargin:t[24],autoPositionOnResize:t[43],avoidPageBreak:t[44],pageColumns:t[45],autoBookmark:t[46],multiplier:t[29]};return t[0]!==void 0&&(Z.exploredCharCount=t[0]),t[1]!==void 0&&(Z.bookCharCount=t[1]),t[10]!==void 0&&(Z.isBookmarkScreen=t[10]),t[3]!==void 0&&(Z.bookmarkData=t[3]),t[2]!==void 0&&(Z.autoScroller=t[2]),t[12]!==void 0&&(Z.bookmarkManager=t[12]),t[13]!==void 0&&(Z.pageManager=t[13]),t[16]!==void 0&&(Z.customReadingPoint=t[16]),t[14]!==void 0&&(Z.customReadingPointTop=t[14]),t[15]!==void 0&&(Z.customReadingPointLeft=t[15]),t[17]!==void 0&&(Z.customReadingPointScrollOffset=t[17]),t[4]!==void 0&&(Z.customReadingPointRange=t[4]),t[5]!==void 0&&(Z.showCustomReadingPoint=t[5]),i=new Sl({props:Z}),ne.push(()=>ce(i,"exploredCharCount",Q,t[0])),ne.push(()=>ce(i,"bookCharCount",re,t[1])),ne.push(()=>ce(i,"isBookmarkScreen",pe,t[10])),ne.push(()=>ce(i,"bookmarkData",Ve,t[3])),ne.push(()=>ce(i,"autoScroller",Pe,t[2])),ne.push(()=>ce(i,"bookmarkManager",_e,t[12])),ne.push(()=>ce(i,"pageManager",Ie,t[13])),ne.push(()=>ce(i,"customReadingPoint",ze,t[16])),ne.push(()=>ce(i,"customReadingPointTop",de,t[14])),ne.push(()=>ce(i,"customReadingPointLeft",oe,t[15])),ne.push(()=>ce(i,"customReadingPointScrollOffset",ie,t[17])),ne.push(()=>ce(i,"customReadingPointRange",Fe,t[4])),ne.push(()=>ce(i,"showCustomReadingPoint",U,t[5])),i.$on("bookmark",t[70]),{c(){Me(e.$$.fragment),n=ue(),Me(i.$$.fragment),p=ue(),N=we(E),R=ue(),z=we(F),K=ue(),B=we(D),L=ue(),I=we(T),w=ue(),b=we(V)},l(_){Ee(e.$$.fragment,_),n=fe(_),Ee(i.$$.fragment,_),p=fe(_),N=Se(_,E),R=fe(_),z=Se(_,F),K=fe(_),B=Se(_,D),L=fe(_),I=Se(_,T),w=fe(_),b=Se(_,V)},m(_,O){De(e,_,O),W(_,n,O),De(i,_,O),W(_,p,O),W(_,N,O),W(_,R,O),W(_,z,O),W(_,K,O),W(_,B,O),W(_,L,O),W(_,I,O),W(_,w,O),W(_,b,O),A=!0},p(_,O){var Be,ke,Ae;const He={};O[0]&1073741824&&(He.styleSheet=_[30].styleSheet),e.$set(He);const j={};O[0]&1073741824&&(j.htmlContent=_[30].htmlContent),O[1]&1&&(j.width=_[31]??0),O[1]&2&&(j.height=_[32]??0),O[0]&8388608&&(j.verticalMode=_[23]),O[1]&4&&(j.fontColor=(Be=_[33])==null?void 0:Be.fontColor),O[1]&8&&(j.backgroundColor=_[34]),O[1]&4&&(j.hintFuriganaFontColor=(ke=_[33])==null?void 0:ke.hintFuriganaFontColor),O[1]&4&&(j.hintFuriganaShadowColor=(Ae=_[33])==null?void 0:Ae.hintFuriganaShadowColor),O[1]&16&&(j.fontFamilyGroupOne=_[35]),O[1]&32&&(j.fontFamilyGroupTwo=_[36]),O[1]&64&&(j.fontSize=_[37]),O[1]&128&&(j.lineHeight=_[38]),O[1]&256&&(j.hideSpoilerImage=_[39]),O[1]&512&&(j.hideFurigana=_[40]),O[1]&1024&&(j.furiganaStyle=_[41]),O[0]&64&&(j.viewMode=_[6]),O[1]&2048&&(j.secondDimensionMaxValue=_[42]),O[0]&16777216&&(j.firstDimensionMargin=_[24]),O[1]&4096&&(j.autoPositionOnResize=_[43]),O[1]&8192&&(j.avoidPageBreak=_[44]),O[1]&16384&&(j.pageColumns=_[45]),O[1]&32768&&(j.autoBookmark=_[46]),O[0]&536870912&&(j.multiplier=_[29]),!o&&O[0]&1&&(o=!0,j.exploredCharCount=_[0],he(()=>o=!1)),!r&&O[0]&2&&(r=!0,j.bookCharCount=_[1],he(()=>r=!1)),!a&&O[0]&1024&&(a=!0,j.isBookmarkScreen=_[10],he(()=>a=!1)),!l&&O[0]&8&&(l=!0,j.bookmarkData=_[3],he(()=>l=!1)),!f&&O[0]&4&&(f=!0,j.autoScroller=_[2],he(()=>f=!1)),!u&&O[0]&4096&&(u=!0,j.bookmarkManager=_[12],he(()=>u=!1)),!g&&O[0]&8192&&(g=!0,j.pageManager=_[13],he(()=>g=!1)),!P&&O[0]&65536&&(P=!0,j.customReadingPoint=_[16],he(()=>P=!1)),!k&&O[0]&16384&&(k=!0,j.customReadingPointTop=_[14],he(()=>k=!1)),!m&&O[0]&32768&&(m=!0,j.customReadingPointLeft=_[15],he(()=>m=!1)),!v&&O[0]&131072&&(v=!0,j.customReadingPointScrollOffset=_[17],he(()=>v=!1)),!s&&O[0]&16&&(s=!0,j.customReadingPointRange=_[4],he(()=>s=!1)),!C&&O[0]&32&&(C=!0,j.showCustomReadingPoint=_[5],he(()=>C=!1)),i.$set(j),(!A||O[1]&65536)&&E!==(E=(_[47]??"")+"")&&Ye(N,E),(!A||O[1]&131072)&&F!==(F=(_[48]??"")+"")&&Ye(z,F),(!A||O[1]&262144)&&D!==(D=(_[49]??"")+"")&&Ye(B,D),(!A||O[1]&524288)&&T!==(T=(_[50]??"")+"")&&Ye(I,T),(!A||O[1]&1048576)&&V!==(V=(_[51]??"")+"")&&Ye(b,V)},i(_){A||(q(e.$$.fragment,_),q(i.$$.fragment,_),A=!0)},o(_){Y(e.$$.fragment,_),Y(i.$$.fragment,_),A=!1},d(_){Te(e,_),_&&M(n),Te(i,_),_&&M(p),_&&M(N),_&&M(R),_&&M(z),_&&M(K),_&&M(B),_&&M(L),_&&M(I),_&&M(w),_&&M(b)}}}function Lo(t){let e,n,i,o,r,a;return n=new Bl({props:{sectionData:t[26],verticalMode:t[23],exploredCharCount:t[0]}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(l){e=ee(l,"DIV",{class:!0});var f=te(e);Ee(n.$$.fragment,f),f.forEach(M),this.h()},h(){var l;J(e,"class","writing-horizontal-tb fixed top-0 left-0 z-[60] flex h-full w-full max-w-xl flex-col justify-between"),y(e,"color",(l=t[33])==null?void 0:l.fontColor),y(e,"background-color",t[34])},m(l,f){W(l,e,f),De(n,e,null),o=!0,r||(a=Wn(ri.call(null,e,t[99])),r=!0)},p(l,f){var g;t=l;const u={};f[0]&67108864&&(u.sectionData=t[26]),f[0]&8388608&&(u.verticalMode=t[23]),f[0]&1&&(u.exploredCharCount=t[0]),n.$set(u),f[1]&4&&y(e,"color",(g=t[33])==null?void 0:g.fontColor),f[1]&8&&y(e,"background-color",t[34])},i(l){o||(q(n.$$.fragment,l),l&&(i||qo(()=>{i=ar(e,Nn,{x:-100,duration:100,easing:zn}),i.start()})),o=!0)},o(l){Y(n.$$.fragment,l),o=!1},d(l){l&&M(e),Te(n),r=!1,a()}}}function Vo(t){let e,n,i;return{c(){e=$("div"),n=ue(),i=$("div"),this.h()},l(o){e=ee(o,"DIV",{class:!0}),te(e).forEach(M),n=fe(o),i=ee(o,"DIV",{class:!0}),te(i).forEach(M),this.h()},h(){J(e,"class","fixed left-0 z-20 h-[1px] w-full border border-red-500"),y(e,"top",`${t[14]}px`),J(i,"class","fixed top-0 z-20 h-full w-[1px] border border-red-500"),y(i,"left",`${t[15]}px`)},m(o,r){W(o,e,r),W(o,n,r),W(o,i,r)},p(o,r){r[0]&16384&&y(e,"top",`${o[14]}px`),r[0]&32768&&y(i,"left",`${o[15]}px`)},d(o){o&&M(e),o&&M(n),o&&M(i)}}}function zo(t){let e,n,i;return n=new ct({props:{icon:Xn,spin:!0}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(o){e=ee(o,"DIV",{class:!0});var r=te(e);Ee(n.$$.fragment,r),r.forEach(M),this.h()},h(){J(e,"class","fixed inset-0 flex h-full w-full items-center justify-center text-7xl")},m(o,r){W(o,e,r),De(n,e,null),i=!0},p:Nt,i(o){i||(q(n.$$.fragment,o),i=!0)},o(o){Y(n.$$.fragment,o),i=!1},d(o){o&&M(e),Te(n)}}}function No(t){let e,n,i,o,r;return n=new ct({props:{icon:ta}}),{c(){e=$("div"),Me(n.$$.fragment),this.h()},l(a){e=ee(a,"DIV",{class:!0});var l=te(e);Ee(n.$$.fragment,l),l.forEach(M),this.h()},h(){J(e,"class","flex h-full w-8 items-center justify-center text-lg"),X(e,"text-red-500",t[20]>1),X(e,"animate-pulse",t[20]>1||t[21])},m(a,l){W(a,e,l),De(n,e,null),i=!0,o||(r=[Ce(e,"click",lr(t[100])),Ce(e,"keyup",Rt)],o=!0)},p(a,l){(!i||l[0]&1048576)&&X(e,"text-red-500",a[20]>1),(!i||l[0]&3145728)&&X(e,"animate-pulse",a[20]>1||a[21])},i(a){i||(q(n.$$.fragment,a),i=!0)},o(a){Y(n.$$.fragment,a),i=!1},d(a){a&&M(e),Te(n),o=!1,Tt(r)}}}function Ho(t){let e,n,i,o,r,a=(t[0]/t[1]*100).toFixed(2)+"",l,f;return{c(){e=$("div"),n=we(t[0]),i=we(" / "),o=we(t[1]),r=we(" ("),l=we(a),f=we("%)"),this.h()},l(u){e=ee(u,"DIV",{class:!0});var g=te(e);n=Se(g,t[0]),i=Se(g," / "),o=Se(g,t[1]),r=Se(g," ("),l=Se(g,a),f=Se(g,"%)"),g.forEach(M),this.h()},h(){var u;J(e,"class","writing-horizontal-tb fixed bottom-2 right-2 z-10 text-xs leading-none"),y(e,"color",(u=t[33])==null?void 0:u.tooltipTextFontColor)},m(u,g){W(u,e,g),le(e,n),le(e,i),le(e,o),le(e,r),le(e,l),le(e,f)},p(u,g){var P;g[0]&1&&Ye(n,u[0]),g[0]&2&&Ye(o,u[1]),g[0]&3&&a!==(a=(u[0]/u[1]*100).toFixed(2)+"")&&Ye(l,a),g[1]&4&&y(e,"color",(P=u[33])==null?void 0:P.tooltipTextFontColor)},d(u){u&&M(e)}}}function ns(t){var V;let e,n,i=(t[27]??"")+"",o,r,a,l,f,u,g,P,k,m,v,s,C,p,E,N,R;An.title=e=fo(((V=t[25])==null?void 0:V.title)??"");let F=t[9]&&Oo(t);const z=[ts,es],K=[];function D(b,A){return b[30]?0:1}u=D(t),g=K[u]=z[u](t);let B=t[7]&&Lo(t),L=(t[18]&&!t[53]||!t[22]&&t[5])&&Vo(t),T=t[8]&&zo(),I=t[19].length&&No(t),w=t[11]&&t[1]&&Ho(t);return{c(){n=ue(),o=we(i),r=ue(),a=$("button"),l=ue(),F&&F.c(),f=ue(),g.c(),P=ue(),B&&B.c(),k=ue(),L&&L.c(),m=ue(),T&&T.c(),v=ue(),s=$("div"),C=$("div"),I&&I.c(),p=ue(),w&&w.c(),this.h()},l(b){rr("svelte-rnuhm6",An.head).forEach(M),n=fe(b),o=Se(b,i),r=fe(b),a=ee(b,"BUTTON",{class:!0}),te(a).forEach(M),l=fe(b),F&&F.l(b),f=fe(b),g.l(b),P=fe(b),B&&B.l(b),k=fe(b),L&&L.l(b),m=fe(b),T&&T.l(b),v=fe(b),s=ee(b,"DIV",{class:!0});var Q=te(s);C=ee(Q,"DIV",{class:!0});var re=te(C);I&&I.l(re),re.forEach(M),p=fe(Q),w&&w.l(Q),Q.forEach(M),this.h()},h(){var b;J(a,"class","fixed inset-x-0 top-0 z-10 h-8 w-full"),J(C,"class","h-full"),J(s,"class","writing-horizontal-tb fixed bottom-0 left-0 z-10 flex h-8 w-full cursor-pointer items-center justify-between text-xs leading-none"),y(s,"color",(b=t[33])==null?void 0:b.tooltipTextFontColor)},m(b,A){W(b,n,A),W(b,o,A),W(b,r,A),W(b,a,A),W(b,l,A),F&&F.m(b,A),W(b,f,A),K[u].m(b,A),W(b,P,A),B&&B.m(b,A),W(b,k,A),L&&L.m(b,A),W(b,m,A),T&&T.m(b,A),W(b,v,A),W(b,s,A),le(s,C),I&&I.m(C,null),le(s,p),w&&w.m(s,null),E=!0,N||(R=[Ce(Ao,"keydown",t[69]),Ce(Ao,"beforeunload",t[68]),Ce(a,"click",t[78]),Ce(s,"click",t[101]),Ce(s,"keyup",Rt)],N=!0)},p(b,A){var re,pe;(!E||A[0]&33554432)&&e!==(e=fo(((re=b[25])==null?void 0:re.title)??""))&&(An.title=e),(!E||A[0]&134217728)&&i!==(i=(b[27]??"")+"")&&Ye(o,i),b[9]?F?(F.p(b,A),A[0]&512&&q(F,1)):(F=Oo(b),F.c(),q(F,1),F.m(f.parentNode,f)):F&&(ut(),Y(F,1,1,()=>{F=null}),ft());let Q=u;u=D(b),u===Q?K[u].p(b,A):(ut(),Y(K[Q],1,1,()=>{K[Q]=null}),ft(),g=K[u],g?g.p(b,A):(g=K[u]=z[u](b),g.c()),q(g,1),g.m(P.parentNode,P)),b[7]?B?(B.p(b,A),A[0]&128&&q(B,1)):(B=Lo(b),B.c(),q(B,1),B.m(k.parentNode,k)):B&&(ut(),Y(B,1,1,()=>{B=null}),ft()),b[18]&&!b[53]||!b[22]&&b[5]?L?L.p(b,A):(L=Vo(b),L.c(),L.m(m.parentNode,m)):L&&(L.d(1),L=null),b[8]?T?(T.p(b,A),A[0]&256&&q(T,1)):(T=zo(),T.c(),q(T,1),T.m(v.parentNode,v)):T&&(ut(),Y(T,1,1,()=>{T=null}),ft()),b[19].length?I?(I.p(b,A),A[0]&524288&&q(I,1)):(I=No(b),I.c(),q(I,1),I.m(C,null)):I&&(ut(),Y(I,1,1,()=>{I=null}),ft()),b[11]&&b[1]?w?w.p(b,A):(w=Ho(b),w.c(),w.m(s,null)):w&&(w.d(1),w=null),A[1]&4&&y(s,"color",(pe=b[33])==null?void 0:pe.tooltipTextFontColor)},i(b){E||(q(F),q(g),q(B),q(T),q(I),E=!0)},o(b){Y(F),Y(g),Y(B),Y(T),Y(I),E=!1},d(b){b&&M(n),b&&M(o),b&&M(r),b&&M(a),b&&M(l),F&&F.d(b),b&&M(f),K[u].d(b),b&&M(P),B&&B.d(b),b&&M(k),L&&L.d(b),b&&M(m),T&&T.d(b),b&&M(v),b&&M(s),I&&I.d(),w&&w.d(),N=!1,Tt(R)}}}const Go="background-color",Wo="writing-mode";function os(t,e,n){let i,o,r,a,l,f,u,g,P,k,m,v,s,C,p,E,N,R,F,z,K,D,B,L,T,I,w,V,b,A,Q,re,pe,Ve,Pe,_e,Ie,ze,de,oe,ie,Fe,U,Z,Ne,ve;G(t,Dr,c=>n(23,r=c)),G(t,$o,c=>n(24,a=c)),G(t,Tr,c=>n(108,l=c)),G(t,Fr,c=>n(109,f=c)),G(t,Br,c=>n(110,g=c)),G(t,Ir,c=>n(111,P=c)),G(t,ei,c=>n(112,m=c)),G(t,Kt,c=>n(113,v=c)),G(t,Ar,c=>n(77,s=c)),G(t,Or,c=>n(114,C=c)),G(t,Lr,c=>n(115,p=c)),G(t,Vr,c=>n(6,E=c)),G(t,Vt,c=>n(7,N=c)),G(t,Dn,c=>n(116,R=c)),G(t,Tn,c=>n(117,F=c)),G(t,Zo,c=>n(28,K=c)),G(t,Fn,c=>n(29,D=c)),G(t,zr,c=>n(35,V=c)),G(t,Nr,c=>n(36,b=c)),G(t,Hr,c=>n(37,A=c)),G(t,Gr,c=>n(38,Q=c)),G(t,Wr,c=>n(39,re=c)),G(t,jr,c=>n(40,pe=c)),G(t,Xr,c=>n(41,Ve=c)),G(t,qr,c=>n(42,Pe=c)),G(t,Kr,c=>n(43,_e=c)),G(t,Yr,c=>n(44,Ie=c)),G(t,Ur,c=>n(45,ze=c)),G(t,Jr,c=>n(46,de=c)),G(t,jn,c=>n(53,ve=c));let ye=!0,_=!0,O=!1,He=!0,j=0,Be=0,ke,Ae,dt,Ue=Promise.resolve(void 0),be=-2,me=-2,Je=r?F:R,Qe=0,ge,at,Ge=!0,pt=!1,je=!1,Ze,Xe=[],gt=[],Re,kt=0,S=!1,ae=0;const We=nn(2500).pipe(_t(()=>n(9,_=!1)),yt());G(t,We,c=>n(27,z=c));const Oe=It(()=>xl(Qr)).pipe(Ke(c=>Number(c.url.searchParams.get("id"))),Ln({refCount:!0,bufferSize:1})),d=Oe.pipe(Lt(async c=>{let H;try{if(Ze=ln(window,sn.BROWSER,void 0,!0,l,f),Ze.startContext({id:c,title:""}),H=await Ze.getBook(),!H)return H;Ze.startContext({id:H.id,title:H.title,imagePath:H.coverImage}),H.storageSource?n(76,Re=await to(H.storageSource,!0)):s!==jt.Off&&n(76,Re=await to(P)),H.lastBookOpen=new Date().getTime(),await Ze.updateLastRead(H),H=await _i(Re,H),await wi(Re)}catch(se){const Le=`Error loading book: ${se.message}`;mt.warn(Le),tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:Le}}]);return}finally{n(8,ye=!1)}return Re&&Re.updateSettings(window,!0,f,l,!1,H.storageSource||P),H}),Vn());G(t,d,c=>n(25,u=c));const x=d.pipe(_t(c=>{c||co(`${so}${qe.MANAGE.routeId}`)}),yt());G(t,x,c=>n(52,Ne=c));const h=d.pipe(_t(c=>{!c||n(3,Ue=En.getBookmark(c.id))}),yt());G(t,h,c=>n(47,oe=c));const lt=d.pipe(Lt(c=>c?(Kn.next(c.sections||[]),Zl(c,".book-content",document)):Ht),Ln({refCount:!0,bufferSize:1}));G(t,lt,c=>n(30,B=c));const an=It(()=>visualViewport?rt(visualViewport,"resize"):qn()).pipe(Vn()),Un=an.pipe(On(0),Ke(()=>(visualViewport==null?void 0:visualViewport.width)||0),cn());G(t,Un,c=>n(31,L=c));const Jn=an.pipe(On(0),Ke(()=>(visualViewport==null?void 0:visualViewport.height)||0),cn());G(t,Jn,c=>n(32,T=c));const vn=vr.pipe(Ke(c=>la.get(c)),$t(c=>!!c));G(t,vn,c=>n(33,I=c));const yn=vn.pipe(Ke(c=>c.backgroundColor));G(t,yn,c=>n(34,w=c));const Qn=yn.pipe(Io(()=>document.body,(c,H)=>H.style.setProperty(Go,c),c=>c.style.removeProperty(Go)),yt(),cn());G(t,Qn,c=>n(48,ie=c));const Zn=yr.pipe(Io(()=>document.documentElement,(c,H)=>H.style.setProperty(Wo,c),c=>c.style.removeProperty(Wo)),yt(),cn());G(t,Zn,c=>n(49,Fe=c));const xn=It(()=>bn).pipe(Ke(c=>[...c.values()]));G(t,xn,c=>n(26,k=c));const $n=It(()=>rt(document,"selectionchange")).pipe(xt(200),_t(()=>{var H,se;const c=((H=window.getSelection())==null?void 0:H.toString())||"";!c&&Ge?at=void 0:c?(at=(se=window.getSelection())==null?void 0:se.getRangeAt(0),Ge=!1):Ge=!0}),yt());G(t,$n,c=>n(50,U=c));const eo=Bn.pipe(ya(6e4),Lt(()=>Wt()),yt());G(t,eo,c=>n(51,Z=c));function Ci(c){return p&&(S||ae!==j||o&&Xe.length||o&>.length)?(c.preventDefault(),c.returnValue="Are you sure you want to exit?"):c}async function to(c,H=!1){if(!c){if(H)throw new Error("No storage source found");return}if(c===lo.GDRIVE_DEFAULT){if(!C){tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:"Sync disabled due to missing Online Connection - refresh Page after going Online to try again"}}]);return}return ln(window,sn.GDRIVE,c,!0,l,f)}if(c===lo.ONEDRIVE_DEFAULT){if(!C){tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:"Sync disabled due to missing Online Connection - refresh Page after going Online to try again"}}]);return}return ln(window,sn.ONEDRIVE,c,!0,l,f)}if(c){const xe=await(await En.db).get("storageSource",c);if(xe){if(xe.type!==sn.FS&&!C){tt.dialogs$.next([{component:Ct,props:{title:"Load Error",message:"Sync disabled due to missing Online Connection - refresh Page after going Online to try again"}}]);return}return ln(window,xe.type,c,!0,l,f)}if(H)throw new Error(`No storage source with name ${c} found`)}const se=`No storage source with name ${c} found - skipping auto import/export`;mt.warn(se),tt.dialogs$.next([{component:Ct,props:{title:"Configuration Error",message:se}}])}async function _i(c,H){if(!c)return H;l||c.clearData(!1),c.startContext({id:H.id,title:H.title,imagePath:H.coverImage||""});let{id:se,...Le}=H;if(H.storageSource){const ot=await c.getBook();ot&&!(ot instanceof File)&&(Le={...ot,id:H.id,lastBookOpen:H.lastBookOpen,storageSource:H.storageSource})}else if(!H.elementHtml)throw new Error("Book has no data stored");const xe={id:se,...Le};return await c.updateLastRead(xe).catch(ot=>{const $e=`Failed to update last read on external storage: ${ot.message}`;mt.warn($e),tt.dialogs$.next([{component:Ct,props:{title:"Update Error",message:$e}}])}),xe}async function wi(c){if(Ze&&c&&(s===jt.Down||s===jt.All)){const H=await c.getProgress();H&&!(H instanceof File)&&(await Ze.saveProgress(H),ae=H.exploredCharCount||0)}}function Si(c){v||!$l(c,Er.getValue(),Rn,vi,se=>Fn.next(Fn.getValue()+se),ke,dt,r,Mi,oo)||(document.activeElement instanceof HTMLElement&&document.activeElement.blur(),c.preventDefault())}function Pi(){let c;return Oe.subscribe(H=>c=H).unsubscribe(),c}async function Rn(c){var Le;const H=Pi();if(!H||!Ae)return;let se;if(n(9,_=!1),i){const xe=m?La(window,at):void 0,ot=xe||ge;qt((Le=ot==null?void 0:ot.endContainer)==null?void 0:Le.parentElement,"add",.5,500),se=Ae.formatBookmarkDataByRange(H,ot),xe&&hi(window)}else se=Ae.formatBookmarkData(H,Qe);if(await Ze.saveProgress(se),o){const xe=S?gt:Xe;xe.includes(uo.PROGRESS)||xe.push(uo.PROGRESS),c&&Bn.next()}n(3,Ue=Promise.resolve(se))}async function vi(){const c=await Ue;!c||!Ae||Ae.scrollToBookmark(c,Qe)}function yi(){if(n(9,_=!1),!dn.fullscreenElement){dn.requestFullscreen(document.documentElement);return}dn.exitFullscreen()}function Ri(){tt.dialogs$.next([{component:Ct,props:{title:"Old Domain",message:"You are currently using the old domain of ッツ Reader - consider switching to https://reader.ttsu.app to prevent issues and to ensure full features"},disableCloseOnClick:!0}])}function Mi(c){if(!(k!=null&&k.length))return;const[H,se]=fi(k);!se&&c===-1||c===1&&se===H.length-1||rn.next(H[se+c].reference)}async function Wt(c=!0){if(S||!Xe.length||!u||!Re)return;n(21,S=!0),c||(Kt.next(!0),mt.clearHistory(),no());const H=u.storageSource||P;Re.updateSettings(window,!1,f,l,!c,H);const se=await Rr(Ze,Re,!c&&g===Re.storageType,[{id:u.id,title:u.title,imagePath:u.coverImage}],Xe).catch(Le=>Le.message);if(Re.updateSettings(window,!0,f,l,!1,H),n(21,S=!1),se){if(!c){const Le=mt.errorCount>1;mt.warn(se),tt.dialogs$.next([{component:Le?Mr:Ct,props:{title:"Error Processing Data",message:Le?"Some or all data could not be stored on an external storage":se}}])}n(20,kt+=1)}else n(20,kt=0),c||tt.dialogs$.next([]),gt.length?(n(19,Xe=JSON.parse(JSON.stringify(gt))),gt=[],c?Bn.next():await Wt(!1)):n(19,Xe=[]);c||Kt.next(!1)}function no(){tt.dialogs$.next([{component:"
",disableCloseOnClick:!0}])}async function Mn(c,H=!0){no();let se;try{H&&await En.deleteLastItem(),await Rn(!1),tt.dialogs$.next([]),o&&await Wt(!1)}catch(Le){se=Le.message}se&&(mt.warn(se),tt.dialogs$.next([{component:Ct,props:{title:"Error",message:se},disableCloseOnClick:!0}])),co(`${so}${c}`)}function oo(){const c=document.querySelector(".book-content");if(!c)return;i&&(n(14,be=window.innerHeight/2-2),n(15,me=window.innerWidth/2-2)),n(9,_=!1),n(18,pt=!0),document.body.classList.add("cursor-crosshair");const{elLeftReferencePoint:H,elTopReferencePoint:se,elRightReferencePoint:Le,elBottomReferencePoint:xe,pointGap:ot}=di(window,c,r,a);on(rt(document,"pointerup"),rt(document,"pointermove")).pipe(Ta(()=>pt)).subscribe($e=>{if($e instanceof PointerEvent)if($e.type==="pointerup")document.body.classList.remove("cursor-crosshair"),n(18,pt=!1),sr().then(()=>{n(15,me=r?$e.x:me),n(14,be=r?be:$e.y);const Pt=Oa(me,be);if(Pt&&qt(Pt.parent,"add",.5,500),i)n(4,ge=Pt==null?void 0:Pt.range);else{let vt=0;r?(vt=Math.ceil(Math.max(0,me-H)/(Le-H)*100),Tn.next(vt)):(vt=Math.ceil(Math.max(0,be-se)/(xe-se)*100),Dn.next(vt)),n(16,Je=vt)}});else{const Pt=$e.x>=H+ot&&$e.x<=Le,vt=$e.y>=se&&$e.y<=xe-ot;i?(n(14,be=vt?$e.y:be),n(15,me=Pt?$e.x:me)):r&&Pt?n(15,me=$e.x):!r&&vt&&n(14,be=$e.y)}})}const Ei=()=>n(9,_=!0);function Di(c){O=c,n(10,O)}const Ti=()=>{n(9,_=!1),Vt.next(!0)},Fi=()=>{n(9,_=!1),n(5,je=!0)},Bi=()=>{n(9,_=!1),i?n(4,ge=void 0):r?(Tn.next(100),n(16,Je=100)):(Dn.next(0),n(16,Je=0))},Ii=()=>Mn(qe.SETTINGS.routeId,!1),Ai=()=>Mn(qe.MANAGE.routeId),Oi=()=>n(9,_=!1);function Li(c){j=c,n(0,j)}function Vi(c){Be=c,n(1,Be)}function zi(c){O=c,n(10,O)}function Ni(c){Ue=c,n(3,Ue)}function Hi(c){ke=c,n(2,ke)}function Gi(c){Ae=c,n(12,Ae)}function Wi(c){dt=c,n(13,dt)}function ji(c){Je=c,n(16,Je)}function Xi(c){be=c,n(14,be)}function qi(c){me=c,n(15,me)}function Ki(c){Qe=c,n(17,Qe)}function Yi(c){ge=c,n(4,ge)}function Ui(c){je=c,n(5,je),n(4,ge)}const Ji=()=>Vt.next(!1),Qi=()=>Wt(!1),Zi=()=>n(11,He=!He);return t.$$.update=()=>{var c;t.$$.dirty[0]&132&&N&&(ke==null||ke.off()),t.$$.dirty[0]&3&&Be&&document.dispatchEvent(new CustomEvent("ttsu:page.change",{detail:{exploredCharCount:j}})),t.$$.dirty[0]&2&&document.dispatchEvent(new CustomEvent("ttsu:page.change",{detail:{bookCharCount:Be}})),t.$$.dirty[0]&48&&je&&(qt((c=ge==null?void 0:ge.endContainer)==null?void 0:c.parentElement,"add",1),rt(document,"click").pipe(mn(1),Gt(1)).subscribe(()=>{var H;n(5,je=!1),qt((H=ge==null?void 0:ge.endContainer)==null?void 0:H.parentElement,"remove",1)})),t.$$.dirty[0]&64&&n(22,i=E===Yt.Paginated),t.$$.dirty[2]&49152&&(o=Re&&(s===jt.Up||s===jt.All)),t.$$.dirty[0]&8&&Ue.then(H=>ae=(H==null?void 0:H.exploredCharCount)||0)},[j,Be,ke,Ue,ge,je,E,N,ye,_,O,He,Ae,dt,be,me,Je,Qe,pt,Xe,kt,S,i,r,a,u,k,z,K,D,B,L,T,I,w,V,b,A,Q,re,pe,Ve,Pe,_e,Ie,ze,de,oe,ie,Fe,U,Z,Ne,ve,We,d,x,h,lt,Un,Jn,vn,yn,Qn,Zn,xn,$n,eo,Ci,Si,Rn,yi,Ri,Wt,Mn,oo,Re,s,Ei,Di,Ti,Fi,Bi,Ii,Ai,Oi,Li,Vi,zi,Ni,Hi,Gi,Wi,ji,Xi,qi,Ki,Yi,Ui,Ji,Qi,Zi]}class ms extends Mt{constructor(e){super(),Et(this,e,os,ns,Dt,{},null,[-1,-1,-1,-1,-1])}}export{ms as default};