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
41 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
*/
2 years ago
var Ir=Object.create;var ke=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames,Lt=Object.getOwnPropertySymbols,_r=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty,Vr=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))Vr.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})},Hr=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fr(e))!Ft.call(r,o)&&o!=="default"&&ke(r,o,{get:()=>e[o],enumerable:!(t=Lr(e,o))||t.enumerable});return r},U=r=>Hr(Vt(ke(r!=null?Ir(_r(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var d=(r,e,t)=>new Promise((o,i)=>{var n=l=>{try{a(t.next(l))}catch(c){i(c)}},s=l=>{try{a(t.throw(l))}catch(c){i(c)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,s);a((t=t.apply(r,e)).next())});$r(exports,{default:()=>Ot});var Ce=U(require("obsidian"));var oe=U(require("obsidian"));var N;(function(t){t.google="google",t.naver="naver"})(N||(N={}));var $t=U(require("obsidian"));var tt=class{getByQuery(e){return d(this,null,function*(){try{let t={q:e,maxResults:40,printType:"books"},o=window.moment.locale();o&&(t.langRestrict=o);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 xe({title:e.title,subtitle:e.subtitle,author:this.formatList(e.authors),category:this.formatList(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 rt=class{constructor(e,t){this.clientId=e;this.clientSecret=t}getByQuery(e){return d(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 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;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 d(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,$t.requestUrl)({url:i.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,this.callback=o,this.serviceProvider=Ht(e.settings)}setBusy(e){this.isBusy=e,this.okBtnRef.setDisabled(e),this.okBtnRef.se
`).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,""")}"
2 years ago
`:`${e}: ${o}
2 years ago
`}).join("").trim()}function zt(r){let e;return r.offset!==null&&r.offset!==void 0&&typeof r.offset=="number"&&(e=window.moment.duration(r.offset,"days")),r.format?window.moment().add(e).format(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;if(t[1]){let i=t[1].replace("+","").trim();Gt.test(i)&&(o=parseInt(i))}e=Kt(e,st,zt({offset:o}))}for(;at.test(e);){let t=at.exec(e),o=t[1],i;if(t[2]){let n=t[2].replace("+","").trim();Gt.test(n)&&(i=parseInt(n))}e=Kt(e,at,zt({format:o,offset:i}))}return e}function Kt(r,e,t){return r.replace(e,function(){return t})}var wr=U(require("obsidian"));var P="top",A="bottom",k="right",T="left",Xe="auto",ie=[P,A,k,T],Z="start",le="end",Qt="clippingParents",Ge="viewport",be="popper",Jt="reference",pt=ie.reduce(function(r,e){return r.concat([e+"-"+Z,e+"-"+le])},[]),qe=[].concat(ie,[Xe]).reduce(function(r,e){return r.concat([e,e+"-"+Z,e+"-"+le])},[]),Ur="beforeRead",Yr="read",zr="afterRead",Kr="beforeMain",Qr="main",Jr="afterMain",Zr="beforeWrite",eo="write",to="afterWrite",Zt=[Ur,Yr,zr,Kr,Qr,Jr,Zr,eo,to];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 D(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 ro(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];!D(n)||!M(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 oo(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,c){return l[c]="",l},{});!D(i)||!M(i)||(Object.assign(i.style,a),Object.keys(n).forEach(function(l){i.removeAttribute(l)}))})}}var er={name:"applyStyles",enabled:!0,phase:"write",fn:ro,effect:oo,requires:["computeStyles"]};function R(r){return r.split("-")[0]}var Y=Math.max,ce=Math.min,ee=Math.round;function W(r,e){e===void 0&&(e=!1);var t=r.getBoundingClientRect(),o=1,i=1;if(D(r)&&e){var n=r.offsetHeight,s=r.offsetWidth;s>0&&(o=ee(t.width)/s||1),n>0&&(i=ee(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=W(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 Ae(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 lt(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!D(r)||_(r).position==="fixed"?null:r.offsetParent}function io(r){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,t=navigator.userAgent.indexOf("Trident")!==-1;if(t&&D(r)){var o=_(r);if(o.position==="fixed")return null}var i=te(r);for(ye(i)&&(i=i.host);D(i)&&["html","body"].indexOf(M(i))<0;){var n=_(i);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||e&&n.willChange==="filter"||e&&n.filter&&n.filte
${a}
3 years ago
---
2 years ago
${l}`:l})}insertMetadata(){return d(this,null,function*(){try{let e=this.app.workspace.getActiveViewOfType(Ce.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 d(this,null,function*(){try{let e=yield this.searchBookMetadata(),t=this.app.workspace.getLeaf();if(!t){console.warn("No active leaf");return}let o=yield this.getRenderedContents(e),i=qt(e,this.settings.fileNameFormat),n=`${this.settings.folder}/${i}`,s=yield this.app.vault.create(n,o);yield t.openFile(s,{state:{mode:"source"}}),t.setEphemeralState({rename:"all"}),yield new nt(this.app).jumpToNextCursorLocation()}catch(e){console.warn(e),this.showNotice(e)}})}openBookSearchModal(e=""){return d(this,null,function*(){return new Promise((t,o)=>new ot(this,e,(i,n)=>i?o(i):t(n)).open())})}openBookSuggestModal(e){return d(this,null,function*(){return new Promise((t,o)=>new it(this.app,e,(i,n)=>i?o(i):t(n)).open())})}loadSettings(){return d(this,null,function*(){this.settings=Object.assign({},jr,yield this.loadData())})}saveSettings(){return d(this,null,function*(){yield this.saveData(this.settings)})}};