1"use strict";(self["webpackChunkshortform"]=self["webpackChunkshortform"]||[]).push([[410],{34410:function(t,e,i){i.d(e,{FilesystemWeb:function(){return n}});i(16280),i(44114),i(16573),i(78100),i(77936),i(18111),i(81148),i(22489),i(7588),i(61701),i(25440),i(21489),i(48140),i(75044),i(21903),i(91134),i(28845),i(373),i(37467),i(44732),i(79577),i(41549),i(49797),i(49631),i(35623),i(62953),i(64979);var r=i(2404),o=i(47066);function s(t){const e=t.split("/").filter(t=>"."!==t),i=[];return e.forEach(t=>{".."===t&&i.length>0&&".."!==i[i.length-1]?i.pop():i.push(t)}),i.join("/")}function a(t,e){t=s(t),e=s(e);const i=t.split("/"),r=e.split("/");return t!==e&&i.every((t,e)=>t===r[e])}class n extends r.E_{constructor(){super(...arguments),this.DB_VERSION=1,this.DB_NAME="Disc",this._writeCmds=["add","put","delete"],this.downloadFile=async t=>{var e,i;const o=(0,r.EA)(t,t.webFetchExtra),s=await fetch(t.url,o);let a;if(t.progress)if(null===s||void 0===s?void 0:s.body){const e=s.body.getReader();let i=0;const r=[],o=s.headers.get("content-type"),n=parseInt(s.headers.get("content-length")||"0",10);while(1){const{done:o,value:s}=await e.read();if(o)break;r.push(s),i+=(null===s||void 0===s?void 0:s.length)||0;const a={url:t.url,bytes:i,contentLength:n};this.notifyListeners("progress",a)}const c=new Uint8Array(i);let d=0;for(const t of r)"undefined"!==typeof t&&(c.set(t,d),d+=t.length);a=new Blob([c.buffer],{type:o||void 0})}else a=new Blob;else a=await s.blob();const n=await this.writeFile({path:t.path,directory:null!==(e=t.directory)&&void 0!==e?e:void 0,recursive:null!==(i=t.recursive)&&void 0!==i&&i,data:a});return{path:n.uri,blob:a}}}readFileInChunks(t,e){throw this.unavailable("Method not implemented.")}async initDb(){if(void 0!==this._db)return this._db;if(!("indexedDB"in window))throw this.unavailable("This browser doesn't support IndexedDB");return new Promise((t,e)=>{const i=indexedDB.open(this.DB_NAME,this.DB_VERSION);i.onupgradeneeded=n.doUpgrade,i.onsuccess=()=>{this._db=i.result,t(i.result)},i.onerror=()=>e(i.error),i.onblocked=()=>{console.warn("db blocked")}})}static doUpgrade(t){const e=t.target,i=e.result;switch(t.oldVersion){case 0:case 1:default:{i.objectStoreNames.contains("FileStorage")&&i.deleteObjectStore("FileStorage");const t=i.createObjectStore("FileStorage",{keyPath:"path"});t.createIndex("by_folder","folder")}}}async dbRequest(t,e){const i=-1!==this._writeCmds.indexOf(t)?"readwrite":"readonly";return this.initDb().then(r=>new Promise((o,s)=>{const a=r.transaction(["FileStorage"],i),n=a.objectStore("FileStorage"),c=n[t](...e);c.onsuccess=()=>o(c.result),c.onerror=()=>s(c.error)}))}async dbIndexRequest(t,e,i){const r=-1!==this._writeCmds.indexOf(e)?"readwrite":"readonly";return this.initDb().then(o=>new Promise((s,a)=>{const n=o.transaction(["FileStorage"],r),c=n.objectStore("FileStorage"),d=c.index(t),h=d[e](...i);h.onsuccess=()=>s(h.result),h.onerror=()=>a(h.error)}))}getPath(t,e){const i=void 0!==e?e.replace(/^[/]+|[/]+$/g,""):"";let r="";return void 0!==t&&(r+="/"+t),""!==e&&(r+="/"+i),r}async clear(){const t=await this.initDb(),e=t.transaction(["FileStorage"],"readwrite"),i=e.objectStore("FileStorage");i.clear()}async readFile(t){const e=this.getPath(t.directory,t.path),i=await this.dbRequest("get",[e]);if(void 0===i)throw Error("File does not exist.");return{data:i.content?i.content:""}}async writeFile(t){const e=this.getPath(t.directory,t.path);let i=t.data;const r=t.encoding,o=t.recursive,s=await this.dbRequest("get",[e]);if(s&&"directory"===s.type)throw Error("The supplied path is a directory.");const a=e.substr(0,e.lastIndexOf("/")),n=await this.dbRequest("get",[a]);if(void 0===n){const e=a.indexOf("/",1);if(-1!==e){const i=a.substr(e);await this.mkdir({path:i,directory:t.directory,recursive:o})}}if(!r&&!(i instanceof Blob)&&(i=i.indexOf(",")>=0?i.split(",")[1]:i,!this.isBase64String(i)))throw Error("The supplied data is not valid base64 content.");const c=Date.now(),d={path:e,folder:a,type:"file",size:i instanceof Blob?i.size:i.length,ctime:c,mtime:c,content:i};return await this.dbRequest("put",[d]),{uri:d.path}}async appendFile(t){const e=this.getPath(t.directory,t.path);let i=t.data;const r=t.encoding,o=e.substr(0,e.lastIndexOf("/")),s=Date.now();let a=s;const n=await this.dbRequest("get",[e]);if(n&&"directory"===n.type)throw Error("The supplied path is a directory.");const c=await this.dbRequest("get",[o]);if(void 0===c){const e=o.indexOf("/",1);if(-1!==e){const i=o.substr(e);await this.mkdir({path:i,directory:t.directory,recursive:!0})}}if(!r&&!this.isBase64String(i))throw Error("The supplied data is not val
1id base64 content.");if(void 0!==n){if(n.content instanceof Blob)throw Error("The occupied entry contains a Blob object which cannot be appended to.");i=void 0===n.content||r?n.content+i:btoa(atob(n.content)+atob(i)),a=n.ctime}const d={path:e,folder:o,type:"file",size:i.length,ctime:a,mtime:s,content:i};await this.dbRequest("put",[d])}async deleteFile(t){const e=this.getPath(t.directory,t.path),i=await this.dbRequest("get",[e]);if(void 0===i)throw Error("File does not exist.");const r=await this.dbIndexRequest("by_folder","getAllKeys",[IDBKeyRange.only(e)]);if(0!==r.length)throw Error("Folder is not empty.");await this.dbRequest("delete",[e])}async mkdir(t){const e=this.getPath(t.directory,t.path),i=t.recursive,r=e.substr(0,e.lastIndexOf("/")),o=(e.match(/\//g)||[]).length,s=await this.dbRequest("get",[r]),a=await this.dbRequest("get",[e]);if(1===o)throw Error("Cannot create Root directory");if(void 0!==a)throw Error("Current directory does already exist.");if(!i&&2!==o&&void 0===s)throw Error("Parent directory must exist");if(i&&2!==o&&void 0===s){const e=r.substr(r.indexOf("/",1));await this.mkdir({path:e,directory:t.directory,recursive:i})}const n=Date.now(),c={path:e,folder:r,type:"directory",size:0,ctime:n,mtime:n};await this.dbRequest("put",[c])}async rmdir(t){const{path:e,directory:i,recursive:r}=t,o=this.getPath(i,e),s=await this.dbRequest("get",[o]);if(void 0===s)throw Error("Folder does not exist.");if("directory"!==s.type)throw Error("Requested path is not a directory");const a=await this.readdir({path:e,directory:i});if(0!==a.files.length&&!r)throw Error("Folder is not empty");for(const n of a.files){const t=`${e}/${n.name}`,o=await this.stat({path:t,directory:i});"file"===o.type?await this.deleteFile({path:t,directory:i}):await this.rmdir({path:t,directory:i,recursive:r})}await this.dbRequest("delete",[o])}async readdir(t){const e=this.getPath(t.directory,t.path),i=await this.dbRequest("get",[e]);if(""!==t.path&&void 0===i)throw Error("Folder does not exist.");const r=await this.dbIndexRequest("by_folder","getAllKeys",[IDBKeyRange.only(e)]),o=await Promise.all(r.map(async t=>{let i=await this.dbRequest("get",[t]);return void 0===i&&(i=await this.dbRequest("get",[t+"/"])),{name:t.substring(e.length+1),type:i.type,size:i.size,ctime:i.ctime,mtime:i.mtime,uri:i.path}}));return{files:o}}async getUri(t){const e=this.getPath(t.directory,t.path);let i=await this.dbRequest("get",[e]);return void 0===i&&(i=await this.dbRequest("get",[e+"/"])),{uri:(null===i||void 0===i?void 0:i.path)||e}}async stat(t){const e=this.getPath(t.directory,t.path);let i=await this.dbRequest("get",[e]);if(void 0===i&&(i=await this.dbRequest("get",[e+"/"])),void 0===i)throw Error("Entry does not exist.");return{name:i.path.substring(e.length+1),type:i.type,size:i.size,ctime:i.ctime,mtime:i.mtime,uri:i.path}}async rename(t){await this._copy(t,!0)}async copy(t){return this._copy(t,!1)}async requestPermissions(){return{publicStorage:"granted"}}async checkPermissions(){return{publicStorage:"granted"}}async _copy(t,e=!1){let{toDirectory:i}=t;const{to:r,from:s,directory:n}=t;if(!r||!s)throw Error("Both to and from must be provided");i||(i=n);const c=this.getPath(n,s),d=this.getPath(i,r);if(c===d)return{uri:d};if(a(c,d))throw Error("To path cannot contain the from path");let h;try{h=await this.stat({path:r,directory:i})}catch(p){const t=r.split("/");t.pop();const e=t.join("/");if(t.length>0){const t=await this.stat({path:e,directory:i});if("directory"!==t.type)throw new Error("Parent directory of the to path is a file")}}if(h&&"directory"===h.type)throw new Error("Cannot overwrite a directory with a file");const l=await this.stat({path:s,directory:n}),u=async(t,e,r)=>{const o=this.getPath(i,t),s=await this.dbRequest("get",[o]);s.ctime=e,s.mtime=r,await this.dbRequest("put",[s])},y=l.ctime?l.ctime:Date.now();switch(l.type){case"file":{const t=await this.readFile({path:s,directory:n});let a;e&&await this.deleteFile({path:s,directory:n}),t.data instanceof Blob||this.isBase64String(t.data)||(a=o.Wi.UTF8);const c=await this.writeFile({path:r,directory:i,data:t.data,encoding:a});return e&&await u(r,y,l.mtime),c}case"directory":{if(h)throw Error("Cannot move a directory over an existing object");try{await this.mkdir({path:r,directory:i,recursive:!1}),e&&await u(r,y,l.mtime)}catch(p){}const t=(await this.readdir({path:s,directory:n})).files;for(const o of t)await this._copy({from:`${s}/${o.name}`,to:`${r}/${o.name}`,directory:n,toDirectory:i},e);e&&await this.rmdir({path:s,directory:n})}}return{uri:d}}isBase64String(t){try{return btoa(atob(t))==t}catch(e){return!1}}}n._debug=!0}
1,81148:function(t,e,i){var r=i(46518),o=i(72652),s=i(79306),a=i(28551),n=i(1767);r({target:"Iterator",proto:!0,real:!0},{every:function(t){a(this),s(t);var e=n(this),i=0;return!o(e,function(e,r){if(!t(e,i++))return r()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}}]); 2//# sourceMappingURL=410.3694dc9c.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.