You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
43 KiB

3 years ago
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var Fr=Object.create;var ke=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Vr=Object.getOwnPropertyNames,Lt=Object.getOwnPropertySymbols,$r=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty,Hr=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,xe=(r,e)=>{for(var t in e||(e={}))Ft.call(e,t)&&_t(r,t,e[t]);if(Lt)for(var t of Lt(e))Hr.call(e,t)&&_t(r,t,e[t]);return r};var Vt=r=>ke(r,"__esModule",{value:!0});var Wr=(r,e)=>{Vt(r);for(var t in e)ke(r,t,{get:e[t],enumerable:!0})},Xr=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vr(e))!Ft.call(r,o)&&o!=="default"&&ke(r,o,{get:()=>e[o],enumerable:!(t=_r(e,o))||t.enumerable});return r},q=r=>Xr(Vt(ke(r!=null?Fr($r(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var g=(r,e,t)=>new Promise((o,n)=>{var i=l=>{try{a(t.next(l))}catch(m){n(m)}},s=l=>{try{a(t.throw(l))}catch(m){n(m)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((t=t.apply(r,e)).next())});Wr(exports,{default:()=>Ot});var Pe=q(require("obsidian"));var oe=q(require("obsidian"));var N;(function(t){t.google="google",t.naver="naver"})(N||(N={}));var $t=q(require("obsidian"));var tt=class{constructor(e){this.localePreference=e}getByQuery(e){return g(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;let n=yield He("https://www.googleapis.com/books/v1/volumes",t);return(n==null?void 0:n.totalItems)?n.items.map(({volumeInfo:i})=>this.createBookItem(i)):[]}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,n,i,s;return xe({title:e.title,subtitle:e.subtitle,author:this.formatList(e.authors),authors:e.authors,category:this.formatList(e.categories),publisher:e.publisher,totalPage:e.pageCount,coverUrl:(n=(o=e.imageLinks)==null?void 0:o.thumbnail)!=null?n:"",coverSmallUrl:(s=(i=e.imageLinks)==null?void 0:i.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(n=>`${n.trim()}`).join(", "):(o=(t=e==null?void 0:e[0])==null?void 0:t.replace("N/A",""))!=null?o:""}};var rt=class{constructor(e,t){this.clientId=e;this.clientSecret=t}getByQuery(e){return g(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},n=yield He("https://openapi.naver.com/v1/search/book.json",t,o);return(n==null?void 0:n.total)?n.items.map(this.createBookItem):[]}catch(t){throw console.warn(t),t}})}createBookItem(e){var t,o;return xe({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 Ht(r){if(r.serviceProvider===N.google)return new tt(r.localePreference);if(r.serviceProvider===N.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 rt(r.naverClientId,r.naverClientSecret)}}function He(o){return g(this,arguments,function*(r,e={},t){let n=new URL(r);return Object.entries(e).forEach(([s,a])=>{n.searchParams.append(s,a==null?void 0:a.toString())}),(yield(0,$t.requestUrl)({url:n.href,method:"GET",headers:xe({Accept:"*/*","Content-Type":"application/json; charset=utf-8"},t)})).json})}var ot=class extends oe.Modal{constructor(e,t,o){super(e.app);this.query=t
2 years ago
`).map(e=>{var i,s;let t=e.indexOf(":");if(t===-1)return[e.trim(),""];let o=(i=e.slice(0,t))==null?void 0:i.trim(),n=(s=e.slice(t+1))==null?void 0:s.trim();return[o,n]}).reduce((e,[t,o])=>{var n;return t&&(e[t]=(n=o==null?void 0:o.trim())!=null?n:""),e},{}):{}}function Yt(r){return Object.entries(r).map(([e,t])=>{var n;let o=(n=t==null?void 0:t.toString().trim())!=null?n:"";return/\r|\n/.test(o)?"":/:\s/.test(o)?`${e}: "${o.replace(/"/g,""")}"
2 years ago
`:`${e}: ${o}
`}).join("").trim()}function zt(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(;st.test(e);){let t=st.exec(e),o=0;if(t==null?void 0:t[1]){let n=t[1].replace("+","").trim();Gt.test(n)&&(o=parseInt(n))}e=Kt(e,st,zt({offset:o}))}for(;at.test(e);){let t=at.exec(e),o=t==null?void 0:t[1],n=0;if(t==null?void 0:t[2]){let i=t[2].replace("+","").trim();Gt.test(i)&&(n=parseInt(i))}e=Kt(e,at,zt({format:o,offset:n}))}return e}function Kt(r,e,t){return r.replace(e,function(){return t})}var wr=q(require("obsidian"));var C="top",D="bottom",k="right",T="left",Xe="auto",ne=[C,D,k,T],Z="start",pe="end",Qt="clippingParents",Ge="viewport",be="popper",Jt="reference",lt=ne.reduce(function(r,e){return r.concat([e+"-"+Z,e+"-"+pe])},[]),Ue=[].concat(ne,[Xe]).reduce(function(r,e){return r.concat([e,e+"-"+Z,e+"-"+pe])},[]),zr="beforeRead",Kr="read",Qr="afterRead",Jr="beforeMain",Zr="main",eo="afterMain",to="beforeWrite",ro="write",oo="afterWrite",Zt=[zr,Kr,Qr,Jr,Zr,eo,to,ro,oo];function M(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 J(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 ye(r){if(typeof ShadowRoot=="undefined")return!1;var e=B(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}function no(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var o=e.styles[t]||{},n=e.attributes[t]||{},i=e.elements[t];!A(i)||!M(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(s){var a=n[s];a===!1?i.removeAttribute(s):i.setAttribute(s,a===!0?"":a)}))})}function io(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 n=e.elements[o],i=e.attributes[o]||{},s=Object.keys(e.styles.hasOwnProperty(o)?e.styles[o]:t[o]),a=s.reduce(function(l,m){return l[m]="",l},{});!A(n)||!M(n)||(Object.assign(n.style,a),Object.keys(i).forEach(function(l){n.removeAttribute(l)}))})}}var er={name:"applyStyles",enabled:!0,phase:"write",fn:no,effect:io,requires:["computeStyles"]};function I(r){return r.split("-")[0]}var Y=Math.max,ce=Math.min,ee=Math.round;function X(r,e){e===void 0&&(e=!1);var t=r.getBoundingClientRect(),o=1,n=1;if(A(r)&&e){var i=r.offsetHeight,s=r.offsetWidth;s>0&&(o=ee(t.width)/s||1),i>0&&(n=ee(t.height)/i||1)}return{width:t.width/o,height:t.height/n,top:t.top/n,right:t.right/o,bottom:t.bottom/n,left:t.left/o,x:t.left/o,y:t.top/n}}function ue(r){var e=X(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 De(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&ye(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 pt(r){return["table","td","th"].indexOf(M(r))>=0}function F(r){return((J(r)?r.ownerDocument:r.document)||window.document).documentElement}function te(r){return M(r)==="html"?r:r.assignedSlot||r.parentNode||(ye(r)?r.host:null)||F(r)}function tr(r){return!A(r)||_(r).position==="fixed"?null:r.offsetParent}function so(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 n=te(r);for(ye(n)&&(n=n.host);A(n)&&["html","body"].indexOf(M(n))<0;){var i=_(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==
2 years ago
${a}
3 years ago
---
${l}`:l})}insertMetadata(){return g(this,null,function*(){try{let e=this.app.workspace.getActiveViewOfType(Pe.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 g(this,null,function*(){try{let e=yield this.searchBookMetadata(),t=yield this.getRenderedContents(e),o=Ut(e,this.settings.fileNameFormat),n=`${this.settings.folder}/${o}`,i=yield this.app.vault.create(n,t);yield Nr(this.app,i),this.openNewBookNote(i)}catch(e){console.warn(e),this.showNotice(e)}})}openNewBookNote(e){return g(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 it(this.app).jumpToNextCursorLocation()})}openBookSearchModal(e=""){return g(this,null,function*(){return new Promise((t,o)=>new ot(this,e,(n,i)=>n?o(n):t(i)).open())})}openBookSuggestModal(e){return g(this,null,function*(){return new Promise((t,o)=>new nt(this.app,e,(n,i)=>n?o(n):t(i)).open())})}loadSettings(){return g(this,null,function*(){this.settings=Object.assign({},jr,yield this.loadData())})}saveSettings(){return g(this,null,function*(){yield this.saveData(this.settings)})}};