From eb1036826abcbd6f2dfb56bf8b95053b7507ce30 Mon Sep 17 00:00:00 2001 From: sradics Date: Sun, 4 May 2025 17:49:18 +0200 Subject: [PATCH] Adjustments for Obsidian commit --- main.js | 4 +- main.ts | 143 +++++++++++++++++++---------------------------------- styles.css | 14 +++--- 3 files changed, 61 insertions(+), 100 deletions(-) diff --git a/main.js b/main.js index a821e49..98e1b4d 100644 --- a/main.js +++ b/main.js @@ -3,8 +3,8 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ -var Dt=Object.create;var wt=Object.defineProperty;var Pt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var jt=(g,T)=>()=>(T||g((T={exports:{}}).exports,T),T.exports),Wt=(g,T)=>{for(var p in T)wt(g,p,{get:T[p],enumerable:!0})},At=(g,T,p,a)=>{if(T&&typeof T=="object"||typeof T=="function")for(let s of Ut(T))!Lt.call(g,s)&&s!==p&&wt(g,s,{get:()=>T[s],enumerable:!(a=Pt(T,s))||a.enumerable});return g};var Zt=(g,T,p)=>(p=g!=null?Dt(Nt(g)):{},At(T||!g||!g.__esModule?wt(p,"default",{value:g,enumerable:!0}):p,g)),Mt=g=>At(wt({},"__esModule",{value:!0}),g);var Ft=jt((It,kt)=>{(function(g){typeof It=="object"&&typeof kt!="undefined"?kt.exports=g():typeof define=="function"&&define.amd?define([],g):(typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this).JSZip=g()})(function(){return function g(T,p,a){function s(b,y){if(!p[b]){if(!T[b]){var m=typeof require=="function"&&require;if(!y&&m)return m(b,!0);if(r)return r(b,!0);var w=new Error("Cannot find module '"+b+"'");throw w.code="MODULE_NOT_FOUND",w}var i=p[b]={exports:{}};T[b][0].call(i.exports,function(f){var n=T[b][1][f];return s(n||f)},i,i.exports,g,T,p,a)}return p[b].exports}for(var r=typeof require=="function"&&require,h=0;h>2,i=(3&b)<<4|y>>4,f=1>6:64,n=2>4,y=(15&w)<<4|(i=r.indexOf(h.charAt(n++)))>>2,m=(3&i)<<6|(f=r.indexOf(h.charAt(n++))),d[u++]=b,i!==64&&(d[u++]=y),f!==64&&(d[u++]=m);return d}},{"./support":30,"./utils":32}],2:[function(g,T,p){"use strict";var a=g("./external"),s=g("./stream/DataWorker"),r=g("./stream/Crc32Probe"),h=g("./stream/DataLengthProbe");function b(y,m,w,i,f){this.compressedSize=y,this.uncompressedSize=m,this.crc32=w,this.compression=i,this.compressedContent=f}b.prototype={getContentWorker:function(){var y=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new h("data_length")),m=this;return y.on("end",function(){if(this.streamInfo.data_length!==m.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),y},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},b.createWorkerFrom=function(y,m,w){return y.pipe(new r).pipe(new h("uncompressedSize")).pipe(m.compressWorker(w)).pipe(new h("compressedSize")).withStreamInfo("compression",m)},T.exports=b},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(g,T,p){"use strict";var a=g("./stream/GenericWorker");p.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},p.DEFLATE=g("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(g,T,p){"use strict";var a=g("./utils"),s=function(){for(var r,h=[],b=0;b<256;b++){r=b;for(var y=0;y<8;y++)r=1&r?3988292384^r>>>1:r>>>1;h[b]=r}return h}();T.exports=function(r,h){return r!==void 0&&r.length?a.getTypeOf(r)!=="string"?function(b,y,m,w){var i=s,f=w+m;b^=-1;for(var n=w;n>>8^i[255&(b^y[n])];return-1^b}(0|h,r,r.length,0):function(b,y,m,w){var i=s,f=w+m;b^=-1;for(var n=w;n>>8^i[255&(b^y.charCodeAt(n))];return-1^b}(0|h,r,r.length,0):0}},{"./utils":32}],5:[function(g,T,p){"use strict";p.base64=!1,p.binary=!1,p.dir=!1,p.createFolders=!0,p.date=null,p.compression=null,p.compressionOptions=null,p.comment=null,p.unixPermissions=null,p.dosPermissions=null},{}],6:[function(g,T,p){"use strict";var a=null;a=typeof Promise!="undefined"?Promise:g("lie"),T.exports={Promise:a}},{lie:37}],7:[function(g,T,p){"use strict";var a=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Uint32Array!="undefined",s=g("pako"),r=g("./utils"),h=g("./stream/GenericWorker"),b=a?"uint8array":"array";function y(m,w){h.call(this,"FlateWorker/"+m),this._pako=null,this._pakoAction=m,this._pakoOptions=w,this.meta={}}p.magic="\b\0",r.inherits(y,h),y.prototype.processChunk=function(m){this.meta=m.meta,this._pako===null&&this._createPako(),this._pako.push(r.transformTo(b,m.data),!1)},y.prototype.flush=function(){h.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},y.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},y.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var m=this;this._pako.onData=function(w){m.push({data:w,meta:m.meta})}},p.compressWorker=function(m){return new y("Deflate",m)},p.uncompressWorker=function(){return new y("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(g,T,p){"use strict";function a(i,f){var n,u="";for(n=0;n>>=8;return u}function s(i,f,n,u,o,d){var v,S,x=i.file,R=i.compression,F=d!==b.utf8encode,N=r.transformTo("string",d(x.name)),I=r.transformTo("string",b.utf8encode(x.name)),M=x.comment,X=r.transformTo("string",d(M)),_=r.transformTo("string",b.utf8encode(M)),O=I.length!==x.name.length,e=_.length!==M.length,D="",q="",L="",Q=x.dir,j=x.date,V={crc32:0,compressedSize:0,uncompressedSize:0};f&&!n||(V.crc32=i.crc32,V.compressedSize=i.compressedSize,V.uncompressedSize=i.uncompressedSize);var z=0;f&&(z|=8),F||!O&&!e||(z|=2048);var E=0,Y=0;Q&&(E|=16),o==="UNIX"?(Y=798,E|=function(H,it){var lt=H;return H||(lt=it?16893:33204),(65535<)<<16}(x.unixPermissions,Q)):(Y=20,E|=function(H){return 63&(H||0)}(x.dosPermissions)),v=j.getUTCHours(),v<<=6,v|=j.getUTCMinutes(),v<<=5,v|=j.getUTCSeconds()/2,S=j.getUTCFullYear()-1980,S<<=4,S|=j.getUTCMonth()+1,S<<=5,S|=j.getUTCDate(),O&&(q=a(1,1)+a(y(N),4)+I,D+="up"+a(q.length,2)+q),e&&(L=a(1,1)+a(y(X),4)+_,D+="uc"+a(L.length,2)+L);var $="";return $+=` -\0`,$+=a(z,2),$+=R.magic,$+=a(v,2),$+=a(S,2),$+=a(V.crc32,4),$+=a(V.compressedSize,4),$+=a(V.uncompressedSize,4),$+=a(N.length,2),$+=a(D.length,2),{fileRecord:m.LOCAL_FILE_HEADER+$+N+D,dirRecord:m.CENTRAL_FILE_HEADER+a(Y,2)+$+a(X.length,2)+"\0\0\0\0"+a(E,4)+a(u,4)+N+D+X}}var r=g("../utils"),h=g("../stream/GenericWorker"),b=g("../utf8"),y=g("../crc32"),m=g("../signature");function w(i,f,n,u){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=n,this.encodeFileName=u,this.streamFiles=i,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(w,h),w.prototype.push=function(i){var f=i.meta.percent||0,n=this.entriesCount,u=this._sources.length;this.accumulate?this.contentBuffer.push(i):(this.bytesWritten+=i.data.length,h.prototype.push.call(this,{data:i.data,meta:{currentFile:this.currentFile,percent:n?(f+100*(n-u-1))/n:100}}))},w.prototype.openedSource=function(i){this.currentSourceOffset=this.bytesWritten,this.currentFile=i.file.name;var f=this.streamFiles&&!i.file.dir;if(f){var n=s(i,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},w.prototype.closedSource=function(i){this.accumulate=!1;var f=this.streamFiles&&!i.file.dir,n=s(i,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),f)this.push({data:function(u){return m.DATA_DESCRIPTOR+a(u.crc32,4)+a(u.compressedSize,4)+a(u.uncompressedSize,4)}(i),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},w.prototype.flush=function(){for(var i=this.bytesWritten,f=0;f=this.index;h--)b=(b<<8)+this.byteAt(h);return this.index+=r,b},readString:function(r){return a.transformTo("string",this.readData(r))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var r=this.readInt(4);return new Date(Date.UTC(1980+(r>>25&127),(r>>21&15)-1,r>>16&31,r>>11&31,r>>5&63,(31&r)<<1))}},T.exports=s},{"../utils":32}],19:[function(g,T,p){"use strict";var a=g("./Uint8ArrayReader");function s(r){a.call(this,r)}g("../utils").inherits(s,a),s.prototype.readData=function(r){this.checkOffset(r);var h=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,h},T.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(g,T,p){"use strict";var a=g("./DataReader");function s(r){a.call(this,r)}g("../utils").inherits(s,a),s.prototype.byteAt=function(r){return this.data.charCodeAt(this.zero+r)},s.prototype.lastIndexOfSignature=function(r){return this.data.lastIndexOf(r)-this.zero},s.prototype.readAndCheckSignature=function(r){return r===this.readData(4)},s.prototype.readData=function(r){this.checkOffset(r);var h=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,h},T.exports=s},{"../utils":32,"./DataReader":18}],21:[function(g,T,p){"use strict";var a=g("./ArrayReader");function s(r){a.call(this,r)}g("../utils").inherits(s,a),s.prototype.readData=function(r){if(this.checkOffset(r),r===0)return new Uint8Array(0);var h=this.data.subarray(this.zero+this.index,this.zero+this.index+r);return this.index+=r,h},T.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(g,T,p){"use strict";var a=g("../utils"),s=g("../support"),r=g("./ArrayReader"),h=g("./StringReader"),b=g("./NodeBufferReader"),y=g("./Uint8ArrayReader");T.exports=function(m){var w=a.getTypeOf(m);return a.checkSupport(w),w!=="string"||s.uint8array?w==="nodebuffer"?new b(m):s.uint8array?new y(a.transformTo("uint8array",m)):new r(a.transformTo("array",m)):new h(m)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(g,T,p){"use strict";p.LOCAL_FILE_HEADER="PK",p.CENTRAL_FILE_HEADER="PK",p.CENTRAL_DIRECTORY_END="PK",p.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",p.ZIP64_CENTRAL_DIRECTORY_END="PK",p.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(g,T,p){"use strict";var a=g("./GenericWorker"),s=g("../utils");function r(h){a.call(this,"ConvertWorker to "+h),this.destType=h}s.inherits(r,a),r.prototype.processChunk=function(h){this.push({data:s.transformTo(this.destType,h.data),meta:h.meta})},T.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(g,T,p){"use strict";var a=g("./GenericWorker"),s=g("../crc32");function r(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g("../utils").inherits(r,a),r.prototype.processChunk=function(h){this.streamInfo.crc32=s(h.data,this.streamInfo.crc32||0),this.push(h)},T.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(g,T,p){"use strict";var a=g("../utils"),s=g("./GenericWorker");function r(h){s.call(this,"DataLengthProbe for "+h),this.propName=h,this.withStreamInfo(h,0)}a.inherits(r,s),r.prototype.processChunk=function(h){if(h){var b=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=b+h.data.length}s.prototype.processChunk.call(this,h)},T.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(g,T,p){"use strict";var a=g("../utils"),s=g("./GenericWorker");function r(h){s.call(this,"DataWorker");var b=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,h.then(function(y){b.dataIsReady=!0,b.data=y,b.max=y&&y.length||0,b.type=a.getTypeOf(y),b.isPaused||b._tickAndRepeat()},function(y){b.error(y)})}a.inherits(r,s),r.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var h=null,b=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":h=this.data.substring(this.index,b);break;case"uint8array":h=this.data.subarray(this.index,b);break;case"array":case"nodebuffer":h=this.data.slice(this.index,b)}return this.index=b,this.push({data:h,meta:{percent:this.max?this.index/this.max*100:0}})},T.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(g,T,p){"use strict";function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,r){return this._listeners[s].push(r),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,r){if(this._listeners[s])for(var h=0;h "+s:s}},T.exports=a},{}],29:[function(g,T,p){"use strict";var a=g("../utils"),s=g("./ConvertWorker"),r=g("./GenericWorker"),h=g("../base64"),b=g("../support"),y=g("../external"),m=null;if(b.nodestream)try{m=g("../nodejs/NodejsStreamOutputAdapter")}catch(f){}function w(f,n){return new y.Promise(function(u,o){var d=[],v=f._internalType,S=f._outputType,x=f._mimeType;f.on("data",function(R,F){d.push(R),n&&n(F)}).on("error",function(R){d=[],o(R)}).on("end",function(){try{var R=function(F,N,I){switch(F){case"blob":return a.newBlob(a.transformTo("arraybuffer",N),I);case"base64":return h.encode(N);default:return a.transformTo(F,N)}}(S,function(F,N){var I,M=0,X=null,_=0;for(I=0;I>>6:(u<65536?n[v++]=224|u>>>12:(n[v++]=240|u>>>18,n[v++]=128|u>>>12&63),n[v++]=128|u>>>6&63),n[v++]=128|63&u);return n}(i)},p.utf8decode=function(i){return s.nodebuffer?a.transformTo("nodebuffer",i).toString("utf-8"):function(f){var n,u,o,d,v=f.length,S=new Array(2*v);for(n=u=0;n>10&1023,S[u++]=56320|1023&o)}return S.length!==u&&(S.subarray?S=S.subarray(0,u):S.length=u),a.applyFromCharCode(S)}(i=a.transformTo(s.uint8array?"uint8array":"array",i))},a.inherits(m,h),m.prototype.processChunk=function(i){var f=a.transformTo(s.uint8array?"uint8array":"array",i.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var n=f;(f=new Uint8Array(n.length+this.leftOver.length)).set(this.leftOver,0),f.set(n,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var u=function(d,v){var S;for((v=v||d.length)>d.length&&(v=d.length),S=v-1;0<=S&&(192&d[S])==128;)S--;return S<0||S===0?v:S+b[d[S]]>v?S:v}(f),o=f;u!==f.length&&(s.uint8array?(o=f.subarray(0,u),this.leftOver=f.subarray(u,f.length)):(o=f.slice(0,u),this.leftOver=f.slice(u,f.length))),this.push({data:p.utf8decode(o),meta:i.meta})},m.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:p.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},p.Utf8DecodeWorker=m,a.inherits(w,h),w.prototype.processChunk=function(i){this.push({data:p.utf8encode(i.data),meta:i.meta})},p.Utf8EncodeWorker=w},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(g,T,p){"use strict";var a=g("./support"),s=g("./base64"),r=g("./nodejsUtils"),h=g("./external");function b(n){return n}function y(n,u){for(var o=0;o>8;this.dir=!!(16&this.externalFileAttributes),i==0&&(this.dosPermissions=63&this.externalFileAttributes),i==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var i=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=i.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=i.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=i.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=i.readInt(4))}},readExtraFields:function(i){var f,n,u,o=i.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});i.index+4>>6:(i<65536?w[u++]=224|i>>>12:(w[u++]=240|i>>>18,w[u++]=128|i>>>12&63),w[u++]=128|i>>>6&63),w[u++]=128|63&i);return w},p.buf2binstring=function(m){return y(m,m.length)},p.binstring2buf=function(m){for(var w=new a.Buf8(m.length),i=0,f=w.length;i>10&1023,d[f++]=56320|1023&n)}return y(d,f)},p.utf8border=function(m,w){var i;for((w=w||m.length)>m.length&&(w=m.length),i=w-1;0<=i&&(192&m[i])==128;)i--;return i<0||i===0?w:i+h[m[i]]>w?i:w}},{"./common":41}],43:[function(g,T,p){"use strict";T.exports=function(a,s,r,h){for(var b=65535&a|0,y=a>>>16&65535|0,m=0;r!==0;){for(r-=m=2e3>>1:s>>>1;r[h]=s}return r}();T.exports=function(s,r,h,b){var y=a,m=b+h;s^=-1;for(var w=b;w>>8^y[255&(s^r[w])];return-1^s}},{}],46:[function(g,T,p){"use strict";var a,s=g("../utils/common"),r=g("./trees"),h=g("./adler32"),b=g("./crc32"),y=g("./messages"),m=0,w=4,i=0,f=-2,n=-1,u=4,o=2,d=8,v=9,S=286,x=30,R=19,F=2*S+1,N=15,I=3,M=258,X=M+I+1,_=42,O=113,e=1,D=2,q=3,L=4;function Q(t,B){return t.msg=y[B],B}function j(t){return(t<<1)-(4t.avail_out&&(A=t.avail_out),A!==0&&(s.arraySet(t.output,B.pending_buf,B.pending_out,A,t.next_out),t.next_out+=A,B.pending_out+=A,t.total_out+=A,t.avail_out-=A,B.pending-=A,B.pending===0&&(B.pending_out=0))}function E(t,B){r._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,B),t.block_start=t.strstart,z(t.strm)}function Y(t,B){t.pending_buf[t.pending++]=B}function $(t,B){t.pending_buf[t.pending++]=B>>>8&255,t.pending_buf[t.pending++]=255&B}function H(t,B){var A,c,l=t.max_chain_length,k=t.strstart,P=t.prev_length,U=t.nice_match,C=t.strstart>t.w_size-X?t.strstart-(t.w_size-X):0,W=t.window,G=t.w_mask,Z=t.prev,K=t.strstart+M,nt=W[k+P-1],et=W[k+P];t.prev_length>=t.good_match&&(l>>=2),U>t.lookahead&&(U=t.lookahead);do if(W[(A=B)+P]===et&&W[A+P-1]===nt&&W[A]===W[k]&&W[++A]===W[k+1]){k+=2,A++;do;while(W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&kC&&--l!=0);return P<=t.lookahead?P:t.lookahead}function it(t){var B,A,c,l,k,P,U,C,W,G,Z=t.w_size;do{if(l=t.window_size-t.lookahead-t.strstart,t.strstart>=Z+(Z-X)){for(s.arraySet(t.window,t.window,Z,Z,0),t.match_start-=Z,t.strstart-=Z,t.block_start-=Z,B=A=t.hash_size;c=t.head[--B],t.head[B]=Z<=c?c-Z:0,--A;);for(B=A=Z;c=t.prev[--B],t.prev[B]=Z<=c?c-Z:0,--A;);l+=Z}if(t.strm.avail_in===0)break;if(P=t.strm,U=t.window,C=t.strstart+t.lookahead,W=l,G=void 0,G=P.avail_in,W=I)for(k=t.strstart-t.insert,t.ins_h=t.window[k],t.ins_h=(t.ins_h<=I&&(t.ins_h=(t.ins_h<=I)if(c=r._tr_tally(t,t.strstart-t.match_start,t.match_length-I),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=I){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=I&&(t.ins_h=(t.ins_h<=I&&t.match_length<=t.prev_length){for(l=t.strstart+t.lookahead-I,c=r._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-I),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=l&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(A=t.pending_buf_size-5);;){if(t.lookahead<=1){if(it(t),t.lookahead===0&&B===m)return e;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var c=t.block_start+A;if((t.strstart===0||t.strstart>=c)&&(t.lookahead=t.strstart-c,t.strstart=c,E(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-X&&(E(t,!1),t.strm.avail_out===0))return e}return t.insert=0,B===w?(E(t,!0),t.strm.avail_out===0?q:L):(t.strstart>t.block_start&&(E(t,!1),t.strm.avail_out),e)}),new rt(4,4,8,4,lt),new rt(4,5,16,8,lt),new rt(4,6,32,32,lt),new rt(4,4,16,16,tt),new rt(8,16,32,32,tt),new rt(8,16,128,128,tt),new rt(8,32,128,256,tt),new rt(32,128,258,1024,tt),new rt(32,258,258,4096,tt)],p.deflateInit=function(t,B){return ut(t,B,d,15,8,0)},p.deflateInit2=ut,p.deflateReset=ct,p.deflateResetKeep=st,p.deflateSetHeader=function(t,B){return t&&t.state?t.state.wrap!==2?f:(t.state.gzhead=B,i):f},p.deflate=function(t,B){var A,c,l,k;if(!t||!t.state||5>8&255),Y(c,c.gzhead.time>>16&255),Y(c,c.gzhead.time>>24&255),Y(c,c.level===9?2:2<=c.strategy||c.level<2?4:0),Y(c,255&c.gzhead.os),c.gzhead.extra&&c.gzhead.extra.length&&(Y(c,255&c.gzhead.extra.length),Y(c,c.gzhead.extra.length>>8&255)),c.gzhead.hcrc&&(t.adler=b(t.adler,c.pending_buf,c.pending,0)),c.gzindex=0,c.status=69):(Y(c,0),Y(c,0),Y(c,0),Y(c,0),Y(c,0),Y(c,c.level===9?2:2<=c.strategy||c.level<2?4:0),Y(c,3),c.status=O);else{var P=d+(c.w_bits-8<<4)<<8;P|=(2<=c.strategy||c.level<2?0:c.level<6?1:c.level===6?2:3)<<6,c.strstart!==0&&(P|=32),P+=31-P%31,c.status=O,$(c,P),c.strstart!==0&&($(c,t.adler>>>16),$(c,65535&t.adler)),t.adler=1}if(c.status===69)if(c.gzhead.extra){for(l=c.pending;c.gzindex<(65535&c.gzhead.extra.length)&&(c.pending!==c.pending_buf_size||(c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),z(t),l=c.pending,c.pending!==c.pending_buf_size));)Y(c,255&c.gzhead.extra[c.gzindex]),c.gzindex++;c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),c.gzindex===c.gzhead.extra.length&&(c.gzindex=0,c.status=73)}else c.status=73;if(c.status===73)if(c.gzhead.name){l=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),z(t),l=c.pending,c.pending===c.pending_buf_size)){k=1;break}k=c.gzindexl&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),k===0&&(c.gzindex=0,c.status=91)}else c.status=91;if(c.status===91)if(c.gzhead.comment){l=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),z(t),l=c.pending,c.pending===c.pending_buf_size)){k=1;break}k=c.gzindexl&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),k===0&&(c.status=103)}else c.status=103;if(c.status===103&&(c.gzhead.hcrc?(c.pending+2>c.pending_buf_size&&z(t),c.pending+2<=c.pending_buf_size&&(Y(c,255&t.adler),Y(c,t.adler>>8&255),t.adler=0,c.status=O)):c.status=O),c.pending!==0){if(z(t),t.avail_out===0)return c.last_flush=-1,i}else if(t.avail_in===0&&j(B)<=j(A)&&B!==w)return Q(t,-5);if(c.status===666&&t.avail_in!==0)return Q(t,-5);if(t.avail_in!==0||c.lookahead!==0||B!==m&&c.status!==666){var U=c.strategy===2?function(C,W){for(var G;;){if(C.lookahead===0&&(it(C),C.lookahead===0)){if(W===m)return e;break}if(C.match_length=0,G=r._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++,G&&(E(C,!1),C.strm.avail_out===0))return e}return C.insert=0,W===w?(E(C,!0),C.strm.avail_out===0?q:L):C.last_lit&&(E(C,!1),C.strm.avail_out===0)?e:D}(c,B):c.strategy===3?function(C,W){for(var G,Z,K,nt,et=C.window;;){if(C.lookahead<=M){if(it(C),C.lookahead<=M&&W===m)return e;if(C.lookahead===0)break}if(C.match_length=0,C.lookahead>=I&&0C.lookahead&&(C.match_length=C.lookahead)}if(C.match_length>=I?(G=r._tr_tally(C,1,C.match_length-I),C.lookahead-=C.match_length,C.strstart+=C.match_length,C.match_length=0):(G=r._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++),G&&(E(C,!1),C.strm.avail_out===0))return e}return C.insert=0,W===w?(E(C,!0),C.strm.avail_out===0?q:L):C.last_lit&&(E(C,!1),C.strm.avail_out===0)?e:D}(c,B):a[c.level].func(c,B);if(U!==q&&U!==L||(c.status=666),U===e||U===q)return t.avail_out===0&&(c.last_flush=-1),i;if(U===D&&(B===1?r._tr_align(c):B!==5&&(r._tr_stored_block(c,0,0,!1),B===3&&(V(c.head),c.lookahead===0&&(c.strstart=0,c.block_start=0,c.insert=0))),z(t),t.avail_out===0))return c.last_flush=-1,i}return B!==w?i:c.wrap<=0?1:(c.wrap===2?(Y(c,255&t.adler),Y(c,t.adler>>8&255),Y(c,t.adler>>16&255),Y(c,t.adler>>24&255),Y(c,255&t.total_in),Y(c,t.total_in>>8&255),Y(c,t.total_in>>16&255),Y(c,t.total_in>>24&255)):($(c,t.adler>>>16),$(c,65535&t.adler)),z(t),0=A.w_size&&(k===0&&(V(A.head),A.strstart=0,A.block_start=0,A.insert=0),W=new s.Buf8(A.w_size),s.arraySet(W,B,G-A.w_size,A.w_size,0),B=W,G=A.w_size),P=t.avail_in,U=t.next_in,C=t.input,t.avail_in=G,t.next_in=0,t.input=B,it(A);A.lookahead>=I;){for(c=A.strstart,l=A.lookahead-(I-1);A.ins_h=(A.ins_h<>>=I=N>>>24,v-=I,(I=N>>>16&255)===0)D[y++]=65535&N;else{if(!(16&I)){if(!(64&I)){N=S[(65535&N)+(d&(1<>>=I,v-=I),v<15&&(d+=e[h++]<>>=I=N>>>24,v-=I,!(16&(I=N>>>16&255))){if(!(64&I)){N=x[(65535&N)+(d&(1<>>=I,v-=I,(I=y-m)>3,d&=(1<<(v-=M<<3))-1,a.next_in=h,a.next_out=y,a.avail_in=h>>24&255)+(_>>>8&65280)+((65280&_)<<8)+((255&_)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(_){var O;return _&&_.state?(O=_.state,_.total_in=_.total_out=O.total=0,_.msg="",O.wrap&&(_.adler=1&O.wrap),O.mode=f,O.last=0,O.havedict=0,O.dmax=32768,O.head=null,O.hold=0,O.bits=0,O.lencode=O.lendyn=new a.Buf32(n),O.distcode=O.distdyn=new a.Buf32(u),O.sane=1,O.back=-1,w):i}function S(_){var O;return _&&_.state?((O=_.state).wsize=0,O.whave=0,O.wnext=0,v(_)):i}function x(_,O){var e,D;return _&&_.state?(D=_.state,O<0?(e=0,O=-O):(e=1+(O>>4),O<48&&(O&=15)),O&&(O<8||15=L.wsize?(a.arraySet(L.window,O,e-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(D<(q=L.wsize-L.wnext)&&(q=D),a.arraySet(L.window,O,e-D,q,L.wnext),(D-=q)?(a.arraySet(L.window,O,e-D,D,0),L.wnext=D,L.whave=L.wsize):(L.wnext+=q,L.wnext===L.wsize&&(L.wnext=0),L.whave>>8&255,e.check=r(e.check,k,2,0),E=z=0,e.mode=2;break}if(e.flags=0,e.head&&(e.head.done=!1),!(1&e.wrap)||(((255&z)<<8)+(z>>8))%31){_.msg="incorrect header check",e.mode=30;break}if((15&z)!=8){_.msg="unknown compression method",e.mode=30;break}if(E-=4,t=8+(15&(z>>>=4)),e.wbits===0)e.wbits=t;else if(t>e.wbits){_.msg="invalid window size",e.mode=30;break}e.dmax=1<>8&1),512&e.flags&&(k[0]=255&z,k[1]=z>>>8&255,e.check=r(e.check,k,2,0)),E=z=0,e.mode=3;case 3:for(;E<32;){if(j===0)break t;j--,z+=D[L++]<>>8&255,k[2]=z>>>16&255,k[3]=z>>>24&255,e.check=r(e.check,k,4,0)),E=z=0,e.mode=4;case 4:for(;E<16;){if(j===0)break t;j--,z+=D[L++]<>8),512&e.flags&&(k[0]=255&z,k[1]=z>>>8&255,e.check=r(e.check,k,2,0)),E=z=0,e.mode=5;case 5:if(1024&e.flags){for(;E<16;){if(j===0)break t;j--,z+=D[L++]<>>8&255,e.check=r(e.check,k,2,0)),E=z=0}else e.head&&(e.head.extra=null);e.mode=6;case 6:if(1024&e.flags&&(j<(H=e.length)&&(H=j),H&&(e.head&&(t=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Array(e.head.extra_len)),a.arraySet(e.head.extra,D,L,H,t)),512&e.flags&&(e.check=r(e.check,D,H,L)),j-=H,L+=H,e.length-=H),e.length))break t;e.length=0,e.mode=7;case 7:if(2048&e.flags){if(j===0)break t;for(H=0;t=D[L+H++],e.head&&t&&e.length<65536&&(e.head.name+=String.fromCharCode(t)),t&&H>9&1,e.head.done=!0),_.adler=e.check=0,e.mode=12;break;case 10:for(;E<32;){if(j===0)break t;j--,z+=D[L++]<>>=7&E,E-=7&E,e.mode=27;break}for(;E<3;){if(j===0)break t;j--,z+=D[L++]<>>=1)){case 0:e.mode=14;break;case 1:if(M(e),e.mode=20,O!==6)break;z>>>=2,E-=2;break t;case 2:e.mode=17;break;case 3:_.msg="invalid block type",e.mode=30}z>>>=2,E-=2;break;case 14:for(z>>>=7&E,E-=7&E;E<32;){if(j===0)break t;j--,z+=D[L++]<>>16^65535)){_.msg="invalid stored block lengths",e.mode=30;break}if(e.length=65535&z,E=z=0,e.mode=15,O===6)break t;case 15:e.mode=16;case 16:if(H=e.length){if(j>>=5,E-=5,e.ndist=1+(31&z),z>>>=5,E-=5,e.ncode=4+(15&z),z>>>=4,E-=4,286>>=3,E-=3}for(;e.have<19;)e.lens[P[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},B=b(0,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,B){_.msg="invalid code lengths set",e.mode=30;break}e.have=0,e.mode=19;case 19:for(;e.have>>16&255,ot=65535&l,!((tt=l>>>24)<=E);){if(j===0)break t;j--,z+=D[L++]<>>=tt,E-=tt,e.lens[e.have++]=ot;else{if(ot===16){for(c=tt+2;E>>=tt,E-=tt,e.have===0){_.msg="invalid bit length repeat",e.mode=30;break}t=e.lens[e.have-1],H=3+(3&z),z>>>=2,E-=2}else if(ot===17){for(c=tt+3;E>>=tt)),z>>>=3,E-=3}else{for(c=tt+7;E>>=tt)),z>>>=7,E-=7}if(e.have+H>e.nlen+e.ndist){_.msg="invalid bit length repeat",e.mode=30;break}for(;H--;)e.lens[e.have++]=t}}if(e.mode===30)break;if(e.lens[256]===0){_.msg="invalid code -- missing end-of-block",e.mode=30;break}if(e.lenbits=9,A={bits:e.lenbits},B=b(y,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,B){_.msg="invalid literal/lengths set",e.mode=30;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},B=b(m,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,B){_.msg="invalid distances set",e.mode=30;break}if(e.mode=20,O===6)break t;case 20:e.mode=21;case 21:if(6<=j&&258<=V){_.next_out=Q,_.avail_out=V,_.next_in=L,_.avail_in=j,e.hold=z,e.bits=E,h(_,$),Q=_.next_out,q=_.output,V=_.avail_out,L=_.next_in,D=_.input,j=_.avail_in,z=e.hold,E=e.bits,e.mode===12&&(e.back=-1);break}for(e.back=0;rt=(l=e.lencode[z&(1<>>16&255,ot=65535&l,!((tt=l>>>24)<=E);){if(j===0)break t;j--,z+=D[L++]<>st)])>>>16&255,ot=65535&l,!(st+(tt=l>>>24)<=E);){if(j===0)break t;j--,z+=D[L++]<>>=st,E-=st,e.back+=st}if(z>>>=tt,E-=tt,e.back+=tt,e.length=ot,rt===0){e.mode=26;break}if(32&rt){e.back=-1,e.mode=12;break}if(64&rt){_.msg="invalid literal/length code",e.mode=30;break}e.extra=15&rt,e.mode=22;case 22:if(e.extra){for(c=e.extra;E>>=e.extra,E-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=23;case 23:for(;rt=(l=e.distcode[z&(1<>>16&255,ot=65535&l,!((tt=l>>>24)<=E);){if(j===0)break t;j--,z+=D[L++]<>st)])>>>16&255,ot=65535&l,!(st+(tt=l>>>24)<=E);){if(j===0)break t;j--,z+=D[L++]<>>=st,E-=st,e.back+=st}if(z>>>=tt,E-=tt,e.back+=tt,64&rt){_.msg="invalid distance code",e.mode=30;break}e.offset=ot,e.extra=15&rt,e.mode=24;case 24:if(e.extra){for(c=e.extra;E>>=e.extra,E-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){_.msg="invalid distance too far back",e.mode=30;break}e.mode=25;case 25:if(V===0)break t;if(H=$-V,e.offset>H){if((H=e.offset-H)>e.whave&&e.sane){_.msg="invalid distance too far back",e.mode=30;break}it=H>e.wnext?(H-=e.wnext,e.wsize-H):e.wnext-H,H>e.length&&(H=e.length),lt=e.window}else lt=q,it=Q-e.offset,H=e.length;for(VF?(I=it[lt+u[O]],E[Y+u[O]]):(I=96,0),d=1<<_-Q,e=v=1<>Q)+(v-=d)]=N<<24|I<<16|M|0,v!==0;);for(d=1<<_-1;z&d;)d>>=1;if(d!==0?(z&=d-1,z+=d):z=0,O++,--$[_]==0){if(_===D)break;_=m[w+u[O]]}if(q<_&&(z&x)!==S){for(Q===0&&(Q=q),R+=e,j=1<<(L=_-Q);L+Q>>7)]}function Y(l,k){l.pending_buf[l.pending++]=255&k,l.pending_buf[l.pending++]=k>>>8&255}function $(l,k,P){l.bi_valid>o-P?(l.bi_buf|=k<>o-l.bi_valid,l.bi_valid+=P-o):(l.bi_buf|=k<>>=1,P<<=1,0<--k;);return P>>>1}function lt(l,k,P){var U,C,W=new Array(u+1),G=0;for(U=1;U<=u;U++)W[U]=G=G+P[U-1]<<1;for(C=0;C<=k;C++){var Z=l[2*C+1];Z!==0&&(l[2*C]=it(W[Z]++,Z))}}function tt(l){var k;for(k=0;k>1;1<=P;P--)st(l,W,P);for(C=K;P=l.heap[1],l.heap[1]=l.heap[l.heap_len--],st(l,W,1),U=l.heap[1],l.heap[--l.heap_max]=P,l.heap[--l.heap_max]=U,W[2*C]=W[2*P]+W[2*U],l.depth[C]=(l.depth[P]>=l.depth[U]?l.depth[P]:l.depth[U])+1,W[2*P+1]=W[2*U+1]=C,l.heap[1]=C++,st(l,W,1),2<=l.heap_len;);l.heap[--l.heap_max]=l.heap[1],function(et,ht){var pt,dt,mt,at,_t,yt,ft=ht.dyn_tree,Et=ht.max_code,Tt=ht.stat_desc.static_tree,Bt=ht.stat_desc.has_stree,Rt=ht.stat_desc.extra_bits,zt=ht.stat_desc.extra_base,gt=ht.stat_desc.max_length,bt=0;for(at=0;at<=u;at++)et.bl_count[at]=0;for(ft[2*et.heap[et.heap_max]+1]=0,pt=et.heap_max+1;pt>=7;C>>=1)if(1&nt&&Z.dyn_ltree[2*K]!==0)return s;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return r;for(K=32;K>>3,(W=l.static_len+3+7>>>3)<=C&&(C=W)):C=W=P+5,P+4<=C&&k!==-1?c(l,k,P,U):l.strategy===4||W===C?($(l,2+(U?1:0),3),ct(l,X,_)):($(l,4+(U?1:0),3),function(Z,K,nt,et){var ht;for($(Z,K-257,5),$(Z,nt-1,5),$(Z,et-4,4),ht=0;ht>>8&255,l.pending_buf[l.d_buf+2*l.last_lit+1]=255&k,l.pending_buf[l.l_buf+l.last_lit]=255&P,l.last_lit++,k===0?l.dyn_ltree[2*P]++:(l.matches++,k--,l.dyn_ltree[2*(e[P]+m+1)]++,l.dyn_dtree[2*E(k)]++),l.last_lit===l.lit_bufsize-1},p._tr_align=function(l){$(l,2,3),H(l,v,X),function(k){k.bi_valid===16?(Y(k,k.bi_buf),k.bi_buf=0,k.bi_valid=0):8<=k.bi_valid&&(k.pending_buf[k.pending++]=255&k.bi_buf,k.bi_buf>>=8,k.bi_valid-=8)}(l)}},{"../utils/common":41}],53:[function(g,T,p){"use strict";T.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(g,T,p){(function(a){(function(s,r){"use strict";if(!s.setImmediate){var h,b,y,m,w=1,i={},f=!1,n=s.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(s);u=u&&u.setTimeout?u:s,h={}.toString.call(s.process)==="[object process]"?function(S){process.nextTick(function(){d(S)})}:function(){if(s.postMessage&&!s.importScripts){var S=!0,x=s.onmessage;return s.onmessage=function(){S=!1},s.postMessage("","*"),s.onmessage=x,S}}()?(m="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",v,!1):s.attachEvent("onmessage",v),function(S){s.postMessage(m+S,"*")}):s.MessageChannel?((y=new MessageChannel).port1.onmessage=function(S){d(S.data)},function(S){y.port2.postMessage(S)}):n&&"onreadystatechange"in n.createElement("script")?(b=n.documentElement,function(S){var x=n.createElement("script");x.onreadystatechange=function(){d(S),x.onreadystatechange=null,b.removeChild(x),x=null},b.appendChild(x)}):function(S){setTimeout(d,0,S)},u.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var x=new Array(arguments.length-1),R=0;Rvt});module.exports=Mt($t);var J=require("obsidian"),Ot=Zt(Ft()),Ht={targetFolder:"Course Modules"},xt=class extends J.Modal{constructor(p,a){super(p);this.result="";this.onSubmit=a}onOpen(){let{contentEl:p}=this;p.empty(),p.createEl("h2",{text:"Enter Course Module URL"}),new J.Setting(p).setName("URL").addText(a=>a.onChange(s=>{this.result=s.trim()}).inputEl.focus()),new J.Setting(p).addButton(a=>a.setButtonText("Download and Unzip").setCta().onClick(()=>{this.result?(this.close(),this.onSubmit(this.result)):new J.Notice("Please enter a URL.")})),p.addEventListener("keypress",a=>{a.key==="Enter"&&(a.preventDefault(),this.result?(this.close(),this.onSubmit(this.result)):new J.Notice("Please enter a URL."))})}onClose(){let{contentEl:p}=this;p.empty()}},St=class extends J.FuzzySuggestModal{constructor(p,a,s,r){super(p);this.plugin=a,this.settingDisplayElement=s,this.preFetchedFolders=r,this.setPlaceholder("Search for a folder..."),console.log("FolderSuggestModal: Initialized with pre-fetched list containing",r.length,"folders.")}getItems(){if(this.preFetchedFolders)return console.log("FolderSuggestModal: Using pre-fetched folder list."),this.preFetchedFolders;console.warn("FolderSuggestModal: Pre-fetched list not available, fetching manually.");let p=this.app.vault.getAllLoadedFiles().filter(s=>s instanceof J.TFolder),a=this.app.vault.getRoot();return p.some(s=>s.path==="/")||p.unshift(a),p}getItemText(p){return p.path==="/"?"/ (Vault Root)":p.path}onChooseItem(p,a){let s=p.path;this.plugin.settings.targetFolder=s,this.plugin.saveSettings(),new J.Notice(`Target folder set to: ${s}`),this.settingDisplayElement.value=s}renderSuggestion(p,a){if(super.renderSuggestion(p,a),p.item.path==="/"){let s=a.querySelector(".suggestion-content");s?s.textContent="/ (Vault Root)":a.setText("/ (Vault Root)")}}},Ct=class extends J.PluginSettingTab{constructor(p,a){super(p,a);this.plugin=a}display(){let{containerEl:p}=this;p.empty(),p.createEl("h2",{text:"Course Material Downloader Settings"});let a=new J.Setting(p).setName("Target Folder").setDesc("The folder where downloaded modules will be unzipped.");a.addText(s=>{s.setValue(this.plugin.settings.targetFolder).setDisabled(!0),s.inputEl.style.width="100%",s.inputEl.style.marginRight="10px";let r=s.inputEl;a.addButton(h=>{h.setButtonText("Change Folder").onClick(()=>{console.log("Settings Tab: 'Change Folder' clicked. Fetching folder list...");let b=this.app.vault.getAllLoadedFiles().filter(m=>m instanceof J.TFolder),y=this.app.vault.getRoot();b.some(m=>m.path==="/")||b.unshift(y),console.log("Settings Tab: Passing",b.length,"folders to modal."),new St(this.app,this.plugin,r,b).open()})})}),p.createEl("p",{text:"Note: If the desired folder doesn't exist, it will be created during the download process (if possible)."})}},vt=class extends J.Plugin{async onload(){console.log("Loading Course Material Downloader Plugin"),await this.loadSettings(),this.addCommand({id:"download-course-module",name:"Download and Unzip Course Module",callback:()=>{this.showUrlInputModal()}}),this.addSettingTab(new Ct(this.app,this))}onunload(){console.log("Unloading Course Material Downloader Plugin")}async loadSettings(){this.settings=Object.assign({},Ht,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async ensureFolderExists(p){if(p==="/"||p==="")return this.app.vault.getRoot();let a=p.replace(/^\/|\/$/g,"");if(a==="")return this.app.vault.getRoot();try{let s=this.app.vault.getAbstractFileByPath(a);if(s instanceof J.TFolder)return s;if(s instanceof J.TFile)return console.error(`Cannot create folder '${a}', a file with this name already exists.`),new J.Notice(`Cannot create folder '${a}', a file exists there.`),null;console.log(`Attempting to create folder: ${a}`);try{let r=await this.app.vault.createFolder(a);return new J.Notice(`Created folder: ${a}`),r}catch(r){console.error(`Error creating folder '${a}':`,r);let h=this.app.vault.getAbstractFileByPath(a);return h instanceof J.TFolder?(console.log(`Folder '${a}' found after initial creation attempt failed.`),h):(new J.Notice(`Error creating folder '${a}'. Check console.`),null)}}catch(s){return console.error(`Unexpected error ensuring folder exists '${a}':`,s),new J.Notice(`Unexpected error checking folder '${a}'. Check console.`),null}}showUrlInputModal(){new xt(this.app,p=>{this.downloadAndUnzip(p)}).open()}async downloadAndUnzip(p){var b,y;if(!p.startsWith("http://")&&!p.startsWith("https://")){new J.Notice("Invalid URL received. Must start with http:// or https://");return}p=p.replace("www.dropbox.com","dl.dropboxusercontent.com"),p.includes("dropbox.com")&&!p.includes("dl=1")&&(p=p.includes("?")?`${p}&dl=1`:`${p}?dl=1`);let a=this.settings.targetFolder,s=await this.ensureFolderExists(a);if(!s){new J.Notice(`Target folder "${a}" could not be found or created. Aborting.`);return}let r=s.path==="/"?"":s.path,h;try{new J.Notice("Downloading module..."),console.log(`Requesting URL: ${p}`),h=(await(0,J.requestUrl)({url:p})).arrayBuffer,new J.Notice("Download complete. Unzipping..."),console.log(`Downloaded ${h.byteLength} bytes.`)}catch(m){console.error("Download Error:",m),new J.Notice(`Failed to download file: ${m.message}. Check console (Ctrl+Shift+I or Cmd+Opt+I).`);return}try{let m=await Ot.default.loadAsync(h),w=0,i=new Set;for(let f in m.files){let n=f.split("/").pop();if(f.startsWith("__MACOSX/")||n===".DS_Store"||!f){f.startsWith("__MACOSX/")&&console.log(`Ignoring macOS metadata folder: ${f}`),n===".DS_Store"&&console.log(`Ignoring .DS_Store file: ${f}`);continue}let u=m.files[f],d=(r?`${r}/${f}`:f).replace(/\\/g,"/").replace(/\/+/g,"/");if(u.dir){let v=d.endsWith("/")?d.slice(0,-1):d;v&&!i.has(v)&&(await this.ensureFolderExists(v)?i.add(v):console.warn(`Could not ensure directory exists: ${v}. Skipping contents.`))}else{let v=await u.async("arraybuffer"),S=d.lastIndexOf("/"),x=S>0?d.substring(0,S):S===0?"/":"";if(x&&x!==r&&!i.has(x))if(await this.ensureFolderExists(x))i.add(x);else{console.warn(`Could not ensure parent directory exists: ${x}. Skipping file: ${d}`);continue}let R=d.startsWith("/")?d.substring(1):d;if(R===""&&d==="/"){console.warn("Attempting to check root path '/' for a file. Skipping.");continue}let F=R?this.app.vault.getAbstractFileByPath(R):null;if(F instanceof J.TFile){console.log(`Skipping extraction for existing file: ${d}`);continue}else if(F instanceof J.TFolder){console.error(`Skipping file write: A folder exists at path ${d}`),new J.Notice(`Skipping file write: Folder exists at ${d}`);continue}else try{console.log(`Creating new file: ${d}`),await this.app.vault.createBinary(d,v,{mtime:Date.now()}),w++}catch(N){(b=N.message)!=null&&b.toLowerCase().includes("file already exists")?console.warn(`Caught 'File already exists' on createBinary for ${d}. Skipping.`):(console.error(`Error creating file '${d}':`,N),new J.Notice(`Error creating file '${d}'. Check console.`))}}}new J.Notice(`Successfully extracted ${w} new file(s) to '${s.path}'.`),console.log(`Extraction complete to folder: ${s.path}`)}catch(m){console.error("Unzip/Write Error:",m),(y=m.message)!=null&&y.toLowerCase().includes("file already exists")?(console.warn("Caught 'File already exists' error during unzip/write phase, possibly handled. Check logic if files were missed."),new J.Notice("An unexpected 'File already exists' error occurred during processing. Some files might not have been processed correctly. Check console.")):new J.Notice(`Failed to unzip or write files: ${m.message}. Check console.`)}}}; +var Dt=Object.create;var vt=Object.defineProperty;var Pt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var jt=(_,T)=>()=>(T||_((T={exports:{}}).exports,T),T.exports),Wt=(_,T)=>{for(var p in T)vt(_,p,{get:T[p],enumerable:!0})},At=(_,T,p,a)=>{if(T&&typeof T=="object"||typeof T=="function")for(let s of Ut(T))!Lt.call(_,s)&&s!==p&&vt(_,s,{get:()=>T[s],enumerable:!(a=Pt(T,s))||a.enumerable});return _};var Zt=(_,T,p)=>(p=_!=null?Dt(Nt(_)):{},At(T||!_||!_.__esModule?vt(p,"default",{value:_,enumerable:!0}):p,_)),Mt=_=>At(vt({},"__esModule",{value:!0}),_);var Ot=jt((It,kt)=>{(function(_){typeof It=="object"&&typeof kt!="undefined"?kt.exports=_():typeof define=="function"&&define.amd?define([],_):(typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this).JSZip=_()})(function(){return function _(T,p,a){function s(b,y){if(!p[b]){if(!T[b]){var m=typeof require=="function"&&require;if(!y&&m)return m(b,!0);if(r)return r(b,!0);var v=new Error("Cannot find module '"+b+"'");throw v.code="MODULE_NOT_FOUND",v}var i=p[b]={exports:{}};T[b][0].call(i.exports,function(f){var n=T[b][1][f];return s(n||f)},i,i.exports,_,T,p,a)}return p[b].exports}for(var r=typeof require=="function"&&require,h=0;h>2,i=(3&b)<<4|y>>4,f=1>6:64,n=2>4,y=(15&v)<<4|(i=r.indexOf(h.charAt(n++)))>>2,m=(3&i)<<6|(f=r.indexOf(h.charAt(n++))),d[u++]=b,i!==64&&(d[u++]=y),f!==64&&(d[u++]=m);return d}},{"./support":30,"./utils":32}],2:[function(_,T,p){"use strict";var a=_("./external"),s=_("./stream/DataWorker"),r=_("./stream/Crc32Probe"),h=_("./stream/DataLengthProbe");function b(y,m,v,i,f){this.compressedSize=y,this.uncompressedSize=m,this.crc32=v,this.compression=i,this.compressedContent=f}b.prototype={getContentWorker:function(){var y=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new h("data_length")),m=this;return y.on("end",function(){if(this.streamInfo.data_length!==m.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),y},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},b.createWorkerFrom=function(y,m,v){return y.pipe(new r).pipe(new h("uncompressedSize")).pipe(m.compressWorker(v)).pipe(new h("compressedSize")).withStreamInfo("compression",m)},T.exports=b},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(_,T,p){"use strict";var a=_("./stream/GenericWorker");p.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},p.DEFLATE=_("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(_,T,p){"use strict";var a=_("./utils"),s=function(){for(var r,h=[],b=0;b<256;b++){r=b;for(var y=0;y<8;y++)r=1&r?3988292384^r>>>1:r>>>1;h[b]=r}return h}();T.exports=function(r,h){return r!==void 0&&r.length?a.getTypeOf(r)!=="string"?function(b,y,m,v){var i=s,f=v+m;b^=-1;for(var n=v;n>>8^i[255&(b^y[n])];return-1^b}(0|h,r,r.length,0):function(b,y,m,v){var i=s,f=v+m;b^=-1;for(var n=v;n>>8^i[255&(b^y.charCodeAt(n))];return-1^b}(0|h,r,r.length,0):0}},{"./utils":32}],5:[function(_,T,p){"use strict";p.base64=!1,p.binary=!1,p.dir=!1,p.createFolders=!0,p.date=null,p.compression=null,p.compressionOptions=null,p.comment=null,p.unixPermissions=null,p.dosPermissions=null},{}],6:[function(_,T,p){"use strict";var a=null;a=typeof Promise!="undefined"?Promise:_("lie"),T.exports={Promise:a}},{lie:37}],7:[function(_,T,p){"use strict";var a=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Uint32Array!="undefined",s=_("pako"),r=_("./utils"),h=_("./stream/GenericWorker"),b=a?"uint8array":"array";function y(m,v){h.call(this,"FlateWorker/"+m),this._pako=null,this._pakoAction=m,this._pakoOptions=v,this.meta={}}p.magic="\b\0",r.inherits(y,h),y.prototype.processChunk=function(m){this.meta=m.meta,this._pako===null&&this._createPako(),this._pako.push(r.transformTo(b,m.data),!1)},y.prototype.flush=function(){h.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},y.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},y.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var m=this;this._pako.onData=function(v){m.push({data:v,meta:m.meta})}},p.compressWorker=function(m){return new y("Deflate",m)},p.uncompressWorker=function(){return new y("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(_,T,p){"use strict";function a(i,f){var n,u="";for(n=0;n>>=8;return u}function s(i,f,n,u,o,d){var w,S,x=i.file,R=i.compression,O=d!==b.utf8encode,N=r.transformTo("string",d(x.name)),I=r.transformTo("string",b.utf8encode(x.name)),M=x.comment,X=r.transformTo("string",d(M)),g=r.transformTo("string",b.utf8encode(M)),F=I.length!==x.name.length,e=g.length!==M.length,D="",q="",L="",Q=x.dir,j=x.date,V={crc32:0,compressedSize:0,uncompressedSize:0};f&&!n||(V.crc32=i.crc32,V.compressedSize=i.compressedSize,V.uncompressedSize=i.uncompressedSize);var E=0;f&&(E|=8),O||!F&&!e||(E|=2048);var z=0,Y=0;Q&&(z|=16),o==="UNIX"?(Y=798,z|=function(H,it){var lt=H;return H||(lt=it?16893:33204),(65535<)<<16}(x.unixPermissions,Q)):(Y=20,z|=function(H){return 63&(H||0)}(x.dosPermissions)),w=j.getUTCHours(),w<<=6,w|=j.getUTCMinutes(),w<<=5,w|=j.getUTCSeconds()/2,S=j.getUTCFullYear()-1980,S<<=4,S|=j.getUTCMonth()+1,S<<=5,S|=j.getUTCDate(),F&&(q=a(1,1)+a(y(N),4)+I,D+="up"+a(q.length,2)+q),e&&(L=a(1,1)+a(y(X),4)+g,D+="uc"+a(L.length,2)+L);var G="";return G+=` +\0`,G+=a(E,2),G+=R.magic,G+=a(w,2),G+=a(S,2),G+=a(V.crc32,4),G+=a(V.compressedSize,4),G+=a(V.uncompressedSize,4),G+=a(N.length,2),G+=a(D.length,2),{fileRecord:m.LOCAL_FILE_HEADER+G+N+D,dirRecord:m.CENTRAL_FILE_HEADER+a(Y,2)+G+a(X.length,2)+"\0\0\0\0"+a(z,4)+a(u,4)+N+D+X}}var r=_("../utils"),h=_("../stream/GenericWorker"),b=_("../utf8"),y=_("../crc32"),m=_("../signature");function v(i,f,n,u){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=n,this.encodeFileName=u,this.streamFiles=i,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(v,h),v.prototype.push=function(i){var f=i.meta.percent||0,n=this.entriesCount,u=this._sources.length;this.accumulate?this.contentBuffer.push(i):(this.bytesWritten+=i.data.length,h.prototype.push.call(this,{data:i.data,meta:{currentFile:this.currentFile,percent:n?(f+100*(n-u-1))/n:100}}))},v.prototype.openedSource=function(i){this.currentSourceOffset=this.bytesWritten,this.currentFile=i.file.name;var f=this.streamFiles&&!i.file.dir;if(f){var n=s(i,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},v.prototype.closedSource=function(i){this.accumulate=!1;var f=this.streamFiles&&!i.file.dir,n=s(i,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),f)this.push({data:function(u){return m.DATA_DESCRIPTOR+a(u.crc32,4)+a(u.compressedSize,4)+a(u.uncompressedSize,4)}(i),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},v.prototype.flush=function(){for(var i=this.bytesWritten,f=0;f=this.index;h--)b=(b<<8)+this.byteAt(h);return this.index+=r,b},readString:function(r){return a.transformTo("string",this.readData(r))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var r=this.readInt(4);return new Date(Date.UTC(1980+(r>>25&127),(r>>21&15)-1,r>>16&31,r>>11&31,r>>5&63,(31&r)<<1))}},T.exports=s},{"../utils":32}],19:[function(_,T,p){"use strict";var a=_("./Uint8ArrayReader");function s(r){a.call(this,r)}_("../utils").inherits(s,a),s.prototype.readData=function(r){this.checkOffset(r);var h=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,h},T.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(_,T,p){"use strict";var a=_("./DataReader");function s(r){a.call(this,r)}_("../utils").inherits(s,a),s.prototype.byteAt=function(r){return this.data.charCodeAt(this.zero+r)},s.prototype.lastIndexOfSignature=function(r){return this.data.lastIndexOf(r)-this.zero},s.prototype.readAndCheckSignature=function(r){return r===this.readData(4)},s.prototype.readData=function(r){this.checkOffset(r);var h=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,h},T.exports=s},{"../utils":32,"./DataReader":18}],21:[function(_,T,p){"use strict";var a=_("./ArrayReader");function s(r){a.call(this,r)}_("../utils").inherits(s,a),s.prototype.readData=function(r){if(this.checkOffset(r),r===0)return new Uint8Array(0);var h=this.data.subarray(this.zero+this.index,this.zero+this.index+r);return this.index+=r,h},T.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(_,T,p){"use strict";var a=_("../utils"),s=_("../support"),r=_("./ArrayReader"),h=_("./StringReader"),b=_("./NodeBufferReader"),y=_("./Uint8ArrayReader");T.exports=function(m){var v=a.getTypeOf(m);return a.checkSupport(v),v!=="string"||s.uint8array?v==="nodebuffer"?new b(m):s.uint8array?new y(a.transformTo("uint8array",m)):new r(a.transformTo("array",m)):new h(m)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(_,T,p){"use strict";p.LOCAL_FILE_HEADER="PK",p.CENTRAL_FILE_HEADER="PK",p.CENTRAL_DIRECTORY_END="PK",p.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",p.ZIP64_CENTRAL_DIRECTORY_END="PK",p.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(_,T,p){"use strict";var a=_("./GenericWorker"),s=_("../utils");function r(h){a.call(this,"ConvertWorker to "+h),this.destType=h}s.inherits(r,a),r.prototype.processChunk=function(h){this.push({data:s.transformTo(this.destType,h.data),meta:h.meta})},T.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(_,T,p){"use strict";var a=_("./GenericWorker"),s=_("../crc32");function r(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}_("../utils").inherits(r,a),r.prototype.processChunk=function(h){this.streamInfo.crc32=s(h.data,this.streamInfo.crc32||0),this.push(h)},T.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(_,T,p){"use strict";var a=_("../utils"),s=_("./GenericWorker");function r(h){s.call(this,"DataLengthProbe for "+h),this.propName=h,this.withStreamInfo(h,0)}a.inherits(r,s),r.prototype.processChunk=function(h){if(h){var b=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=b+h.data.length}s.prototype.processChunk.call(this,h)},T.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(_,T,p){"use strict";var a=_("../utils"),s=_("./GenericWorker");function r(h){s.call(this,"DataWorker");var b=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,h.then(function(y){b.dataIsReady=!0,b.data=y,b.max=y&&y.length||0,b.type=a.getTypeOf(y),b.isPaused||b._tickAndRepeat()},function(y){b.error(y)})}a.inherits(r,s),r.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var h=null,b=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":h=this.data.substring(this.index,b);break;case"uint8array":h=this.data.subarray(this.index,b);break;case"array":case"nodebuffer":h=this.data.slice(this.index,b)}return this.index=b,this.push({data:h,meta:{percent:this.max?this.index/this.max*100:0}})},T.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(_,T,p){"use strict";function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,r){return this._listeners[s].push(r),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,r){if(this._listeners[s])for(var h=0;h "+s:s}},T.exports=a},{}],29:[function(_,T,p){"use strict";var a=_("../utils"),s=_("./ConvertWorker"),r=_("./GenericWorker"),h=_("../base64"),b=_("../support"),y=_("../external"),m=null;if(b.nodestream)try{m=_("../nodejs/NodejsStreamOutputAdapter")}catch(f){}function v(f,n){return new y.Promise(function(u,o){var d=[],w=f._internalType,S=f._outputType,x=f._mimeType;f.on("data",function(R,O){d.push(R),n&&n(O)}).on("error",function(R){d=[],o(R)}).on("end",function(){try{var R=function(O,N,I){switch(O){case"blob":return a.newBlob(a.transformTo("arraybuffer",N),I);case"base64":return h.encode(N);default:return a.transformTo(O,N)}}(S,function(O,N){var I,M=0,X=null,g=0;for(I=0;I>>6:(u<65536?n[w++]=224|u>>>12:(n[w++]=240|u>>>18,n[w++]=128|u>>>12&63),n[w++]=128|u>>>6&63),n[w++]=128|63&u);return n}(i)},p.utf8decode=function(i){return s.nodebuffer?a.transformTo("nodebuffer",i).toString("utf-8"):function(f){var n,u,o,d,w=f.length,S=new Array(2*w);for(n=u=0;n>10&1023,S[u++]=56320|1023&o)}return S.length!==u&&(S.subarray?S=S.subarray(0,u):S.length=u),a.applyFromCharCode(S)}(i=a.transformTo(s.uint8array?"uint8array":"array",i))},a.inherits(m,h),m.prototype.processChunk=function(i){var f=a.transformTo(s.uint8array?"uint8array":"array",i.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var n=f;(f=new Uint8Array(n.length+this.leftOver.length)).set(this.leftOver,0),f.set(n,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var u=function(d,w){var S;for((w=w||d.length)>d.length&&(w=d.length),S=w-1;0<=S&&(192&d[S])==128;)S--;return S<0||S===0?w:S+b[d[S]]>w?S:w}(f),o=f;u!==f.length&&(s.uint8array?(o=f.subarray(0,u),this.leftOver=f.subarray(u,f.length)):(o=f.slice(0,u),this.leftOver=f.slice(u,f.length))),this.push({data:p.utf8decode(o),meta:i.meta})},m.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:p.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},p.Utf8DecodeWorker=m,a.inherits(v,h),v.prototype.processChunk=function(i){this.push({data:p.utf8encode(i.data),meta:i.meta})},p.Utf8EncodeWorker=v},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(_,T,p){"use strict";var a=_("./support"),s=_("./base64"),r=_("./nodejsUtils"),h=_("./external");function b(n){return n}function y(n,u){for(var o=0;o>8;this.dir=!!(16&this.externalFileAttributes),i==0&&(this.dosPermissions=63&this.externalFileAttributes),i==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var i=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=i.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=i.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=i.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=i.readInt(4))}},readExtraFields:function(i){var f,n,u,o=i.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});i.index+4>>6:(i<65536?v[u++]=224|i>>>12:(v[u++]=240|i>>>18,v[u++]=128|i>>>12&63),v[u++]=128|i>>>6&63),v[u++]=128|63&i);return v},p.buf2binstring=function(m){return y(m,m.length)},p.binstring2buf=function(m){for(var v=new a.Buf8(m.length),i=0,f=v.length;i>10&1023,d[f++]=56320|1023&n)}return y(d,f)},p.utf8border=function(m,v){var i;for((v=v||m.length)>m.length&&(v=m.length),i=v-1;0<=i&&(192&m[i])==128;)i--;return i<0||i===0?v:i+h[m[i]]>v?i:v}},{"./common":41}],43:[function(_,T,p){"use strict";T.exports=function(a,s,r,h){for(var b=65535&a|0,y=a>>>16&65535|0,m=0;r!==0;){for(r-=m=2e3>>1:s>>>1;r[h]=s}return r}();T.exports=function(s,r,h,b){var y=a,m=b+h;s^=-1;for(var v=b;v>>8^y[255&(s^r[v])];return-1^s}},{}],46:[function(_,T,p){"use strict";var a,s=_("../utils/common"),r=_("./trees"),h=_("./adler32"),b=_("./crc32"),y=_("./messages"),m=0,v=4,i=0,f=-2,n=-1,u=4,o=2,d=8,w=9,S=286,x=30,R=19,O=2*S+1,N=15,I=3,M=258,X=M+I+1,g=42,F=113,e=1,D=2,q=3,L=4;function Q(t,B){return t.msg=y[B],B}function j(t){return(t<<1)-(4t.avail_out&&(A=t.avail_out),A!==0&&(s.arraySet(t.output,B.pending_buf,B.pending_out,A,t.next_out),t.next_out+=A,B.pending_out+=A,t.total_out+=A,t.avail_out-=A,B.pending-=A,B.pending===0&&(B.pending_out=0))}function z(t,B){r._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,B),t.block_start=t.strstart,E(t.strm)}function Y(t,B){t.pending_buf[t.pending++]=B}function G(t,B){t.pending_buf[t.pending++]=B>>>8&255,t.pending_buf[t.pending++]=255&B}function H(t,B){var A,c,l=t.max_chain_length,k=t.strstart,P=t.prev_length,U=t.nice_match,C=t.strstart>t.w_size-X?t.strstart-(t.w_size-X):0,W=t.window,$=t.w_mask,Z=t.prev,K=t.strstart+M,nt=W[k+P-1],et=W[k+P];t.prev_length>=t.good_match&&(l>>=2),U>t.lookahead&&(U=t.lookahead);do if(W[(A=B)+P]===et&&W[A+P-1]===nt&&W[A]===W[k]&&W[++A]===W[k+1]){k+=2,A++;do;while(W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&W[++k]===W[++A]&&kC&&--l!=0);return P<=t.lookahead?P:t.lookahead}function it(t){var B,A,c,l,k,P,U,C,W,$,Z=t.w_size;do{if(l=t.window_size-t.lookahead-t.strstart,t.strstart>=Z+(Z-X)){for(s.arraySet(t.window,t.window,Z,Z,0),t.match_start-=Z,t.strstart-=Z,t.block_start-=Z,B=A=t.hash_size;c=t.head[--B],t.head[B]=Z<=c?c-Z:0,--A;);for(B=A=Z;c=t.prev[--B],t.prev[B]=Z<=c?c-Z:0,--A;);l+=Z}if(t.strm.avail_in===0)break;if(P=t.strm,U=t.window,C=t.strstart+t.lookahead,W=l,$=void 0,$=P.avail_in,W<$&&($=W),A=$===0?0:(P.avail_in-=$,s.arraySet(U,P.input,P.next_in,$,C),P.state.wrap===1?P.adler=h(P.adler,U,$,C):P.state.wrap===2&&(P.adler=b(P.adler,U,$,C)),P.next_in+=$,P.total_in+=$,$),t.lookahead+=A,t.lookahead+t.insert>=I)for(k=t.strstart-t.insert,t.ins_h=t.window[k],t.ins_h=(t.ins_h<=I&&(t.ins_h=(t.ins_h<=I)if(c=r._tr_tally(t,t.strstart-t.match_start,t.match_length-I),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=I){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=I&&(t.ins_h=(t.ins_h<=I&&t.match_length<=t.prev_length){for(l=t.strstart+t.lookahead-I,c=r._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-I),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=l&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(A=t.pending_buf_size-5);;){if(t.lookahead<=1){if(it(t),t.lookahead===0&&B===m)return e;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var c=t.block_start+A;if((t.strstart===0||t.strstart>=c)&&(t.lookahead=t.strstart-c,t.strstart=c,z(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-X&&(z(t,!1),t.strm.avail_out===0))return e}return t.insert=0,B===v?(z(t,!0),t.strm.avail_out===0?q:L):(t.strstart>t.block_start&&(z(t,!1),t.strm.avail_out),e)}),new rt(4,4,8,4,lt),new rt(4,5,16,8,lt),new rt(4,6,32,32,lt),new rt(4,4,16,16,tt),new rt(8,16,32,32,tt),new rt(8,16,128,128,tt),new rt(8,32,128,256,tt),new rt(32,128,258,1024,tt),new rt(32,258,258,4096,tt)],p.deflateInit=function(t,B){return ut(t,B,d,15,8,0)},p.deflateInit2=ut,p.deflateReset=ct,p.deflateResetKeep=st,p.deflateSetHeader=function(t,B){return t&&t.state?t.state.wrap!==2?f:(t.state.gzhead=B,i):f},p.deflate=function(t,B){var A,c,l,k;if(!t||!t.state||5>8&255),Y(c,c.gzhead.time>>16&255),Y(c,c.gzhead.time>>24&255),Y(c,c.level===9?2:2<=c.strategy||c.level<2?4:0),Y(c,255&c.gzhead.os),c.gzhead.extra&&c.gzhead.extra.length&&(Y(c,255&c.gzhead.extra.length),Y(c,c.gzhead.extra.length>>8&255)),c.gzhead.hcrc&&(t.adler=b(t.adler,c.pending_buf,c.pending,0)),c.gzindex=0,c.status=69):(Y(c,0),Y(c,0),Y(c,0),Y(c,0),Y(c,0),Y(c,c.level===9?2:2<=c.strategy||c.level<2?4:0),Y(c,3),c.status=F);else{var P=d+(c.w_bits-8<<4)<<8;P|=(2<=c.strategy||c.level<2?0:c.level<6?1:c.level===6?2:3)<<6,c.strstart!==0&&(P|=32),P+=31-P%31,c.status=F,G(c,P),c.strstart!==0&&(G(c,t.adler>>>16),G(c,65535&t.adler)),t.adler=1}if(c.status===69)if(c.gzhead.extra){for(l=c.pending;c.gzindex<(65535&c.gzhead.extra.length)&&(c.pending!==c.pending_buf_size||(c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),E(t),l=c.pending,c.pending!==c.pending_buf_size));)Y(c,255&c.gzhead.extra[c.gzindex]),c.gzindex++;c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),c.gzindex===c.gzhead.extra.length&&(c.gzindex=0,c.status=73)}else c.status=73;if(c.status===73)if(c.gzhead.name){l=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),E(t),l=c.pending,c.pending===c.pending_buf_size)){k=1;break}k=c.gzindexl&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),k===0&&(c.gzindex=0,c.status=91)}else c.status=91;if(c.status===91)if(c.gzhead.comment){l=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>l&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),E(t),l=c.pending,c.pending===c.pending_buf_size)){k=1;break}k=c.gzindexl&&(t.adler=b(t.adler,c.pending_buf,c.pending-l,l)),k===0&&(c.status=103)}else c.status=103;if(c.status===103&&(c.gzhead.hcrc?(c.pending+2>c.pending_buf_size&&E(t),c.pending+2<=c.pending_buf_size&&(Y(c,255&t.adler),Y(c,t.adler>>8&255),t.adler=0,c.status=F)):c.status=F),c.pending!==0){if(E(t),t.avail_out===0)return c.last_flush=-1,i}else if(t.avail_in===0&&j(B)<=j(A)&&B!==v)return Q(t,-5);if(c.status===666&&t.avail_in!==0)return Q(t,-5);if(t.avail_in!==0||c.lookahead!==0||B!==m&&c.status!==666){var U=c.strategy===2?function(C,W){for(var $;;){if(C.lookahead===0&&(it(C),C.lookahead===0)){if(W===m)return e;break}if(C.match_length=0,$=r._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++,$&&(z(C,!1),C.strm.avail_out===0))return e}return C.insert=0,W===v?(z(C,!0),C.strm.avail_out===0?q:L):C.last_lit&&(z(C,!1),C.strm.avail_out===0)?e:D}(c,B):c.strategy===3?function(C,W){for(var $,Z,K,nt,et=C.window;;){if(C.lookahead<=M){if(it(C),C.lookahead<=M&&W===m)return e;if(C.lookahead===0)break}if(C.match_length=0,C.lookahead>=I&&0C.lookahead&&(C.match_length=C.lookahead)}if(C.match_length>=I?($=r._tr_tally(C,1,C.match_length-I),C.lookahead-=C.match_length,C.strstart+=C.match_length,C.match_length=0):($=r._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++),$&&(z(C,!1),C.strm.avail_out===0))return e}return C.insert=0,W===v?(z(C,!0),C.strm.avail_out===0?q:L):C.last_lit&&(z(C,!1),C.strm.avail_out===0)?e:D}(c,B):a[c.level].func(c,B);if(U!==q&&U!==L||(c.status=666),U===e||U===q)return t.avail_out===0&&(c.last_flush=-1),i;if(U===D&&(B===1?r._tr_align(c):B!==5&&(r._tr_stored_block(c,0,0,!1),B===3&&(V(c.head),c.lookahead===0&&(c.strstart=0,c.block_start=0,c.insert=0))),E(t),t.avail_out===0))return c.last_flush=-1,i}return B!==v?i:c.wrap<=0?1:(c.wrap===2?(Y(c,255&t.adler),Y(c,t.adler>>8&255),Y(c,t.adler>>16&255),Y(c,t.adler>>24&255),Y(c,255&t.total_in),Y(c,t.total_in>>8&255),Y(c,t.total_in>>16&255),Y(c,t.total_in>>24&255)):(G(c,t.adler>>>16),G(c,65535&t.adler)),E(t),0=A.w_size&&(k===0&&(V(A.head),A.strstart=0,A.block_start=0,A.insert=0),W=new s.Buf8(A.w_size),s.arraySet(W,B,$-A.w_size,A.w_size,0),B=W,$=A.w_size),P=t.avail_in,U=t.next_in,C=t.input,t.avail_in=$,t.next_in=0,t.input=B,it(A);A.lookahead>=I;){for(c=A.strstart,l=A.lookahead-(I-1);A.ins_h=(A.ins_h<>>=I=N>>>24,w-=I,(I=N>>>16&255)===0)D[y++]=65535&N;else{if(!(16&I)){if(!(64&I)){N=S[(65535&N)+(d&(1<>>=I,w-=I),w<15&&(d+=e[h++]<>>=I=N>>>24,w-=I,!(16&(I=N>>>16&255))){if(!(64&I)){N=x[(65535&N)+(d&(1<>>=I,w-=I,(I=y-m)>3,d&=(1<<(w-=M<<3))-1,a.next_in=h,a.next_out=y,a.avail_in=h>>24&255)+(g>>>8&65280)+((65280&g)<<8)+((255&g)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(g){var F;return g&&g.state?(F=g.state,g.total_in=g.total_out=F.total=0,g.msg="",F.wrap&&(g.adler=1&F.wrap),F.mode=f,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new a.Buf32(n),F.distcode=F.distdyn=new a.Buf32(u),F.sane=1,F.back=-1,v):i}function S(g){var F;return g&&g.state?((F=g.state).wsize=0,F.whave=0,F.wnext=0,w(g)):i}function x(g,F){var e,D;return g&&g.state?(D=g.state,F<0?(e=0,F=-F):(e=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15=L.wsize?(a.arraySet(L.window,F,e-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(D<(q=L.wsize-L.wnext)&&(q=D),a.arraySet(L.window,F,e-D,q,L.wnext),(D-=q)?(a.arraySet(L.window,F,e-D,D,0),L.wnext=D,L.whave=L.wsize):(L.wnext+=q,L.wnext===L.wsize&&(L.wnext=0),L.whave>>8&255,e.check=r(e.check,k,2,0),z=E=0,e.mode=2;break}if(e.flags=0,e.head&&(e.head.done=!1),!(1&e.wrap)||(((255&E)<<8)+(E>>8))%31){g.msg="incorrect header check",e.mode=30;break}if((15&E)!=8){g.msg="unknown compression method",e.mode=30;break}if(z-=4,t=8+(15&(E>>>=4)),e.wbits===0)e.wbits=t;else if(t>e.wbits){g.msg="invalid window size",e.mode=30;break}e.dmax=1<>8&1),512&e.flags&&(k[0]=255&E,k[1]=E>>>8&255,e.check=r(e.check,k,2,0)),z=E=0,e.mode=3;case 3:for(;z<32;){if(j===0)break t;j--,E+=D[L++]<>>8&255,k[2]=E>>>16&255,k[3]=E>>>24&255,e.check=r(e.check,k,4,0)),z=E=0,e.mode=4;case 4:for(;z<16;){if(j===0)break t;j--,E+=D[L++]<>8),512&e.flags&&(k[0]=255&E,k[1]=E>>>8&255,e.check=r(e.check,k,2,0)),z=E=0,e.mode=5;case 5:if(1024&e.flags){for(;z<16;){if(j===0)break t;j--,E+=D[L++]<>>8&255,e.check=r(e.check,k,2,0)),z=E=0}else e.head&&(e.head.extra=null);e.mode=6;case 6:if(1024&e.flags&&(j<(H=e.length)&&(H=j),H&&(e.head&&(t=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Array(e.head.extra_len)),a.arraySet(e.head.extra,D,L,H,t)),512&e.flags&&(e.check=r(e.check,D,H,L)),j-=H,L+=H,e.length-=H),e.length))break t;e.length=0,e.mode=7;case 7:if(2048&e.flags){if(j===0)break t;for(H=0;t=D[L+H++],e.head&&t&&e.length<65536&&(e.head.name+=String.fromCharCode(t)),t&&H>9&1,e.head.done=!0),g.adler=e.check=0,e.mode=12;break;case 10:for(;z<32;){if(j===0)break t;j--,E+=D[L++]<>>=7&z,z-=7&z,e.mode=27;break}for(;z<3;){if(j===0)break t;j--,E+=D[L++]<>>=1)){case 0:e.mode=14;break;case 1:if(M(e),e.mode=20,F!==6)break;E>>>=2,z-=2;break t;case 2:e.mode=17;break;case 3:g.msg="invalid block type",e.mode=30}E>>>=2,z-=2;break;case 14:for(E>>>=7&z,z-=7&z;z<32;){if(j===0)break t;j--,E+=D[L++]<>>16^65535)){g.msg="invalid stored block lengths",e.mode=30;break}if(e.length=65535&E,z=E=0,e.mode=15,F===6)break t;case 15:e.mode=16;case 16:if(H=e.length){if(j>>=5,z-=5,e.ndist=1+(31&E),E>>>=5,z-=5,e.ncode=4+(15&E),E>>>=4,z-=4,286>>=3,z-=3}for(;e.have<19;)e.lens[P[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},B=b(0,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,B){g.msg="invalid code lengths set",e.mode=30;break}e.have=0,e.mode=19;case 19:for(;e.have>>16&255,ot=65535&l,!((tt=l>>>24)<=z);){if(j===0)break t;j--,E+=D[L++]<>>=tt,z-=tt,e.lens[e.have++]=ot;else{if(ot===16){for(c=tt+2;z>>=tt,z-=tt,e.have===0){g.msg="invalid bit length repeat",e.mode=30;break}t=e.lens[e.have-1],H=3+(3&E),E>>>=2,z-=2}else if(ot===17){for(c=tt+3;z>>=tt)),E>>>=3,z-=3}else{for(c=tt+7;z>>=tt)),E>>>=7,z-=7}if(e.have+H>e.nlen+e.ndist){g.msg="invalid bit length repeat",e.mode=30;break}for(;H--;)e.lens[e.have++]=t}}if(e.mode===30)break;if(e.lens[256]===0){g.msg="invalid code -- missing end-of-block",e.mode=30;break}if(e.lenbits=9,A={bits:e.lenbits},B=b(y,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,B){g.msg="invalid literal/lengths set",e.mode=30;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},B=b(m,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,B){g.msg="invalid distances set",e.mode=30;break}if(e.mode=20,F===6)break t;case 20:e.mode=21;case 21:if(6<=j&&258<=V){g.next_out=Q,g.avail_out=V,g.next_in=L,g.avail_in=j,e.hold=E,e.bits=z,h(g,G),Q=g.next_out,q=g.output,V=g.avail_out,L=g.next_in,D=g.input,j=g.avail_in,E=e.hold,z=e.bits,e.mode===12&&(e.back=-1);break}for(e.back=0;rt=(l=e.lencode[E&(1<>>16&255,ot=65535&l,!((tt=l>>>24)<=z);){if(j===0)break t;j--,E+=D[L++]<>st)])>>>16&255,ot=65535&l,!(st+(tt=l>>>24)<=z);){if(j===0)break t;j--,E+=D[L++]<>>=st,z-=st,e.back+=st}if(E>>>=tt,z-=tt,e.back+=tt,e.length=ot,rt===0){e.mode=26;break}if(32&rt){e.back=-1,e.mode=12;break}if(64&rt){g.msg="invalid literal/length code",e.mode=30;break}e.extra=15&rt,e.mode=22;case 22:if(e.extra){for(c=e.extra;z>>=e.extra,z-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=23;case 23:for(;rt=(l=e.distcode[E&(1<>>16&255,ot=65535&l,!((tt=l>>>24)<=z);){if(j===0)break t;j--,E+=D[L++]<>st)])>>>16&255,ot=65535&l,!(st+(tt=l>>>24)<=z);){if(j===0)break t;j--,E+=D[L++]<>>=st,z-=st,e.back+=st}if(E>>>=tt,z-=tt,e.back+=tt,64&rt){g.msg="invalid distance code",e.mode=30;break}e.offset=ot,e.extra=15&rt,e.mode=24;case 24:if(e.extra){for(c=e.extra;z>>=e.extra,z-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){g.msg="invalid distance too far back",e.mode=30;break}e.mode=25;case 25:if(V===0)break t;if(H=G-V,e.offset>H){if((H=e.offset-H)>e.whave&&e.sane){g.msg="invalid distance too far back",e.mode=30;break}it=H>e.wnext?(H-=e.wnext,e.wsize-H):e.wnext-H,H>e.length&&(H=e.length),lt=e.window}else lt=q,it=Q-e.offset,H=e.length;for(VO?(I=it[lt+u[F]],z[Y+u[F]]):(I=96,0),d=1<>Q)+(w-=d)]=N<<24|I<<16|M|0,w!==0;);for(d=1<>=1;if(d!==0?(E&=d-1,E+=d):E=0,F++,--G[g]==0){if(g===D)break;g=m[v+u[F]]}if(q>>7)]}function Y(l,k){l.pending_buf[l.pending++]=255&k,l.pending_buf[l.pending++]=k>>>8&255}function G(l,k,P){l.bi_valid>o-P?(l.bi_buf|=k<>o-l.bi_valid,l.bi_valid+=P-o):(l.bi_buf|=k<>>=1,P<<=1,0<--k;);return P>>>1}function lt(l,k,P){var U,C,W=new Array(u+1),$=0;for(U=1;U<=u;U++)W[U]=$=$+P[U-1]<<1;for(C=0;C<=k;C++){var Z=l[2*C+1];Z!==0&&(l[2*C]=it(W[Z]++,Z))}}function tt(l){var k;for(k=0;k>1;1<=P;P--)st(l,W,P);for(C=K;P=l.heap[1],l.heap[1]=l.heap[l.heap_len--],st(l,W,1),U=l.heap[1],l.heap[--l.heap_max]=P,l.heap[--l.heap_max]=U,W[2*C]=W[2*P]+W[2*U],l.depth[C]=(l.depth[P]>=l.depth[U]?l.depth[P]:l.depth[U])+1,W[2*P+1]=W[2*U+1]=C,l.heap[1]=C++,st(l,W,1),2<=l.heap_len;);l.heap[--l.heap_max]=l.heap[1],function(et,ht){var pt,dt,mt,at,gt,yt,ft=ht.dyn_tree,zt=ht.max_code,Tt=ht.stat_desc.static_tree,Bt=ht.stat_desc.has_stree,Rt=ht.stat_desc.extra_bits,Et=ht.stat_desc.extra_base,_t=ht.stat_desc.max_length,bt=0;for(at=0;at<=u;at++)et.bl_count[at]=0;for(ft[2*et.heap[et.heap_max]+1]=0,pt=et.heap_max+1;pt>=7;C>>=1)if(1&nt&&Z.dyn_ltree[2*K]!==0)return s;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return r;for(K=32;K>>3,(W=l.static_len+3+7>>>3)<=C&&(C=W)):C=W=P+5,P+4<=C&&k!==-1?c(l,k,P,U):l.strategy===4||W===C?(G(l,2+(U?1:0),3),ct(l,X,g)):(G(l,4+(U?1:0),3),function(Z,K,nt,et){var ht;for(G(Z,K-257,5),G(Z,nt-1,5),G(Z,et-4,4),ht=0;ht>>8&255,l.pending_buf[l.d_buf+2*l.last_lit+1]=255&k,l.pending_buf[l.l_buf+l.last_lit]=255&P,l.last_lit++,k===0?l.dyn_ltree[2*P]++:(l.matches++,k--,l.dyn_ltree[2*(e[P]+m+1)]++,l.dyn_dtree[2*z(k)]++),l.last_lit===l.lit_bufsize-1},p._tr_align=function(l){G(l,2,3),H(l,w,X),function(k){k.bi_valid===16?(Y(k,k.bi_buf),k.bi_buf=0,k.bi_valid=0):8<=k.bi_valid&&(k.pending_buf[k.pending++]=255&k.bi_buf,k.bi_buf>>=8,k.bi_valid-=8)}(l)}},{"../utils/common":41}],53:[function(_,T,p){"use strict";T.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(_,T,p){(function(a){(function(s,r){"use strict";if(!s.setImmediate){var h,b,y,m,v=1,i={},f=!1,n=s.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(s);u=u&&u.setTimeout?u:s,h={}.toString.call(s.process)==="[object process]"?function(S){process.nextTick(function(){d(S)})}:function(){if(s.postMessage&&!s.importScripts){var S=!0,x=s.onmessage;return s.onmessage=function(){S=!1},s.postMessage("","*"),s.onmessage=x,S}}()?(m="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(S){s.postMessage(m+S,"*")}):s.MessageChannel?((y=new MessageChannel).port1.onmessage=function(S){d(S.data)},function(S){y.port2.postMessage(S)}):n&&"onreadystatechange"in n.createElement("script")?(b=n.documentElement,function(S){var x=n.createElement("script");x.onreadystatechange=function(){d(S),x.onreadystatechange=null,b.removeChild(x),x=null},b.appendChild(x)}):function(S){setTimeout(d,0,S)},u.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var x=new Array(arguments.length-1),R=0;Rwt});module.exports=Mt(Gt);var J=require("obsidian"),Ft=Zt(Ot()),Ht={targetFolder:"Course Modules"},xt=class extends J.Modal{constructor(p,a){super(p);this.result="";this.onSubmit=a}onOpen(){let{contentEl:p}=this;p.empty(),p.createEl("h2",{text:"Enter Course Module URL"}),new J.Setting(p).setName("URL").addText(a=>a.onChange(s=>{this.result=s.trim()}).inputEl.focus()),new J.Setting(p).addButton(a=>a.setButtonText("Download and Unzip").setCta().onClick(()=>{this.result?(this.close(),this.onSubmit(this.result)):new J.Notice("Please enter a URL.")})),p.addEventListener("keypress",a=>{a.key==="Enter"&&(a.preventDefault(),this.result?(this.close(),this.onSubmit(this.result)):new J.Notice("Please enter a URL."))})}onClose(){let{contentEl:p}=this;p.empty()}},St=class extends J.FuzzySuggestModal{constructor(p,a,s,r){super(p);this.plugin=a,this.settingDisplayElement=s,this.preFetchedFolders=r,this.setPlaceholder("Search for a folder...")}getItems(){if(this.preFetchedFolders)return this.preFetchedFolders;console.warn("FolderSuggestModal: Pre-fetched list not available, fetching manually.");let p=this.app.vault.getAllLoadedFiles().filter(s=>s instanceof J.TFolder),a=this.app.vault.getRoot();return p.some(s=>s.path==="/")||p.unshift(a),p}getItemText(p){return p.path==="/"?"/ (Vault Root)":p.path}onChooseItem(p,a){let s=p.path;this.plugin.settings.targetFolder=s,this.plugin.saveSettings(),new J.Notice(`Target folder set to: ${s}`),this.settingDisplayElement.value=s}renderSuggestion(p,a){if(super.renderSuggestion(p,a),p.item.path==="/"){let s=a.querySelector(".suggestion-content");s?s.textContent="/ (Vault Root)":a.setText("/ (Vault Root)")}}},Ct=class extends J.PluginSettingTab{constructor(p,a){super(p,a);this.plugin=a}display(){let{containerEl:p}=this;p.empty(),p.createEl("h2",{text:"Course Material Downloader Settings"});let a=new J.Setting(p).setName("Target Folder").setDesc("The folder where downloaded modules will be unzipped.");a.addText(s=>{s.setValue(this.plugin.settings.targetFolder).setDisabled(!0),s.inputEl.addClass("course-material-downloader-wide-input");let r=s.inputEl;a.addButton(h=>{h.setButtonText("Change Folder").onClick(()=>{let b=this.app.vault.getAllLoadedFiles().filter(m=>m instanceof J.TFolder),y=this.app.vault.getRoot();b.some(m=>m.path==="/")||b.unshift(y),new St(this.app,this.plugin,r,b).open()})})}),p.createEl("p",{text:"Note: If the desired folder doesn't exist, it will be created during the download process (if possible)."})}},wt=class extends J.Plugin{async onload(){await this.loadSettings(),this.addCommand({id:"download-course-module",name:"Download and Unzip Course Module",callback:()=>{this.showUrlInputModal()}}),this.addSettingTab(new Ct(this.app,this))}onunload(){}async loadSettings(){this.settings=Object.assign({},Ht,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async ensureFolderExists(p){if(p==="/"||p==="")return this.app.vault.getRoot();let a=p.replace(/^\/|\/$/g,"");if(a==="")return this.app.vault.getRoot();try{let s=this.app.vault.getAbstractFileByPath(a);if(s instanceof J.TFolder)return s;if(s instanceof J.TFile)return console.error(`Cannot create folder '${a}', a file with this name already exists.`),new J.Notice(`Cannot create folder '${a}', a file exists there.`),null;try{let r=await this.app.vault.createFolder(a);return new J.Notice(`Created folder: ${a}`),r}catch(r){console.error(`Error creating folder '${a}':`,r);let h=this.app.vault.getAbstractFileByPath(a);return h instanceof J.TFolder?h:(new J.Notice(`Error creating folder '${a}'. Check console.`),null)}}catch(s){return console.error(`Unexpected error ensuring folder exists '${a}':`,s),new J.Notice(`Unexpected error checking folder '${a}'. Check console.`),null}}showUrlInputModal(){new xt(this.app,p=>{this.downloadAndUnzip(p)}).open()}async downloadAndUnzip(p){var b,y;if(!p.startsWith("http://")&&!p.startsWith("https://")){new J.Notice("Invalid URL received. Must start with http:// or https://");return}p=p.replace("www.dropbox.com","dl.dropboxusercontent.com"),p.includes("dropbox.com")&&!p.includes("dl=1")&&(p=p.includes("?")?`${p}&dl=1`:`${p}?dl=1`);let a=this.settings.targetFolder,s=await this.ensureFolderExists(a);if(!s){new J.Notice(`Target folder "${a}" could not be found or created. Aborting.`);return}let r=s.path==="/"?"":s.path,h;try{new J.Notice("Downloading module..."),h=(await(0,J.requestUrl)({url:p})).arrayBuffer,new J.Notice("Download complete. Unzipping...")}catch(m){console.error("Download Error:",m),new J.Notice(`Failed to download file: ${m.message}. Check console (Ctrl+Shift+I or Cmd+Opt+I).`);return}try{let m=await Ft.default.loadAsync(h),v=0,i=new Set;for(let f in m.files){let n=f.split("/").pop();if(f.startsWith("__MACOSX/")||n===".DS_Store"||!f)continue;let u=m.files[f],d=(r?`${r}/${f}`:f).replace(/\\/g,"/").replace(/\/+/g,"/");if(u.dir){let w=d.endsWith("/")?d.slice(0,-1):d;w&&!i.has(w)&&(await this.ensureFolderExists(w)?i.add(w):console.warn(`Could not ensure directory exists: ${w}. Skipping contents.`))}else{let w=await u.async("arraybuffer"),S=d.lastIndexOf("/"),x=S>0?d.substring(0,S):S===0?"/":"";if(x&&x!==r&&!i.has(x))if(await this.ensureFolderExists(x))i.add(x);else{console.warn(`Could not ensure parent directory exists: ${x}. Skipping file: ${d}`);continue}let R=d.startsWith("/")?d.substring(1):d;if(R===""&&d==="/"){console.warn("Attempting to check root path '/' for a file. Skipping.");continue}let O=R?this.app.vault.getAbstractFileByPath(R):null;if(O instanceof J.TFile)continue;if(O instanceof J.TFolder){console.error(`Skipping file write: A folder exists at path ${d}`),new J.Notice(`Skipping file write: Folder exists at ${d}`);continue}else try{await this.app.vault.createBinary(d,w,{mtime:Date.now()}),v++}catch(N){(b=N.message)!=null&&b.toLowerCase().includes("file already exists")?console.warn(`Caught 'File already exists' on createBinary for ${d}. Skipping.`):(console.error(`Error creating file '${d}':`,N),new J.Notice(`Error creating file '${d}'. Check console.`))}}}new J.Notice(`Successfully extracted ${v} new file(s) to '${s.path}'.`)}catch(m){console.error("Unzip/Write Error:",m),(y=m.message)!=null&&y.toLowerCase().includes("file already exists")?(console.warn("Caught 'File already exists' error during unzip/write phase, possibly handled. Check logic if files were missed."),new J.Notice("An unexpected 'File already exists' error occurred during processing. Some files might not have been processed correctly. Check console.")):new J.Notice(`Failed to unzip or write files: ${m.message}. Check console.`)}}}; /*! Bundled license information: jszip/dist/jszip.min.js: diff --git a/main.ts b/main.ts index caad2ae..206b475 100644 --- a/main.ts +++ b/main.ts @@ -9,10 +9,10 @@ import { TAbstractFile, Modal, TFile, - FuzzySuggestModal, // Needed for the searchable folder list - FuzzyMatch // Needed for highlighting search results + FuzzySuggestModal, + FuzzyMatch } from 'obsidian'; -import JSZip from 'jszip'; // Keep this import as is with allowSyntheticDefaultImports: true +import JSZip from 'jszip'; // Settings Interface interface CourseMaterialPluginSettings { @@ -87,34 +87,30 @@ class UrlInputModal extends Modal { // ---------------------------------------- -// Folder Suggest Modal Class (MODIFIED to accept pre-fetched list) +// Folder Suggest Modal Class (Cleaned up logs) // ---------------------------------------- class FolderSuggestModal extends FuzzySuggestModal { plugin: CourseMaterialPlugin; settingDisplayElement: HTMLInputElement; preFetchedFolders: TFolder[] | null; // To store the list passed from settings tab - // --- MODIFIED CONSTRUCTOR --- constructor(app: App, plugin: CourseMaterialPlugin, settingDisplayElement: HTMLInputElement, folders: TFolder[]) { super(app); this.plugin = plugin; this.settingDisplayElement = settingDisplayElement; this.preFetchedFolders = folders; // Store the passed list this.setPlaceholder("Search for a folder..."); - console.log("FolderSuggestModal: Initialized with pre-fetched list containing", folders.length, "folders."); + } - // --- MODIFIED getItems --- - // Get all folders including root getItems(): TFolder[] { // Prioritize the pre-fetched list if available if (this.preFetchedFolders) { - console.log("FolderSuggestModal: Using pre-fetched folder list."); return this.preFetchedFolders; } // Fallback: Fetch if list wasn't provided (shouldn't happen with new settings tab logic) - console.warn("FolderSuggestModal: Pre-fetched list not available, fetching manually."); + console.warn("FolderSuggestModal: Pre-fetched list not available, fetching manually."); // Keep warning const folders = this.app.vault.getAllLoadedFiles() .filter(file => file instanceof TFolder) as TFolder[]; const root = this.app.vault.getRoot(); @@ -124,37 +120,32 @@ class FolderSuggestModal extends FuzzySuggestModal { return folders; } - // Text representation of each folder for searching and display getItemText(folder: TFolder): string { return folder.path === '/' ? '/ (Vault Root)' : folder.path; // Display the full path, special label for root } - // Action when a folder is chosen onChooseItem(folder: TFolder, evt: MouseEvent | KeyboardEvent): void { const selectedPath = folder.path; // Path is '/' for root this.plugin.settings.targetFolder = selectedPath; this.plugin.saveSettings(); new Notice(`Target folder set to: ${selectedPath}`); - // Update the text display in the settings tab immediately + this.settingDisplayElement.value = selectedPath; } - // Optional: Render suggestions with highlighting (more advanced) renderSuggestion(item: FuzzyMatch, el: HTMLElement): void { - // Use the default fuzzy match rendering provided by the parent class super.renderSuggestion(item, el); - // Add special text for root folder if (item.item.path === '/') { const existingText = el.querySelector('.suggestion-content'); if (existingText) existingText.textContent = '/ (Vault Root)'; - else el.setText('/ (Vault Root)'); // Fallback if structure changes + else el.setText('/ (Vault Root)'); } } } // ---------------------------------------- -// Settings Tab Class (FIXED .setCta() usage) +// Settings Tab Class (Using CSS class for styling) // ---------------------------------------- class CourseMaterialSettingTab extends PluginSettingTab { plugin: CourseMaterialPlugin; @@ -167,60 +158,51 @@ class CourseMaterialSettingTab extends PluginSettingTab { display(): void { const { containerEl } = this; - containerEl.empty(); // Clear previous settings shown + containerEl.empty(); containerEl.createEl('h2', { text: 'Course Material Downloader Settings' }); - // --- MODIFIED Setting for Target Folder --- - const setting = new Setting(containerEl) // Store the setting reference + const setting = new Setting(containerEl) .setName('Target Folder') .setDesc('The folder where downloaded modules will be unzipped.'); // Add a non-editable text element to display the current setting setting.addText(text => { text.setValue(this.plugin.settings.targetFolder).setDisabled(true); - text.inputEl.style.width = '100%'; // Make the input field take full available width - text.inputEl.style.marginRight = '10px'; // Add some space before the button - const displayElement = text.inputEl; // Store the input element reference + + text.inputEl.addClass('course-material-downloader-wide-input'); + const displayElement = text.inputEl; // Add the button to the same setting control container - setting.addButton(button => { // Add button directly to the 'setting' object + setting.addButton(button => { button.setButtonText('Change Folder') - // --- REMOVED .setCta(false) --- - // .setCta(false) // No argument needed, just remove if not CTA .onClick(() => { - // --- FETCH FOLDER LIST HERE --- - console.log("Settings Tab: 'Change Folder' clicked. Fetching folder list..."); + const currentFolders = (this.app.vault.getAllLoadedFiles() .filter(file => file instanceof TFolder) as TFolder[]); - // Ensure root is included if needed (getAllLoadedFiles usually includes it) const root = this.app.vault.getRoot(); if (!currentFolders.some(f => f.path === '/')) { currentFolders.unshift(root); } - console.log("Settings Tab: Passing", currentFolders.length, "folders to modal."); + - // --- PASS LIST TO MODAL --- - // Open the suggester modal when button is clicked, passing the fetched list new FolderSuggestModal(this.app, this.plugin, displayElement, currentFolders).open(); }); }); }); - - // Note about folder creation (still relevant) containerEl.createEl('p', { text: 'Note: If the desired folder doesn\'t exist, it will be created during the download process (if possible).' }); } } // ---------------------------------------- -// Main Plugin Class +// Main Plugin Class (Cleaned up logs) // ---------------------------------------- export default class CourseMaterialPlugin extends Plugin { settings: CourseMaterialPluginSettings; async onload() { - console.log('Loading Course Material Downloader Plugin'); + await this.loadSettings(); this.addCommand({ @@ -235,7 +217,7 @@ export default class CourseMaterialPlugin extends Plugin { } onunload() { - console.log('Unloading Course Material Downloader Plugin'); + } async loadSettings() { @@ -246,53 +228,47 @@ export default class CourseMaterialPlugin extends Plugin { await this.saveData(this.settings); } - // --- Helper to ensure folder exists (Handles existing files gracefully) --- + // --- Helper to ensure folder exists (Handles existing files gracefully, cleaned logs) --- async ensureFolderExists(path: string): Promise { - // Handle root case explicitly if (path === '/' || path === '') { return this.app.vault.getRoot(); } - - // Normalize path slightly (remove leading/trailing slashes for consistency) let normalizedPath = path.replace(/^\/|\/$/g, ''); if (normalizedPath === '') return this.app.vault.getRoot(); - try { const existingItem = this.app.vault.getAbstractFileByPath(normalizedPath); if (existingItem instanceof TFolder) { - // Folder already exists, all good. return existingItem; } else if (existingItem instanceof TFile) { - // A file exists with this name, cannot create folder here. + console.error(`Cannot create folder '${normalizedPath}', a file with this name already exists.`); new Notice(`Cannot create folder '${normalizedPath}', a file exists there.`); - return null; // Indicate failure + return null; } else { - // Folder doesn't exist, try to create it - console.log(`Attempting to create folder: ${normalizedPath}`); + try { const newFolder = await this.app.vault.createFolder(normalizedPath); new Notice(`Created folder: ${normalizedPath}`); - return newFolder; // Return the newly created folder object + return newFolder; } catch (creationError) { - // Handle potential errors during creation itself + console.error(`Error creating folder '${normalizedPath}':`, creationError); const checkAgain = this.app.vault.getAbstractFileByPath(normalizedPath); if (checkAgain instanceof TFolder) { - console.log(`Folder '${normalizedPath}' found after initial creation attempt failed.`); - return checkAgain; // It exists now, return it + + return checkAgain; } new Notice(`Error creating folder '${normalizedPath}'. Check console.`); - return null; // Indicate failure + return null; } } } catch (error) { - // Catch errors during the initial getAbstractFileByPath or other unexpected issues + console.error(`Unexpected error ensuring folder exists '${normalizedPath}':`, error); new Notice(`Unexpected error checking folder '${normalizedPath}'. Check console.`); - return null; // Indicate failure + return null; } } @@ -305,7 +281,7 @@ export default class CourseMaterialPlugin extends Plugin { } - // --- Main Download/Unzip Logic (Handles skipping existing files & macOS metadata) --- + // --- Main Download/Unzip Logic (Cleaned up logs) --- async downloadAndUnzip(url: string) { // --- 1. URL Validation & Dropbox Fix --- if (!url.startsWith('http://') && !url.startsWith('https://')) { @@ -319,13 +295,11 @@ export default class CourseMaterialPlugin extends Plugin { // --- 2. Get Target Folder and Ensure It Exists --- const targetFolderPath = this.settings.targetFolder; - // Use ensureFolderExists to handle root ('/') correctly now const targetFolder = await this.ensureFolderExists(targetFolderPath); if (!targetFolder) { new Notice(`Target folder "${targetFolderPath}" could not be found or created. Aborting.`); return; } - // Use the path from the TFolder object, especially important for root const cleanTargetFolderPath = targetFolder.path === '/' ? '' : targetFolder.path; @@ -333,12 +307,13 @@ export default class CourseMaterialPlugin extends Plugin { let zipData: ArrayBuffer; try { new Notice('Downloading module...'); - console.log(`Requesting URL: ${url}`); + const response = await requestUrl({ url: url }); zipData = response.arrayBuffer; new Notice('Download complete. Unzipping...'); - console.log(`Downloaded ${zipData.byteLength} bytes.`); + } catch (error) { + console.error('Download Error:', error); new Notice(`Failed to download file: ${error.message}. Check console (Ctrl+Shift+I or Cmd+Opt+I).`); return; @@ -348,30 +323,25 @@ export default class CourseMaterialPlugin extends Plugin { try { const zip = await JSZip.loadAsync(zipData); let fileCount = 0; - let folderPathsCreated = new Set(); // Track created folders + let folderPathsCreated = new Set(); for (const relativePath in zip.files) { - // Skip macOS metadata (__MACOSX, .DS_Store) and empty paths - const fileName = relativePath.split('/').pop(); // Get the actual filename part + const fileName = relativePath.split('/').pop(); if (relativePath.startsWith('__MACOSX/') || fileName === '.DS_Store' || !relativePath) { - if(relativePath.startsWith('__MACOSX/')) console.log(`Ignoring macOS metadata folder: ${relativePath}`); - if(fileName === '.DS_Store') console.log(`Ignoring .DS_Store file: ${relativePath}`); - continue; // Skip this entry + continue; } - const zipEntry = zip.files[relativePath]; - // Construct full destination path, handling root folder case const fullDestPath = cleanTargetFolderPath ? `${cleanTargetFolderPath}/${relativePath}` : relativePath; const normalizedDestPath = fullDestPath.replace(/\\/g, '/').replace(/\/+/g, '/'); // Handle directories from zip if (zipEntry.dir) { - // Remove trailing slash for ensureFolderExists if present const dirPath = normalizedDestPath.endsWith('/') ? normalizedDestPath.slice(0, -1) : normalizedDestPath; if (dirPath && !folderPathsCreated.has(dirPath)) { const folderExists = await this.ensureFolderExists(dirPath); if (!folderExists) { + console.warn(`Could not ensure directory exists: ${dirPath}. Skipping contents.`); } else { folderPathsCreated.add(dirPath); @@ -381,60 +351,50 @@ export default class CourseMaterialPlugin extends Plugin { // Handle files from zip else { const fileData = await zipEntry.async('arraybuffer'); - // Extract parent path correctly, handling root case const lastSlashIndex = normalizedDestPath.lastIndexOf('/'); const parentPath = lastSlashIndex > 0 ? normalizedDestPath.substring(0, lastSlashIndex) : (lastSlashIndex === 0 ? '/' : ''); - // Ensure parent directory exists first if (parentPath && parentPath !== cleanTargetFolderPath && !folderPathsCreated.has(parentPath)) { const parentFolderExists = await this.ensureFolderExists(parentPath); if (!parentFolderExists) { + console.warn(`Could not ensure parent directory exists: ${parentPath}. Skipping file: ${normalizedDestPath}`); - continue; // Skip this file if parent folder failed + continue; } else { folderPathsCreated.add(parentPath); } } - // Check if item exists at the destination path - // Use the normalized path for checking - // Handle root path correctly for getAbstractFileByPath (doesn't want leading '/') const pathToCheck = normalizedDestPath.startsWith('/') ? normalizedDestPath.substring(1) : normalizedDestPath; - // Ensure pathToCheck is not empty if normalizedDestPath was just '/' if (pathToCheck === '' && normalizedDestPath === '/') { - // This case shouldn't happen for files, but defensively handle + console.warn("Attempting to check root path '/' for a file. Skipping."); continue; } - // Check if pathToCheck is not empty before calling getAbstractFileByPath const existingItem = pathToCheck ? this.app.vault.getAbstractFileByPath(pathToCheck) : null; - if (existingItem instanceof TFile) { - // File already exists. Skip extracting this file. - console.log(`Skipping extraction for existing file: ${normalizedDestPath}`); - continue; // Skip to the next item in the zip loop + continue; } else if (existingItem instanceof TFolder) { - // Cannot replace a folder with a file. + console.error(`Skipping file write: A folder exists at path ${normalizedDestPath}`); new Notice(`Skipping file write: Folder exists at ${normalizedDestPath}`); - continue; // Skip to the next item in the zip loop + continue; } else { // File does not exist. Create it. try { - console.log(`Creating new file: ${normalizedDestPath}`); + await this.app.vault.createBinary(normalizedDestPath, fileData, { mtime: Date.now() }); - fileCount++; // Increment count ONLY when a new file is created + fileCount++; } catch (writeError) { - // Check if the specific error is "File already exists" which might happen - // despite our checks due to timing or case sensitivity differences. if (writeError.message?.toLowerCase().includes("file already exists")) { + console.warn(`Caught 'File already exists' on createBinary for ${normalizedDestPath}. Skipping.`); } else { - // Handle other unexpected write errors + console.error(`Error creating file '${normalizedDestPath}':`, writeError); new Notice(`Error creating file '${normalizedDestPath}'. Check console.`); } @@ -444,12 +404,13 @@ export default class CourseMaterialPlugin extends Plugin { } // End of for loop new Notice(`Successfully extracted ${fileCount} new file(s) to '${targetFolder.path}'.`); - console.log(`Extraction complete to folder: ${targetFolder.path}`); + } catch (error) { + console.error('Unzip/Write Error:', error); - // General catch block for errors during JSZip processing or unexpected issues if (error.message?.toLowerCase().includes("file already exists")) { + console.warn("Caught 'File already exists' error during unzip/write phase, possibly handled. Check logic if files were missed."); new Notice("An unexpected 'File already exists' error occurred during processing. Some files might not have been processed correctly. Check console."); } else { diff --git a/styles.css b/styles.css index 71cc60f..28a2a04 100644 --- a/styles.css +++ b/styles.css @@ -1,8 +1,8 @@ -/* +/* Styles for Course Material Downloader Plugin */ -This CSS file will be included with your plugin, and -available in the app when your plugin is enabled. - -If your plugin does not need CSS, delete this file. - -*/ +/* Make the folder display input wider in settings */ +.course-material-downloader-wide-input { + width: 100%; + margin-right: 10px; /* Add space before the button */ + } + \ No newline at end of file