"use strict";const p=require("axios"),compact_js=require("lodash/compact.js"),each_js=require("lodash/each.js"),filter_js=require("lodash/filter.js"),find_js=require("lodash/find.js"),flatten_js=require("lodash/flatten.js"),get_js=require("lodash/get.js"),groupBy_js=require("lodash/groupBy.js"),isArray_js=require("lodash/isArray.js"),isBoolean_js=require("lodash/isBoolean.js"),isEqual_js=require("lodash/isEqual.js"),isFinite_js=require("lodash/isFinite.js"),isInteger_js=require("lodash/isInteger.js"),isNil_js=require("lodash/isNil.js");require("lodash/isNumber.js");const isObject_js=require("lodash/isObject.js"),isString_js=require("lodash/isString.js"),keyBy_js=require("lodash/keyBy.js"),keys_js=require("lodash/keys.js"),map_js=require("lodash/map.js"),omit_js=require("lodash/omit.js"),pickBy_js=require("lodash/pickBy.js"),set_js=require("lodash/set.js"),some_js=require("lodash/some.js"),sortBy_js=require("lodash/sortBy.js"),times_js=require("lodash/times.js"),unset_js=require("lodash/unset.js"),values_js=require("lodash/values.js");function _interopDefaultCompat(r){return r&&typeof r=="object"&&"default"in r?r.default:r}const p__default=_interopDefaultCompat(p),compact_js__default=_interopDefaultCompat(compact_js),each_js__default=_interopDefaultCompat(each_js),filter_js__default=_interopDefaultCompat(filter_js),find_js__default=_interopDefaultCompat(find_js),flatten_js__default=_interopDefaultCompat(flatten_js),get_js__default=_interopDefaultCompat(get_js),groupBy_js__default=_interopDefaultCompat(groupBy_js),isArray_js__default=_interopDefaultCompat(isArray_js),isBoolean_js__default=_interopDefaultCompat(isBoolean_js),isEqual_js__default=_interopDefaultCompat(isEqual_js),isFinite_js__default=_interopDefaultCompat(isFinite_js),isInteger_js__default=_interopDefaultCompat(isInteger_js),isNil_js__default=_interopDefaultCompat(isNil_js),isObject_js__default=_interopDefaultCompat(isObject_js),isString_js__default=_interopDefaultCompat(isString_js),keyBy_js__default=_interopDefaultCompat(keyBy_js),keys_js__default=_interopDefaultCompat(keys_js),map_js__default=_interopDefaultCompat(map_js),omit_js__default=_interopDefaultCompat(omit_js),pickBy_js__default=_interopDefaultCompat(pickBy_js),set_js__default=_interopDefaultCompat(set_js),some_js__default=_interopDefaultCompat(some_js),sortBy_js__default=_interopDefaultCompat(sortBy_js),times_js__default=_interopDefaultCompat(times_js),unset_js__default=_interopDefaultCompat(unset_js),values_js__default=_interopDefaultCompat(values_js);function getFieldMask(r){let e="";const t=Object.keys(r).filter(a=>a!=="gridProperties").join(",");return r.gridProperties&&(e=Object.keys(r.gridProperties).map(a=>`gridProperties.${a}`).join(","),e.length&&t.length&&(e=`${e},`)),e+t}function columnToLetter(r){let e,t="",a=r;for(;a>0;)e=(a-1)%26,t=String.fromCharCode(e+65)+t,a=(a-e-1)/26;return t}function letterToColumn(r){let e=0;const{length:t}=r;for(let a=0;a{const a=typeof r[t]=="object",s=a&&r[t].length>=0;if(a||(e+=`${t}=${encodeURIComponent(r[t])}&`),a&&s)for(const i of r[t])e+=`${t}=${encodeURIComponent(i)}&`}),e&&e.slice(0,-1)}function checkForDuplicateHeaders(r){const e=groupBy_js__default(r);each_js__default(e,(t,a)=>{if(a&&t.length>1)throw new Error(`Duplicate header detected: "${a}". Please make sure all non-empty headers are unique`)})}class GoogleSpreadsheetRow{constructor(e,t,a){this._worksheet=e,this._rowNumber=t,this._rawData=a,this._deleted=!1}get deleted(){return this._deleted}get rowNumber(){return this._rowNumber}_updateRowNumber(e){this._rowNumber=e}get a1Range(){return[this._worksheet.a1SheetName,"!",`A${this._rowNumber}`,":",`${columnToLetter(this._worksheet.headerValues.length)}${this._rowNumber}`].join("")}get(e){const t=this._worksheet.headerValues.indexOf(e);return this._rawData[t]}set(e,t){const a=this._worksheet.headerValues.indexOf(e);this._rawData[a]=t}assign(e){for(const t in e)this.set(t,e[t])}toObject(){const e={};for(let t=0;t{const a=t.startRow||0,s=t.startColumn||0,i=t.rowMetadata.length,o=t.columnMetadata.length;for(let n=0;nt.value).length,loaded:e.length,total:this.rowCount*this.columnCount}}getCellByA1(e){const t=e.match(/([A-Z]+)([0-9]+)/);if(!t)throw new Error(`Cell address "${e}" not valid`);const a=letterToColumn(t[1]),s=parseInt(t[2]);return this.getCell(s-1,a-1)}getCell(e,t){if(e<0||t<0)throw new Error("Min coordinate is 0, 0");if(e>=this.rowCount||t>=this.columnCount)throw new Error(`Out of bounds, sheet is ${this.rowCount} by ${this.columnCount}`);if(!get_js__default(this._cells,`[${e}][${t}]`))throw new Error("This cell has not been loaded yet");return this._cells[e][t]}async loadCells(e){if(!e)return this._spreadsheet.loadCells(this.a1SheetName);const t=isArray_js__default(e)?e:[e],a=map_js__default(t,s=>{if(isString_js__default(s))return s.startsWith(this.a1SheetName)?s:`${this.a1SheetName}!${s}`;if(isObject_js__default(s)){const i=s;if(i.sheetId&&i.sheetId!==this.sheetId)throw new Error("Leave sheet ID blank or set to matching ID of this sheet");return{sheetId:this.sheetId,...s}}throw new Error("Each filter must be a A1 range string or gridrange object")});return this._spreadsheet.loadCells(a)}async saveUpdatedCells(){const e=filter_js__default(flatten_js__default(this._cells),{_isDirty:!0});e.length&&await this.saveCells(e)}async saveCells(e){const t=map_js__default(e,s=>s._getUpdateRequest()),a=map_js__default(e,s=>`${this.a1SheetName}!${s.a1Address}`);if(!compact_js__default(t).length)throw new Error("At least one cell must have something to update");await this._spreadsheet._makeBatchUpdateRequest(t,a)}async _ensureHeaderRowLoaded(){this._headerValues||await this.loadHeaderRow()}async loadHeaderRow(e,t){e!==void 0&&(this._headerRowIndex=e);const a=await this.getCellsInRange(this._headerRange,t);this._processHeaderRow(a)}_processHeaderRow(e){if(!e)throw new Error("No values in the header row - fill the first row with header values before trying to interact with rows");if(this._headerValues=map_js__default(e[0],t=>t?.toString()?.trim()),!compact_js__default(this.headerValues).length)throw new Error("All your header cells are blank - fill the first row with header values before trying to interact with rows");checkForDuplicateHeaders(this.headerValues)}async setHeaderRow(e,t){if(!e)return;if(e.length>this.columnCount)throw new Error(`Sheet is not large enough to fit ${e.length} columns. Resize the sheet first.`);const a=map_js__default(e,i=>i?.toString()?.trim());if(checkForDuplicateHeaders(a),!compact_js__default(a).length)throw new Error("All your header cells are blank -");t&&(this._headerRowIndex=t);const s=await this._spreadsheet.sheetsApi.request({method:"put",url:`/values/${this.encodedA1SheetName}!${this._headerRowIndex}:${this._headerRowIndex}`,params:{valueInputOption:"USER_ENTERED",includeValuesInResponse:!0},data:{range:`${this.a1SheetName}!${this._headerRowIndex}:${this._headerRowIndex}`,majorDimension:"ROWS",values:[[...a,...times_js__default(this.columnCount-a.length,()=>"")]]}});this._headerValues=s.data.updatedData.values[0]}async addRows(e,t={}){if(this.title.includes(":"))throw new Error('Please remove the ":" from your sheet title. There is a bug with the google API which breaks appending rows if any colons are in the sheet title.');if(!isArray_js__default(e))throw new Error("You must pass in an array of row values to append");await this._ensureHeaderRowLoaded();const a=[];each_js__default(e,n=>{let d;if(isArray_js__default(n))d=n;else if(isObject_js__default(n)){d=[];for(let l=0;lthis.rowCount&&(this._rawProperties.gridProperties.rowCount=o+e.length-1),map_js__default(s.data.updates.updatedData.values,n=>new GoogleSpreadsheetRow(this,o++,n))}async addRow(e,t){return(await this.addRows([e],t))[0]}async getRows(e){const t=e?.offset||0,a=e?.limit||this.rowCount-1;let s;e?.majorDimension&&(s={majorDimension:e.majorDimension}),e?.valueRenderOption&&(s?s.valueRenderOption=e.valueRenderOption:s={valueRenderOption:e.valueRenderOption});const i=1+this._headerRowIndex+t,o=i+a-1;let n;if(this._headerValues){const h=columnToLetter(this.headerValues.length);n=await this.getCellsInRange(`A${i}:${h}${o}`,s)}else{const h=await this.batchGetCellsInRange([this._headerRange,`A${i}:${this.lastColumnLetter}${o}`],s);this._processHeaderRow(h[0]),n=h[1]}if(!n)return[];const d=[];let l=i;for(let h=0;h{t.rowNumber>e&&t._updateRowNumber(t.rowNumber-1)})}async clearRows(e){const t=e?.start||this._headerRowIndex+1,a=e?.end||this.rowCount;await this._spreadsheet.sheetsApi.post(`/values/${this.encodedA1SheetName}!${t}:${a}:clear`),this._rowCache.forEach(s=>{s.rowNumber>=t&&s.rowNumber<=a&&s._clearRowData()})}async updateProperties(e){return this._makeSingleUpdateRequest("updateSheetProperties",{properties:{sheetId:this.sheetId,...e},fields:getFieldMask(e)})}async updateGridProperties(e){return this.updateProperties({gridProperties:e})}async resize(e){return this.updateGridProperties(e)}async updateDimensionProperties(e,t,a){return this._makeSingleUpdateRequest("updateDimensionProperties",{range:{sheetId:this.sheetId,dimension:e,...a},properties:t,fields:getFieldMask(t)})}async getCellsInRange(e,t){return(await this._spreadsheet.sheetsApi.get(`/values/${this.encodedA1SheetName}!${e}`,{params:t})).data.values}async batchGetCellsInRange(e,t){const a=e.map(s=>`ranges=${this.encodedA1SheetName}!${s}`).join("&");return(await this._spreadsheet.sheetsApi.get(`/values:batchGet?${a}`,{params:t})).data.valueRanges.map(s=>s.values)}async updateNamedRange(){}async addNamedRange(){}async deleteNamedRange(){}async repeatCell(){}async autoFill(){}async cutPaste(){}async copyPaste(){}async mergeCells(e,t="MERGE_ALL"){await this._makeSingleUpdateRequest("mergeCells",{mergeType:t,range:this._addSheetIdToRange(e)})}async unmergeCells(e){await this._makeSingleUpdateRequest("unmergeCells",{range:this._addSheetIdToRange(e)})}async updateBorders(){}async addFilterView(){}async appendCells(){}async clearBasicFilter(){}async deleteDimension(){}async deleteEmbeddedObject(){}async deleteFilterView(){}async duplicateFilterView(){}async duplicate(e){const t=(await this._makeSingleUpdateRequest("duplicateSheet",{sourceSheetId:this.sheetId,...e?.index!==void 0&&{insertSheetIndex:e.index},...e?.id&&{newSheetId:e.id},...e?.title&&{newSheetName:e.title}})).properties.sheetId;return this._spreadsheet.sheetsById[t]}async findReplace(){}async insertDimension(e,t,a){if(!e)throw new Error("You need to specify a dimension. i.e. COLUMNS|ROWS");if(!isObject_js__default(t))throw new Error("`range` must be an object containing `startIndex` and `endIndex`");if(!isInteger_js__default(t.startIndex)||t.startIndex<0)throw new Error("range.startIndex must be an integer >=0");if(!isInteger_js__default(t.endIndex)||t.endIndex<0)throw new Error("range.endIndex must be an integer >=0");if(t.endIndex<=t.startIndex)throw new Error("range.endIndex must be greater than range.startIndex");if(a===void 0&&(a=t.startIndex>0),a&&t.startIndex===0)throw new Error("Cannot set inheritFromBefore to true if inserting in first row/column");return this._makeSingleUpdateRequest("insertDimension",{range:{sheetId:this.sheetId,dimension:e,startIndex:t.startIndex,endIndex:t.endIndex},inheritFromBefore:a})}async insertRange(){}async moveDimension(){}async updateEmbeddedObjectPosition(){}async pasteData(){}async textToColumns(){}async updateFilterView(){}async deleteRange(){}async appendDimension(){}async addConditionalFormatRule(){}async updateConditionalFormatRule(){}async deleteConditionalFormatRule(){}async sortRange(){}async setDataValidation(e,t){return this._makeSingleUpdateRequest("setDataValidation",{range:{sheetId:this.sheetId,...e},...t&&{rule:t}})}async setBasicFilter(){}async addProtectedRange(){}async updateProtectedRange(){}async deleteProtectedRange(){}async autoResizeDimensions(){}async addChart(){}async updateChartSpec(){}async updateBanding(){}async addBanding(){}async deleteBanding(){}async createDeveloperMetadata(e,t,a,s){return this._spreadsheet.createSheetDeveloperMetadata(e,t,this.sheetId,a,s)}async updateDeveloperMetadata(){}async deleteDeveloperMetadata(){}async randomizeRange(){}async addDimensionGroup(){}async deleteDimensionGroup(){}async updateDimensionGroup(){}async trimWhitespace(){}async deleteDuplicates(){}async addSlicer(){}async updateSlicerSpec(){}async delete(){return this._spreadsheet.deleteSheet(this.sheetId)}async copyToSpreadsheet(e){return this._spreadsheet.sheetsApi.post(`/sheets/${this.sheetId}:copyTo`,{destinationSpreadsheetId:e})}async clear(e){const t=e?`!${e}`:"";await this._spreadsheet.sheetsApi.post(`/values/${this.encodedA1SheetName}${t}:clear`),this.resetLocalCache(!0)}async downloadAsCSV(e=!1){return this._spreadsheet._downloadAs("csv",this.sheetId,e)}async downloadAsTSV(e=!1){return this._spreadsheet._downloadAs("tsv",this.sheetId,e)}async downloadAsPDF(e=!1){return this._spreadsheet._downloadAs("pdf",this.sheetId,e)}}var AUTH_MODES=(r=>(r.GOOGLE_AUTH_CLIENT="google_auth",r.RAW_ACCESS_TOKEN="raw_access_token",r.API_KEY="api_key",r))(AUTH_MODES||{});const u="https://sheets.googleapis.com/v4/spreadsheets",w="https://www.googleapis.com/drive/v3/files",c={html:{},zip:{},xlsx:{},ods:{},csv:{singleWorksheet:!0},tsv:{singleWorksheet:!0},pdf:{singleWorksheet:!0}};function m(r){if("getRequestHeaders"in r)return AUTH_MODES.GOOGLE_AUTH_CLIENT;if("token"in r&&r.token)return AUTH_MODES.RAW_ACCESS_TOKEN;if("apiKey"in r&&r.apiKey)return AUTH_MODES.API_KEY;throw new Error("Invalid auth")}async function g(r){if("getRequestHeaders"in r)return{headers:await r.getRequestHeaders()};if("apiKey"in r&&r.apiKey)return{params:{key:r.apiKey}};if("token"in r&&r.token)return{headers:{Authorization:`Bearer ${r.token}`}};throw new Error("Invalid auth")}class GoogleSpreadsheet{constructor(e,t){this._rawProperties=null,this._spreadsheetUrl=null,this._deleted=!1,this._rateLimitedRetries=0,this._initialRateLimitedRetryDelay=3e3,this.spreadsheetId=e,this.auth=t,this._rawSheets={},this._spreadsheetUrl=null,this.sheetsApi=p__default.create({baseURL:`${u}/${e}`,paramsSerializer:axiosParamsSerializer,maxContentLength:1/0,maxBodyLength:1/0}),this.driveApi=p__default.create({baseURL:`${w}/${e}`,paramsSerializer:axiosParamsSerializer}),this.sheetsApi.interceptors.request.use(this._setAxiosRequestAuth.bind(this)),this.sheetsApi.interceptors.response.use(this._handleAxiosResponse.bind(this),this._handleAxiosErrors.bind(this)),this.driveApi.interceptors.request.use(this._setAxiosRequestAuth.bind(this)),this.driveApi.interceptors.response.use(this._handleAxiosResponse.bind(this),this._handleAxiosErrors.bind(this))}get authMode(){return m(this.auth)}setRetryOptions(e,t){this._rateLimitedRetries=e,this._initialRateLimitedRetryDelay=t}async _setAxiosRequestAuth(e){const t=await g(this.auth);return each_js__default(t.headers,(a,s)=>{e.headers.set(s,a)}),e.params={...e.params,...t.params},e}async _handleAxiosResponse(e){return e}async _handleAxiosErrors(e){return t=>{if(get_js__default(t,"response.status")===429){const s=t.config,i=s?.retryCount??0;if(this._rateLimitedRetries>0&&i{setTimeout(()=>{o(e(s))},this._initialRateLimitedRetryDelay*(i+1))})}const a=t.response?.data;if(a){if(!a.error)throw t;const{code:s,message:i}=a.error;throw t.message=`Google API error - [${s}] ${i}`,t}throw get_js__default(t,"response.status")===403&&"apiKey"in this.auth?new Error("Sheet is private. Use authentication or make public. (see https://github.com/theoephraim/node-google-spreadsheet#a-note-on-authentication for details)"):t}}async _makeSingleUpdateRequest(e,t){const a=await this.sheetsApi.post(":batchUpdate",{requests:[{[e]:t}],includeSpreadsheetInResponse:!0});return this._updateRawProperties(a.data.updatedSpreadsheet.properties),each_js__default(a.data.updatedSpreadsheet.sheets,s=>this._updateOrCreateSheet(s)),a.data.replies[0][e]}async _makeBatchUpdateRequest(e,t){const a=await this.sheetsApi.post(":batchUpdate",{requests:e,includeSpreadsheetInResponse:!0,...t&&{responseIncludeGridData:!0,...t!=="*"&&{responseRanges:t}}});this._updateRawProperties(a.data.updatedSpreadsheet.properties),each_js__default(a.data.updatedSpreadsheet.sheets,s=>this._updateOrCreateSheet(s))}_ensureInfoLoaded(){if(!this._rawProperties)throw new Error("You must call `doc.loadInfo()` before accessing this property")}_updateRawProperties(e){this._rawProperties=e}_updateOrCreateSheet(e){const{properties:t,data:a}=e,{sheetId:s}=t;this._rawSheets[s]?this._rawSheets[s].updateRawData(t,a):this._rawSheets[s]=new GoogleSpreadsheetWorksheet(this,t,a)}_getProp(e){return this._ensureInfoLoaded(),this._rawProperties[e]}get title(){return this._getProp("title")}get locale(){return this._getProp("locale")}get timeZone(){return this._getProp("timeZone")}get autoRecalc(){return this._getProp("autoRecalc")}get defaultFormat(){return this._getProp("defaultFormat")}get spreadsheetTheme(){return this._getProp("spreadsheetTheme")}get iterativeCalculationSettings(){return this._getProp("iterativeCalculationSettings")}async updateProperties(e){await this._makeSingleUpdateRequest("updateSpreadsheetProperties",{properties:e,fields:getFieldMask(e)})}async loadInfo(e=!1){const t=await this.sheetsApi.get("/",{params:{...e&&{includeGridData:!0}}});if(!t.data?.spreadsheetUrl)throw new Error(`Failed to load document info. Status: ${t.status}, Status Text: ${t.statusText}, Data: ${JSON.stringify(t.data)}`);this._spreadsheetUrl=t.data.spreadsheetUrl,this._rawProperties=t.data.properties,each_js__default(t.data.sheets,a=>this._updateOrCreateSheet(a))}resetLocalCache(){this._rawProperties=null,this._rawSheets={}}get sheetCount(){return this._ensureInfoLoaded(),values_js__default(this._rawSheets).length}get sheetsById(){return this._ensureInfoLoaded(),this._rawSheets}get sheetsByIndex(){return this._ensureInfoLoaded(),sortBy_js__default(this._rawSheets,"index")}get sheetsByTitle(){return this._ensureInfoLoaded(),keyBy_js__default(this._rawSheets,"title")}async addSheet(e={}){const t=(await this._makeSingleUpdateRequest("addSheet",{properties:omit_js__default(e,"headerValues","headerRowIndex")})).properties.sheetId,a=this.sheetsById[t];return e.headerValues&&await a.setHeaderRow(e.headerValues,e.headerRowIndex),a}async deleteSheet(e){await this._makeSingleUpdateRequest("deleteSheet",{sheetId:e}),delete this._rawSheets[e]}async addNamedRange(e,t,a){return this._makeSingleUpdateRequest("addNamedRange",{name:e,namedRangeId:a,range:t})}async deleteNamedRange(e){return this._makeSingleUpdateRequest("deleteNamedRange",{namedRangeId:e})}async loadCells(e){const t=this.authMode===AUTH_MODES.API_KEY,a=isArray_js__default(e)?e:[e],s=map_js__default(a,n=>{if(isString_js__default(n))return t?n:{a1Range:n};if(isObject_js__default(n)){if(t)throw new Error("Only A1 ranges are supported when fetching cells with read-only access (using only an API key)");return{gridRange:n}}throw new Error("Each filter must be an A1 range string or a gridrange object")});let i;this.authMode===AUTH_MODES.API_KEY?i=await this.sheetsApi.get("/",{params:{includeGridData:!0,ranges:s}}):i=await this.sheetsApi.post(":getByDataFilter",{includeGridData:!0,dataFilters:s});const{sheets:o}=i.data;each_js__default(o,n=>{this._updateOrCreateSheet(n)})}async _downloadAs(e,t,a){if(!c[e])throw new Error(`unsupported export fileType - ${e}`);if(c[e].singleWorksheet){if(t===void 0)throw new Error(`Must specify worksheetId when exporting as ${e}`)}else if(t)throw new Error(`Cannot specify worksheetId when exporting as ${e}`);if(e==="html"&&(e="zip"),!this._spreadsheetUrl)throw new Error("Cannot export sheet that is not fully loaded");const s=this._spreadsheetUrl.replace("/edit","/export");return(await this.sheetsApi.get(s,{baseURL:"",params:{id:this.spreadsheetId,format:e,...t&&{gid:t}},responseType:a?"stream":"arraybuffer"})).data}async downloadAsZippedHTML(e){return this._downloadAs("html",void 0,e)}async downloadAsHTML(e){return this._downloadAs("html",void 0,e)}async downloadAsXLSX(e=!1){return this._downloadAs("xlsx",void 0,e)}async downloadAsODS(e=!1){return this._downloadAs("ods",void 0,e)}async delete(){const e=await this.driveApi.delete("");return this._deleted=!0,e.data}async listPermissions(){return(await this.driveApi.request({method:"GET",url:"/permissions",params:{fields:"permissions(id,type,emailAddress,domain,role,displayName,photoLink,deleted)"}})).data.permissions}async setPublicAccessLevel(e){const t=await this.listPermissions(),a=find_js__default(t,s=>s.type==="anyone");if(e===!1){if(!a)return;await this.driveApi.request({method:"DELETE",url:`/permissions/${a.id}`})}else await this.driveApi.request({method:"POST",url:"/permissions",params:{},data:{role:e||"viewer",type:"anyone"}})}async share(e,t){let a,s;return e.includes("@")?a=e:s=e,(await this.driveApi.request({method:"POST",url:"/permissions",params:{...t?.emailMessage===!1&&{sendNotificationEmail:!1},...isString_js__default(t?.emailMessage)&&{emailMessage:t?.emailMessage},...t?.role==="owner"&&{transferOwnership:!0}},data:{role:t?.role||"writer",...a&&{type:t?.isGroup?"group":"user",emailAddress:a},...s&&{type:"domain",domain:s}}})).data}static async createNewSpreadsheetDocument(e,t){if(m(e)===AUTH_MODES.API_KEY)throw new Error("Cannot use api key only to create a new spreadsheet - it is only usable for read-only access of public docs");const a=await g(e),s=await p__default.request({method:"POST",url:u,paramsSerializer:axiosParamsSerializer,...a,data:{properties:t}}),i=new GoogleSpreadsheet(s.data.spreadsheetId,e);return i._spreadsheetUrl=s.data.spreadsheetUrl,i._rawProperties=s.data.properties,each_js__default(s.data.sheets,o=>i._updateOrCreateSheet(o)),i}async _createDeveloperMetadata(e,t,a,s,i){return this._makeSingleUpdateRequest("createDeveloperMetadata",{developerMetadata:{metadataKey:e,metadataValue:t,location:a,visibility:s||"PROJECT",metadataId:i}}).then(o=>o.developerMetadata)}async _getDeveloperMetadata(e){return this.sheetsApi.post("/developerMetadata:search",{dataFilters:[e]}).then(t=>t.data.matchedDeveloperMetadata)}async getMetadataById(e){return this.sheetsApi.get(`/developerMetadata/${e}`).then(t=>t.data)}async createSheetDeveloperMetadata(e,t,a,s,i){return this._createDeveloperMetadata(e,t,{sheetId:a??0},s,i)}async createRangeDeveloperMetadata(e,t,a,s,i){return this._createDeveloperMetadata(e,t,{dimensionRange:a},s,i)}async getDeveloperMetadataByA1Range(e){return this._getDeveloperMetadata({a1Range:e})}async getDeveloperMetadataByGridRange(e){return this._getDeveloperMetadata({gridRange:e})}}exports.GoogleSpreadsheet=GoogleSpreadsheet,exports.GoogleSpreadsheetCell=GoogleSpreadsheetCell,exports.GoogleSpreadsheetCellErrorValue=GoogleSpreadsheetCellErrorValue,exports.GoogleSpreadsheetRow=GoogleSpreadsheetRow,exports.GoogleSpreadsheetWorksheet=GoogleSpreadsheetWorksheet;