/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var Mr = Object . create ; var ke = Object . defineProperty ; var Rr = Object . getOwnPropertyDescriptor ; var Lr = Object . getOwnPropertyNames , Ft = Object . getOwnPropertySymbols , Fr = Object . getPrototypeOf , _t = Object . prototype . hasOwnProperty , _r = Object . prototype . propertyIsEnumerable ; var $t = ( r , e , t ) => e in r ? ke ( r , e , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : t } ) : r [ e ] = t , ye = ( r , e ) => { for ( var t in e || ( e = { } ) ) _t . call ( e , t ) && $t ( r , t , e [ t ] ) ; if ( Ft ) for ( var t of Ft ( e ) ) _r . call ( e , t ) && $t ( r , t , e [ t ] ) ; return r } ; var Vt = r => ke ( r , "__esModule" , { value : ! 0 } ) ; var $r = ( r , e ) => { Vt ( r ) ; for ( var t in e ) ke ( r , t , { get : e [ t ] , enumerable : ! 0 } ) } , Vr = ( r , e , t ) => { if ( e && typeof e == "object" || typeof e == "function" ) for ( let o of Lr ( e ) ) ! _t . call ( r , o ) && o !== "default" && ke ( r , o , { get : ( ) => e [ o ] , enumerable : ! ( t = Rr ( e , o ) ) || t . enumerable } ) ; return r } , q = r => Vr ( Vt ( ke ( r != null ? Mr ( Fr ( r ) ) : { } , "default" , r && r . _ _esModule && "default" in r ? { get : ( ) => r . default , enumerable : ! 0 } : { value : r , enumerable : ! 0 } ) ) , r ) ; var h = ( r , e , t ) => new Promise ( ( o , i ) => { var n = l => { try { a ( t . next ( l ) ) } catch ( u ) { i ( u ) } } , s = l => { try { a ( t . throw ( l ) ) } catch ( u ) { i ( u ) } } , a = l => l . done ? o ( l . value ) : Promise . resolve ( l . value ) . then ( n , s ) ; a ( ( t = t . apply ( r , e ) ) . next ( ) ) } ) ; $r ( exports , { default : ( ) => Tt } ) ; var ne = q ( require ( "obsidian" ) ) ; var re = q ( require ( "obsidian" ) ) ; var I ; ( function ( t ) { t . google = "google" , t . naver = "naver" } ) ( I || ( I = { } ) ) ; var Ht = q ( require ( "obsidian" ) ) ; var rt = class { constructor ( e , t ) { this . localePreference = e ; this . apiKey = t } getByQuery ( e ) { return h ( this , null , function * ( ) { try { let t = { q : e , maxResults : 40 , printType : "books" } , o = this . localePreference ; o === "default" ? t . langRestrict = window . moment . locale ( ) : t . langRestrict = o , this . apiKey !== "" && ( t . key = this . apiKey ) ; let i = yield He ( "https://www.googleapis.com/books/v1/volumes" , t ) ; return ( i == null ? void 0 : i . totalItems ) ? i . items . map ( ( { volumeInfo : n } ) => this . createBookItem ( n ) ) : [ ] } catch ( t ) { throw console . warn ( t ) , t } } ) } getISBN ( e ) { return e == null ? void 0 : e . reduce ( ( t , o ) => ( o . type == "ISBN_10" && ( t . isbn10 = o . identifier . trim ( ) ) , o . type == "ISBN_13" && ( t . isbn13 = o . identifier . trim ( ) ) , t ) , { } ) } createBookItem ( e ) { var o , i , n , s ; return ye ( { title : e . title , subtitle : e . subtitle , author : this . formatList ( e . authors ) , authors : e . authors , category : this . formatList ( e . categories ) , categories : e . categories , publisher : e . publisher , totalPage : e . pageCount , coverUrl : ( i = ( o = e . imageLinks ) == null ? void 0 : o . thumbnail ) != null ? i : "" , coverSmallUrl : ( s = ( n = e . imageLinks ) == null ? void 0 : n . smallThumbnail ) != null ? s : "" , publishDate : e . publishedDate || "" , description : e . description , link : e . canonicalVolumeLink || e . infoLink , previewLink : e . previewLink } , this . getISBN ( e . industryIdentifiers ) ) } convertGoogleBookImageURLSize ( e , t ) { return e . replace ( /(&zoom)=\d/ , ` $ 1= ${ t } ` ) } formatList ( e ) { var t , o ; return ( e == null ? void 0 : e . length ) > 1 ? e . map ( i => ` ${ i . trim ( ) } ` ) . join ( ", " ) : ( o = ( t = e == null ? void 0 : e [ 0 ] ) == null ? void 0 : t . replace ( "N/A" , "" ) ) != null ? o : "" } } ; var ot = class { constructor ( e , t ) { this . clientId = e ; this . clientSecret = t } getByQuery ( e ) { return h ( this , null , function * ( ) { try { let t = { query : e , display : 50 , sort : "sim" } , o = { "X-Naver-Client-Id" : this . clientId , "X-Naver-Client-Secret" : this . clientSecret } , i = yield He ( "https://openapi.naver.com/v1/search/book.json" , t , o ) ; return ( i == null ? void 0 : i . total ) ? i . items . map ( this . createBookItem ) : [ ] } catch ( t ) { throw console . warn ( t ) , t } } ) } createBookItem ( e ) { var t , o ; return ye ( { title : e . title , author : e . author , publisher : e . publisher , coverUrl : e . image , publishDate : ( ( t = e . pubdate ) == null ? void 0 : t . slice ( 0 , 4 ) ) || "" , link : e . link , description : e . description , isbn : e . isbn } , ( ( o = e . isbn ) == null ? void 0 : o . length ) >= 13 ? { isbn13 : e . isbn } : { isbn10 : e . isbn } ) } } ; function Wt ( r ) { if ( r . serviceProvider === I . google ) return new rt ( r . localePreference , r . apiKey ) ; if ( r . serviceProvider === I . naver ) { if ( ! r . naverClientId || ! r . naverClientSecret ) throw new Error ( '\uB124\uC774\uBC84 \uAC1C\uBC1C\uC790\uC13C\uD130\uC5D0\uC11C "Client ID"\uC640 "Client Secret"\uB97C \uBC1C\uAE09\uBC1B\uC544 \uC124\uC815\uD574\uC8FC\uC138\uC694.' ) ; return new ot ( r . naverClientId , r . naverClientSecret ) } } function He ( o ) { return h ( this , arguments , function * ( r , e = { } , t ) { let i = new URL ( r ) ; return Object . entries ( e ) . forEach ( ( [ s , a ] ) => { i . searchParams . append ( s , a == null ? void 0 : a . toString ( ) ) } ) , ( yield ( 0 , Ht . requestUrl ) ( { url : i . href , method : "GET" , headers : ye ( { Accept : "*/*" , "Content-Type" : "application/json; charset=utf-8" } ,
` ).map(e=>{var n,s;let t=e.indexOf(":");if(t===-1)return[e.trim(),""];let o=(n=e.slice(0,t))==null?void 0:n.trim(),i=(s=e.slice(t+1))==null?void 0:s.trim();return[o,i]}).reduce((e,[t,o])=>{var i;return t&&(e[t]=(i=o==null?void 0:o.trim())!=null?i:""),e},{}):{}}function Yt(r){return Object.entries(r).map(([e,t])=>{var i;let o=(i=t==null?void 0:t.toString().trim())!=null?i:"";return/ \r | \n /.test(o)?"":/: \s /.test(o)? ` $ { e } : "${o.replace(/" / g , """ ) } "
` : ` $ { e } : $ { o }
` }).join("").trim()}function Kt(r){let e;return(r==null?void 0:r.offset)!==null&&(r==null?void 0:r.offset)!==void 0&&typeof r.offset=="number"&&(e=window.moment.duration(r.offset,"days")),(r==null?void 0:r.format)?window.moment().add(e).format(r==null?void 0:r.format):window.moment().add(e).format("YYYY-MM-DD")}function We(r){let e=r;for(;at.test(e);){let t=at.exec(e),o=0;if(t==null?void 0:t[1]){let i=t[1].replace("+","").trim();Xt.test(i)&&(o=parseInt(i))}e=zt(e,at,Kt({offset:o}))}for(;lt.test(e);){let t=lt.exec(e),o=t==null?void 0:t[1],i=0;if(t==null?void 0:t[2]){let n=t[2].replace("+","").trim();Xt.test(n)&&(i=parseInt(n))}e=zt(e,lt,Kt({format:o,offset:i}))}return e}function zt(r,e,t){return r.replace(e,function(){return t})}var wr=q(require("obsidian"));var j="top",N="bottom",k="right",T="left",Ge="auto",oe=[j,N,k,T],J="start",pe="end",Qt="clippingParents",Ue="viewport",xe="popper",Jt="reference",ct=oe.reduce(function(r,e){return r.concat([e+"-"+J,e+"-"+pe])},[]),Xe=[].concat(oe,[Ge]).reduce(function(r,e){return r.concat([e,e+"-"+J,e+"-"+pe])},[]),Xr="beforeRead",qr="read",Yr="afterRead",Kr="beforeMain",zr="main",Qr="afterMain",Jr="beforeWrite",Zr="write",eo="afterWrite",Zt=[Xr,qr,Yr,Kr,zr,Qr,Jr,Zr,eo];function D(r){return r?(r.nodeName||"").toLowerCase():null}function B(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}function Q(r){var e=B(r).Element;return r instanceof e||r instanceof Element}function A(r){var e=B(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function Se(r){if(typeof ShadowRoot=="undefined")return!1;var e=B(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}function to(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var o=e.styles[t]||{},i=e.attributes[t]||{},n=e.elements[t];!A(n)||!D(n)||(Object.assign(n.style,o),Object.keys(i).forEach(function(s){var a=i[s];a===!1?n.removeAttribute(s):n.setAttribute(s,a===!0?"":a)}))})}function ro(r){var e=r.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(o){var i=e.elements[o],n=e.attributes[o]||{},s=Object.keys(e.styles.hasOwnProperty(o)?e.styles[o]:t[o]),a=s.reduce(function(l,u){return l[u]="",l},{});!A(i)||!D(i)||(Object.assign(i.style,a),Object.keys(n).forEach(function(l){i.removeAttribute(l)}))})}}var er={name:"applyStyles",enabled:!0,phase:"write",fn:to,effect:ro,requires:["computeStyles"]};function M(r){return r.split("-")[0]}var Y=Math.max,ce=Math.min,Z=Math.round;function G(r,e){e===void 0&&(e=!1);var t=r.getBoundingClientRect(),o=1,i=1;if(A(r)&&e){var n=r.offsetHeight,s=r.offsetWidth;s>0&&(o=Z(t.width)/s||1),n>0&&(i=Z(t.height)/n||1)}return{width:t.width/o,height:t.height/i,top:t.top/i,right:t.right/o,bottom:t.bottom/i,left:t.left/o,x:t.left/o,y:t.top/i}}function me(r){var e=G(r),t=r.offsetWidth,o=r.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-o)<=1&&(o=e.height),{x:r.offsetLeft,y:r.offsetTop,width:t,height:o}}function Ne(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&Se(t)){var o=e;do{if(o&&r.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function $ (r){return B(r).getComputedStyle(r)}function mt(r){return["table","td","th"].indexOf(D(r))>=0}function F(r){return((Q(r)?r.ownerDocument:r.document)||window.document).documentElement}function ee(r){return D(r)==="html"?r:r.assignedSlot||r.parentNode||(Se(r)?r.host:null)||F(r)}function tr(r){return!A(r)|| $ (r).position==="fixed"?null:r.offsetParent}function oo(r){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,t=navigator.userAgent.indexOf("Trident")!==-1;if(t&&A(r)){var o= $ (r);if(o.position==="fixed")return null}var i=ee(r);for(Se(i)&&(i=i.host);A(i)&&["html","body"].indexOf(D(i))<0;){var n= $ (i);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="p
$ { p }
-- -
$ { d } ` :d}return u})}downloadAndSaveImage(e,t,o){return h(this,null,function*(){let{enableCoverImageSave:i}=this.settings;if(!i)return console.warn("Cover image saving is not enabled."),"";try{let n=yield(0,ne.requestUrl)({url:o,method:"GET",headers:{Accept:"image/*"}});if(console.log(n.headers),n.status!==200)throw new Error( ` Failed to download image : $ { n . status } ` );let s=n.arrayBuffer,a= ` $ { t } / $ { e } ` ;return yield this.app.vault.adapter.writeBinary(a,s),a}catch(n){return console.error("Error downloading or saving image:",n),""}})}insertMetadata(){return h(this,null,function*(){try{let e=this.app.workspace.getActiveViewOfType(ne.MarkdownView);if(!e){console.warn("Can not find an active markdown view");return}let t=yield this.searchBookMetadata(e.file.basename);if(!e.editor){console.warn("Can not find editor from the active markdown view");return}let o=yield this.getRenderedContents(t);e.editor.replaceRange(o,{line:0,ch:0})}catch(e){console.warn(e),this.showNotice(e)}})}createNewBookNote(){return h(this,null,function*(){try{let e=yield this.searchBookMetadata(),t=yield this.getRenderedContents(e),o=pt(e,this.settings.fileNameFormat),i= ` $ { this . settings . folder } / $ { o } ` ,n=yield this.app.vault.create(i,t);yield Tr(this.app,n),this.openNewBookNote(n)}catch(e){console.warn(e),this.showNotice(e)}})}openNewBookNote(e){return h(this,null,function*(){if(!this.settings.openPageOnCompletion)return;let t=this.app.workspace.getLeaf();if(!t){console.warn("No active leaf");return}yield t.openFile(e,{state:{mode:"source"}}),t.setEphemeralState({rename:"all"}),yield new st(this.app).jumpToNextCursorLocation()})}openBookSearchModal(e=""){return h(this,null,function*(){return new Promise((t,o)=>new it(this,e,(i,n)=>i?o(i):t(n)).open())})}openBookSuggestModal(e){return h(this,null,function*(){return new Promise((t,o)=>new nt(this.app,this.settings.showCoverImageInSearch,e,(i,n)=>i?o(i):t(n)).open())})}loadSettings(){return h(this,null,function*(){this.settings=Object.assign({},Er,yield this.loadData())})}saveSettings(){return h(this,null,function*(){yield this.saveData(this.settings)})}};