/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var ut = Object . defineProperty ; var Or = Object . getOwnPropertyDescriptor ; var Dr = Object . getOwnPropertyNames ; var Nr = Object . prototype . hasOwnProperty ; var Lr = ( r , e ) => { for ( var t in e ) ut ( r , t , { get : e [ t ] , enumerable : ! 0 } ) } , Rr = ( r , e , t , o ) => { if ( e && typeof e == "object" || typeof e == "function" ) for ( let i of Dr ( e ) ) ! Nr . call ( r , i ) && i !== t && ut ( r , i , { get : ( ) => e [ i ] , enumerable : ! ( o = Or ( e , i ) ) || o . enumerable } ) ; return r } ; var Fr = r => Rr ( ut ( { } , "__esModule" , { value : ! 0 } ) , r ) ; var Lo = { } ; Lr ( Lo , { default : ( ) => at } ) ; module . exports = Fr ( Lo ) ; var oe = require ( "obsidian" ) ; var Vt = require ( "obsidian" ) ; var we = class we { constructor ( e , t , o ) { this . localePreference = e ; this . enableCoverImageEdgeCurl = t ; this . apiKey = o } getLanguageRestriction ( e ) { return e === "default" ? window . moment . locale ( ) : e } buildSearchParams ( e , t ) { let o = { q : e , maxResults : we . MAX _RESULTS , printType : we . PRINT _TYPE , langRestrict : this . getLanguageRestriction ( ( t == null ? void 0 : t . locale ) || this . localePreference ) } ; return this . apiKey && ( o . key = this . apiKey ) , o } async getByQuery ( e , t ) { try { let o = this . buildSearchParams ( e , t ) , i = await Ue ( "https://www.googleapis.com/books/v1/volumes" , o ) ; return i != null && i . totalItems ? i . items . map ( ( { volumeInfo : n } ) => this . createBookItem ( n ) ) : [ ] } catch ( o ) { throw console . warn ( o ) , o } } extractISBNs ( e ) { var t ; return ( t = e == null ? void 0 : e . reduce ( ( o , i ) => { let n = i . type === "ISBN_10" ? "isbn10" : "isbn13" ; return o [ n ] = i . identifier . trim ( ) , o } , { } ) ) != null ? t : { } } extractBasicBookInfo ( e ) { var t , o , i , n ; return { 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 : this . setCoverImageEdgeCurl ( ( o = ( t = e . imageLinks ) == null ? void 0 : t . thumbnail ) != null ? o : "" , this . enableCoverImageEdgeCurl ) , coverSmallUrl : this . setCoverImageEdgeCurl ( ( n = ( i = e . imageLinks ) == null ? void 0 : i . smallThumbnail ) != null ? n : "" , this . enableCoverImageEdgeCurl ) , publishDate : e . publishedDate || "" , description : e . description , link : e . canonicalVolumeLink || e . infoLink , previewLink : e . previewLink } } createBookItem ( e ) { return { title : "" , subtitle : "" , author : "" , authors : [ ] , category : "" , categories : [ ] , publisher : "" , publishDate : "" , totalPage : "" , coverUrl : "" , coverSmallUrl : "" , description : "" , link : "" , previewLink : "" , ... this . extractBasicBookInfo ( e ) , ... this . extractISBNs ( e . industryIdentifiers ) } } formatList ( e ) { var t ; return e && e . length > 1 ? e . map ( o => o . trim ( ) ) . join ( ", " ) : ( t = e == null ? void 0 : e [ 0 ] ) != null ? t : "" } setCoverImageEdgeCurl ( e , t ) { return t ? e : e . replace ( "&edge=curl" , "" ) } static convertGoogleBookImageURLSize ( e , t ) { return e . replace ( /(&zoom)=\d/ , ` $ 1= ${ t } ` ) } } ; we . MAX _RESULTS = 40 , we . PRINT _TYPE = "books" ; var _e = we ; var We = class { constructor ( e , t ) { this . clientId = e ; this . clientSecret = t } async getByQuery ( e ) { try { let t = { query : e , display : 50 , sort : "sim" } , o = { "X-Naver-Client-Id" : this . clientId , "X-Naver-Client-Secret" : this . clientSecret } , i = await Ue ( "https://openapi.naver.com/v1/search/book.json" , t , o ) ; return i != null && i . total ? i . items . map ( this . createBookItem ) : [ ] } catch ( t ) { throw console . warn ( t ) , t } } createBookItem ( e ) { var t , o ; return { 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 } } } } ; var mt = class extends Error { constructor ( e ) { super ( e ) , this . name = "ConfigurationError" } } ; function _t ( r ) { switch ( r . serviceProvider ) { case "google" : return new _e ( r . localePreference , r . enableCoverImageEdgeCurl , r . apiKey ) ; case "naver" : return Mr ( r ) , new We ( r . naverClientId , r . naverClientSecret ) ; default : throw new Error ( "Unsupported service provider." ) } } function Mr ( r ) { if ( ! r . naverClientId || ! r . naverClientSecret ) throw new mt ( '\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.' ) } async function Ue ( r , e = { } , t ) { let o = new URL ( r ) ; return $r ( o , e ) , ( await ( 0 , Vt . requestUrl ) ( { url : o . href , method : "GET" , headers : { Accept : "*/*" , "Content-Type" : "application/json; charset=utf-8" , ... t } } ) ) . json } function $r ( r , e ) { Object . entries ( e ) . forEach ( ( [ t , o ] ) => { r . searchParams . append ( t , o . toString ( ) ) } ) } var Ut = /^-?[0-9]*$/ , dt = /{{DATE(\+-?[0-9]+)?}}/ , gt = / {
` ).map(e=>{var n,l;let t=e.indexOf(":");if(t===-1)return[e.trim(),""];let o=(n=e.slice(0,t))==null?void 0:n.trim(),i=(l=e.slice(t+1))==null?void 0:l.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 zt(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 Wt(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&&r.format?window.moment().add(e).format(r==null?void 0:r.format):window.moment().add(e).format("YYYY-MM-DD")}function Ge(r){let e=r;for(;dt.test(e);){let t=dt.exec(e),o=0;if(t!=null&&t[1]){let i=t[1].replace("+","").trim();Ut.test(i)&&(o=parseInt(i))}e=Gt(e,dt,Wt({offset:o}))}for(;gt.test(e);){let t=gt.exec(e),o=t==null?void 0:t[1],i=0;if(t!=null&&t[2]){let n=t[2].replace("+","").trim();Ut.test(n)&&(i=parseInt(n))}e=Gt(e,gt,Wt({format:o,offset:i}))}return e}function Gt(r,e,t){return r.replace(e,function(){return t})}var P=require("obsidian");var Ur={en:"English",af:"Afrikaans","ar-dz":"Arabic (Algeria)","ar-kw":"Arabic (Kuwait)","ar-ly":"Arabic (Libya)","ar-ma":"Arabic (Morocco)","ar-sa":"Arabic (Saudi Arabia)","ar-tn":"Arabic (Tunisia)",ar:"Arabic",az:"Azerbaijani",be:"Belarusian",bg:"Bulgarian",bm:"Bambara",bn:"Bengali",bo:"Tibetan",br:"Breton",bs:"Bosnian",ca:"Catalan",cs:"Czech",cv:"Chuvash",cy:"Welsh",da:"Danish","de-at":"German (Austria)","de-ch":"German (Switzerland)",de:"German",dv:"Divehi",el:"Greek","en-au":"English (Australia)","en-ca":"English (Canada)","en-gb":"English (United Kingdom)","en-ie":"English (Ireland)","en-nz":"English (New Zealand)",eo:"Esperanto","es-do":"Spanish (Dominican Republic)","es-us":"Spanish (United States)",es:"Spanish",et:"Estonian",eu:"Basque",fa:"Persian",fi:"Finnish",fo:"Faroese","fr-ca":"French (Canada)","fr-ch":"French (Switzerland)",fr:"French",fy:"Western Frisian",gd:"Scottish Gaelic",gl:"Galician","gom-latn":"gom (Latin)",gu:"Gujarati",he:"Hebrew",hi:"Hindi",hr:"Croatian",hu:"Hungarian","hy-am":"Armenian (Armenia)",id:"Indonesian",is:"Icelandic",it:"Italian",ja:"Japanese",jv:"Javanese",ka:"Georgian",kk:"Kazakh",km:"Khmer",kn:"Kannada",ko:"Korean",ky:"Kirghiz",lb:"Luxembourgish",lo:"Lao",lt:"Lithuanian",lv:"Latvian",me:"me",mi:"Maori",mk:"Macedonian",ml:"Malayalam",mr:"Marathi","ms-my":"Malay (Malaysia)",ms:"Malay",mt:"Maltese",my:"Burmese",nb:"Norwegian Bokm \x E5l",ne:"Nepali","nl-be":"Dutch (Belgium)",nl:"Dutch",nn:"Norwegian Nynorsk","pa-in":"Punjabi (India)",pl:"Polish","pt-br":"Portuguese (Brazil)",pt:"Portuguese",ro:"Romanian",ru:"Russian",sd:"Sindhi",se:"Northern Sami",si:"Sinhala",sk:"Slovak",sl:"Slovenian",sq:"Albanian","sr-cyrl":"Serbian (Cyrillic)",sr:"Serbian",ss:"Swati",sv:"Swedish",sw:"Swahili",ta:"Tamil",te:"Telugu",tet:"Tetum",th:"Thai","tl-ph":"Tagalog (Philippines)",tlh:"Klingon",tr:"Turkish",tzl:"tzl","tzm-latn":"tzm (Latin)",tzm:"tzm",uk:"Ukrainian",ur:"Urdu","uz-latn":"Uzbek (Latin)",uz:"Uzbek",vi:"Vietnamese","x-pseudo":"x-pseudo",yo:"Yoruba","zh-cn":"Chinese (China)","zh-hk":"Chinese (Hong Kong SAR China)","zh-tw":"Chinese (Taiwan)","zh-mo":"Chinese (Macau SAR China)"},ye=Ur;var be=require("obsidian"),Xe=class extends be.Modal{constructor(t,o){var i,n;super(t.app);this.callback=o;this.plugin=t,this.currentServiceProvider=(n=(i=t.settings)==null?void 0:i.serviceProvider)!=null?n:"google"}get settings(){return this.plugin.settings}async saveSetting(){return this.plugin.saveSettings()}saveClientId(t){this.currentServiceProvider==="naver"&&(this.plugin.settings.naverClientId=t)}saveClientSecret(t){this.currentServiceProvider==="naver"&&(this.settings.naverClientSecret=t)}get currentClientId(){return this.currentServiceProvider==="naver"?this.settings.naverClientId:""}get currentClientSecret(){return this.currentServiceProvider==="naver"?this.settings.naverClientSecret:""}onOpen(){let{contentEl:t}=this;t.createEl("h2",{text:"Service Provider Setting"}),new be.Setting(t).setName("Client ID").addText(o=>{o.setValue(this.currentClientId).onChange(i=>this.saveClientId(i))}),new be.Setting(t).setName("Client Secret").addText(o=>{o.setValue(this.currentClientSecret).onChange(i=>this.saveClientSecret(i))}),new be.Setting(t).addButton(o=>o.setButtonText("Save").setCta().onClick(async()=>{var i;await this.plugin.saveSettings(),this.close(),(i=this.callback)==null||i.call(thi
$ { p }
-- -
$ { d } ` :d}return u}async downloadAndSaveImage(e,t,o){let{enableCoverImageSave:i}=this.settings;if(!i)return console.warn("Cover image saving is not enabled."),"";try{let n=await(0,oe.requestUrl)({url:o,method:"GET",headers:{Accept:"image/*"}});if(n.status!==200)throw new Error( ` Failed to download image : $ { n . status } ` );let l=n.arrayBuffer,a= ` $ { t } / $ { e } ` ;return await this.app.vault.adapter.writeBinary(a,l),a}catch(n){return console.error("Error downloading or saving image:",n),""}}async insertMetadata(){try{let e=this.app.workspace.getActiveViewOfType(oe.MarkdownView);if(!e){console.warn("Can not find an active markdown view");return}let t=await this.searchBookMetadata(e.file.basename);if(!e.editor){console.warn("Can not find editor from the active markdown view");return}let o=await this.getRenderedContents(t);e.editor.replaceRange(o,{line:0,ch:0})}catch(e){console.warn(e),this.showNotice(e)}}async createNewBookNote(){try{let e=await this.searchBookMetadata(),t=await this.getRenderedContents(e),o=ht(e,this.settings.fileNameFormat),i= ` $ { this . settings . folder } / $ { o } ` ,n=await this.app.vault.create(i,t);await Cr(this.app,n),this.openNewBookNote(n)}catch(e){console.warn(e),this.showNotice(e)}}async openNewBookNote(e){if(!this.settings.openPageOnCompletion)return;let t=this.app.workspace.getLeaf();if(!t){console.warn("No active leaf");return}await t.openFile(e,{state:{mode:"source"}}),t.setEphemeralState({rename:"all"}),await new it(this.app).jumpToNextCursorLocation()}async openBookSearchModal(e=""){return new Promise((t,o)=>new rt(this,e,(i,n)=>i?o(i):t(n)).open())}async openBookSuggestModal(e){return new Promise((t,o)=>new ot(this.app,this.settings.showCoverImageInSearch,e,(i,n)=>i?o(i):t(n)).open())}async loadSettings(){this.settings=Object.assign({},Fe,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
/* nosourcemap */