blue-chestnut-solar-expert 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, g as getElement, h } from './index-DZjEuBrX.js';
2
2
  import { f as fetchSolarData, g as getBuildingImages } from './api-E7GpMOpJ.js';
3
- import { D as DOTTED_LINE_COLOR, R as ROW_SPACING, C as COLUMN_SPACING, a as DEFAULT_SOLAR_EXPERT_CONFIG, b as DEFAULT_SOLAR_PANEL_TYPE, B as BORDER_INSET, c as DEFAULT_SUNNINESS } from './config-hh5GAFbi.js';
3
+ import { D as DOTTED_LINE_COLOR, R as ROW_SPACING, C as COLUMN_SPACING, a as DEFAULT_SOLAR_EXPERT_CONFIG, b as DEFAULT_SOLAR_PANEL_TYPE, c as DEFAULT_SUNNINESS, B as BORDER_INSET } from './config-hh5GAFbi.js';
4
4
  import { r as roofTool, t as tools, m as moveTool, o as obstructionTool, d as deleteTool } from './tools-DO8CG56H.js';
5
- import { o as onChange, s as state, g as getLanguageStrings } from './store-DsXeXraH.js';
5
+ import { o as onChange, s as state, g as getLanguageStrings } from './store-CbFNgpiN.js';
6
6
 
7
7
  /*
8
8
  Copyright 2023 Google LLC
@@ -2224,6 +2224,7 @@ const MapDraw = class {
2224
2224
  selectedPolygon = null;
2225
2225
  buildingInsights = null;
2226
2226
  pixelInMeters = 0.2;
2227
+ isMobile = false;
2227
2228
  get el() { return getElement(this); }
2228
2229
  canvasElement;
2229
2230
  polygonCanvas;
@@ -2296,6 +2297,29 @@ const MapDraw = class {
2296
2297
  if (!this.buildingInsights) {
2297
2298
  alert("No building insights found. Please enter them manually.");
2298
2299
  }
2300
+ // If on mobile, automatically calculate panels using Google API data
2301
+ if (state.isMobile && this.buildingInsights) {
2302
+ const maxPanels = this.buildingInsights.solarPotential.maxArrayPanelsCount;
2303
+ const approximatedPanels = Math.floor(maxPanels / 3); // Use one third of max panels
2304
+ const positionedPanels = Array(approximatedPanels).fill(null)
2305
+ .map((_, i) => ({
2306
+ panel: this.solarPanel,
2307
+ pixelPosition: {
2308
+ x: -1,
2309
+ y: -1,
2310
+ },
2311
+ horizontal: true,
2312
+ rotation: 0,
2313
+ }));
2314
+ this.roofPolygonsSolarPanels = {
2315
+ ...this.roofPolygonsSolarPanels,
2316
+ ["mobile-panels"]: {
2317
+ positionedPanels,
2318
+ sunniness: this.buildingInsights.solarPotential.buildingStats
2319
+ .sunshineQuantiles[5] ?? DEFAULT_SUNNINESS,
2320
+ },
2321
+ };
2322
+ }
2299
2323
  }
2300
2324
  async getBuildingImages() {
2301
2325
  if (!state.latitude || !state.longitude) {
@@ -2332,6 +2356,8 @@ const MapDraw = class {
2332
2356
  });
2333
2357
  }
2334
2358
  handleMouseMove(event) {
2359
+ if (state.isMobile)
2360
+ return; // Prevent interactions on mobile
2335
2361
  if (!this.polygonCanvas || !this.polygonCtx)
2336
2362
  return;
2337
2363
  // translate the website pixel coordinates to the canvas coordinates
@@ -2490,6 +2516,8 @@ const MapDraw = class {
2490
2516
  }
2491
2517
  }
2492
2518
  handleMouseDown(event) {
2519
+ if (state.isMobile)
2520
+ return; // Prevent interactions on mobile
2493
2521
  if (!this.polygonCanvas || !this.polygonCtx)
2494
2522
  return;
2495
2523
  if (!this.polygonCanvas.contains(event.target))
@@ -2703,20 +2731,20 @@ const MapDraw = class {
2703
2731
  render() {
2704
2732
  const t = getLanguageStrings(state.settings.language);
2705
2733
  const currentPolygon = this.getCurrentPolygon();
2706
- return (h("div", { key: 'd07de924756053a22246dfe365cb9a3e4d804e14', class: "flex flex-col justify-center items-center w-full h-full gap-4", id: "map-draw" }, this.showInstructions && (h("div", { key: '35da1ca1f6c6ecb2b5f9ac8200fd1d375c4b3e39', class: "w-full rounded-4xl p-4 bg-white" }, t.mapDraw.instructions.parts.roof, " ", h("button", { key: '7a091abdbc451b86b0386744fabb407f93d280d7', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(roofTool) }, h("icon-selector", { key: '5072d7cb08b0338667a5cc32cd217919d570babb', name: "house", inline: true })), " ", t.mapDraw.instructions.parts.obstruction, " ", h("button", { key: '7ef36ac3d64c8cc50dcf716bc9501fe291fca64e', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(obstructionTool) }, h("icon-selector", { key: '46ea7197bb95ad6b5d5863847e6250b94a9efe38', name: "octagon-minus", inline: true })), " ", t.mapDraw.instructions.parts.delete, " ", h("button", { key: '4988fd2d6183c360305e6987b5928e72fc099a53', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(deleteTool) }, h("icon-selector", { key: '9dc9aa801e6c2013495894c96c18a4e4c586a503', name: "eraser", inline: true })), " ", t.mapDraw.instructions.parts.move, " ", h("button", { key: '71f92584748cc7d80fa98f89ee30aad2f34ef708', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(moveTool) }, h("icon-selector", { key: 'd46e966016652a8d1ec5f9ab32254b9f1d5c783f', name: "move", inline: true })), " ", t.mapDraw.instructions.parts.end)), h("div", { key: 'e482db8518551447d2de2e01ca55dc9610ffc19e', class: "w-full flex flex-row justify-between items-center" }, this.showInstructions
2734
+ return (h("div", { key: 'bc5cb8df93f77ad4fe45c79b1deef0609a77253a', class: "flex flex-col justify-center items-center w-full h-full gap-4", id: "map-draw" }, this.showInstructions && !state.isMobile && (h("div", { key: '54410436177fb4a4f306e7526dcd3a04f20335ea', class: "w-full rounded-4xl p-4 bg-white" }, t.mapDraw.instructions.parts.roof, " ", h("button", { key: '642ed241afe9a207fde659f084149e3e35f6ccd1', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(roofTool) }, h("icon-selector", { key: '4071eff3dcc4a6d3d1d5d49177c3b21c761a3861', name: "house", inline: true })), " ", t.mapDraw.instructions.parts.obstruction, " ", h("button", { key: '7b9188696846fbea5f06415649f71bbd7f3b13c7', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(obstructionTool) }, h("icon-selector", { key: 'a2494edd178f787d96aff921aec005d93df4031e', name: "octagon-minus", inline: true })), " ", t.mapDraw.instructions.parts.delete, " ", h("button", { key: 'ff5aa2388ea6e657dc1435cbebfb9b911a687934', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(deleteTool) }, h("icon-selector", { key: 'f3cbd140baf8cb028f66bff5a1a8968cbef89363', name: "eraser", inline: true })), " ", t.mapDraw.instructions.parts.move, " ", h("button", { key: '3e81bf328648f3d2a8b4f60075b33fe2cf9b5ad6', class: "inline-flex items-center justify-center p-1 rounded-full hover:bg-gray-300 transition-colors", onClick: () => this.handleToolSelect(moveTool) }, h("icon-selector", { key: 'be1d5191ed1b2a3c8cf66776b1ea159d4ff43afd', name: "move", inline: true })), " ", t.mapDraw.instructions.parts.end)), h("div", { key: 'e94aca98a9480808b71049af0e1fb7d7343f22a0', class: "w-full flex flex-row justify-between items-center" }, !state.isMobile && (this.showInstructions
2707
2735
  ? (h("button", { class: "px-4 py-2 rounded-4xl hover:bg-gray-300 transition-colors duration-200 bg-white p-4", onClick: () => this.showInstructions = false }, t.mapDraw.instructions.hide))
2708
- : (h("button", { class: "px-4 py-2 rounded-4xl hover:bg-gray-300 transition-colors duration-200 bg-white p-4", onClick: () => this.showInstructions = true }, t.mapDraw.instructions.show)), h("button", { key: 'c58a7cdcb0b00ffe477add863e6f57ab07da9d4e', class: "flex items-center gap-2 bg-white p-2 rounded-4xl hover:bg-gray-300", onClick: this.handleSettingsClick }, h("settings-icon", { key: 'a3b876e00784f02eaafea25491a361f9da42b966' }))), h("div", { key: 'd0daea2194a023ddbe3884d720575f959ef6afb2', class: "w-full" }, h("tool-box", { key: '3f573a87ebc0b57f340a74a2a0ad67d9e5ba3f89', currentTool: this.currentTool, onToolSelect: (tool) => this.handleToolSelect(tool) })), this.loadingState === "empty" && (h("div", { key: '779841f8febd6e97385b57847724881c37d353b0', class: "w-full" }, h("p", { key: '6f1b56ef9d898530de16d8431adc678b9ec0340f', class: "text-white text-center flex items-center justify-center rounded-4xl p-4 w-full", style: {
2736
+ : (h("button", { class: "px-4 py-2 rounded-4xl hover:bg-gray-300 transition-colors duration-200 bg-white p-4", onClick: () => this.showInstructions = true }, t.mapDraw.instructions.show))), h("button", { key: '0c6706ca25dee7f3a7c0c7f375a7c43216f4e5dc', class: "flex items-center gap-2 bg-white p-2 rounded-4xl hover:bg-gray-300", onClick: this.handleSettingsClick }, h("settings-icon", { key: 'a0c2d9d7c75444a497fd79e627efa80878b77b76' }))), h("div", { key: 'b4299108e6cf2b3c44781108204061ff1f868b17', class: "w-full" }, !state.isMobile && (h("tool-box", { key: '25958772c5bcad715eed7e61e9fcf8ba834085e4', currentTool: this.currentTool, onToolSelect: (tool) => this.handleToolSelect(tool) }))), this.loadingState === "empty" && (h("div", { key: '73298d935a0d154587f44aefa01e535b4724965f', class: "w-full" }, h("p", { key: '355a0d78e9429be46867be7918ebee5bb988d86b', class: "text-white text-center flex items-center justify-center rounded-4xl p-4 w-full", style: {
2709
2737
  backgroundColor: "rgba(0, 0, 0, 0.5)",
2710
2738
  } }, t.mapDraw.noAddressSelected))), (state.latitude && state.longitude &&
2711
- this.loadingState === "loading") && (h("div", { key: '1c6a9efd98acf4ef17b0c2895b1bf099c2f71ba6', class: "flex items-center justify-center w-full bg-opacity-75 z-20 pt-7 rounded-4xl" }, h("div", { key: '5f37f48a3d88c51b40870341ecfd2fc27df55148', class: "animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-[#271200]" }))), h("div", { key: '0a016b607d2ee950d1e79b4fd02e5bb62e6172cc', class: "flex items-start justify-center h-full w-full bg-[#f3ebda] rounded-4xl" }, h("div", { key: '2befcf578ecc366bdf7ac03d5b01512e96973e44', class: "relative h-full flex items-center justify-center w-full rounded-4xl bg-[#271200]", style: {
2739
+ this.loadingState === "loading") && (h("div", { key: '63ef7715a479e33e10f32e4ef73512e742feae52', class: "flex items-center justify-center w-full bg-opacity-75 z-20 pt-7 rounded-4xl" }, h("div", { key: '09e523207603a59802393725446693ab9dfb0eec', class: "animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-[#271200]" }))), h("div", { key: '1ba6f36469c629c4a735eb778a525e519b868dcc', class: "flex items-start justify-center h-full w-full bg-[#f3ebda] rounded-4xl" }, h("div", { key: '78a383993d84bd7a5a804a9b8aed982bca3593db', class: "relative h-full flex items-center justify-center w-full rounded-4xl bg-[#271200]", style: {
2712
2740
  aspectRatio: this.rgbTiff
2713
2741
  ? `${this.rgbTiff.width}/${this.rgbTiff.height}`
2714
2742
  : "1/1",
2715
- } }, h("canvas", { key: '6084cc3040923ec095f2b633d82d993c1ec8a63d', ref: (el) => this.canvasElement = el, class: "absolute top-0 left-0 w-full h-full rounded-4xl", id: "map-draw-canvas", style: {
2743
+ } }, h("canvas", { key: '9f73b8eacc53d97584d1a1f2ad75cce42f94d883', ref: (el) => this.canvasElement = el, class: "absolute top-0 left-0 w-full h-full rounded-4xl", id: "map-draw-canvas", style: {
2716
2744
  cursor: this.currentTool.cursor,
2717
- } }), h("canvas", { key: '81d60c93c923b80494b6efaa231c192a308d618b', ref: (el) => this.polygonCanvas = el, class: "absolute top-0 left-0 w-full h-full rounded-4xl", style: {
2745
+ } }), h("canvas", { key: 'd817b13ad847248e5cccbe4a572db0d38115f40d', ref: (el) => this.polygonCanvas = el, class: "absolute top-0 left-0 w-full h-full rounded-4xl", style: {
2718
2746
  cursor: this.currentTool.cursor,
2719
- } }), currentPolygon?.details && (h("button", { key: 'f2f4c937f2fa739d4583cd14bc1d34e849f750cb', class: "absolute bottom-4 right-4 px-4 py-2 bg-[#f3ebda] rounded-4xl hover:bg-[#ffffff] text-[#271200] transition-colors duration-200 z-10 text-xs", onClick: () => this.calculateSolarPanels() }, t.mapDraw.calculateSolarPanels)))), h("div", { key: '5cc85ab4ac0d0d471f56f423b688eb6417bd9690', class: "flex gap-4 flex-row justify-center items-center w-full" }, h("div", { key: '4baafe4af834391336049f22d5270c8a10e210c3', class: "w-full bg-[#f3ebda] rounded-4xl p-4" }, h("h3", { key: '9e29671cbac1b52359772a71af0a79159d3493e7', class: "text-lg font-semibold mb-4 text-center" }, t.mapDraw.information), currentPolygon?.details
2747
+ } }), currentPolygon?.details && (h("button", { key: 'e1ac09242d33d5ff1df6442682c812734aec3ed6', class: "absolute bottom-4 right-4 px-4 py-2 bg-[#f3ebda] rounded-4xl hover:bg-[#ffffff] text-[#271200] transition-colors duration-200 z-10 text-xs", onClick: () => this.calculateSolarPanels() }, t.mapDraw.calculateSolarPanels)))), !state.isMobile && (h("div", { key: '08f69bf2844c1bced2dc1cc17c38a6aeccd4b8b7', class: "flex gap-4 flex-row justify-center items-center w-full" }, h("div", { key: 'e587229364e9644a764ebf57a22c73a8fd139054', class: "w-full bg-[#f3ebda] rounded-4xl p-4" }, h("h3", { key: '0606f98d16973c8dbf75ad59030de9716c757dbc', class: "text-lg font-semibold mb-4 text-center" }, t.mapDraw.information), currentPolygon?.details
2720
2748
  ? (h("div", { class: "space-y-4" }, h("div", null, h("div", { class: "grid grid-cols-2 gap-2" }, h("div", null, h("h4", { class: "text-sm font-medium text-gray-600" }, t.mapDraw.area), h("p", { class: "text-lg" }, currentPolygon.details
2721
2749
  ?.area
2722
2750
  .toFixed(2), " m\u00B2")), h("div", null, h("div", null, h("h4", { class: "text-sm font-medium text-gray-600" }, t.mapDraw.panels), h("p", { class: "text-lg" }, this
@@ -2768,7 +2796,7 @@ const MapDraw = class {
2768
2796
  this.calculateSolarPanels();
2769
2797
  }
2770
2798
  } }))))
2771
- : (h("p", { class: "text-gray-500 text-center" }, t.mapDraw.noPolygonSelected)))), h("div", { key: '5d0dde89de88f0b3609bc262a1d78e436f25c0fb', class: "w-full" }, h("solar-system-form", { key: '8883ac75cd7fcb32724bd72b5a9f6638c03052a4', systemConfigs: this.roofPolygonsSolarPanels, roofPolygons: this.roofPolygons, obstructionPolygons: this.obstructionPolygons })), this.showSettings && (h("settings-modal", { key: '00c8a929cdc1eb0bc05c5805986135bcebceea2d', settings: state.settings, onClose: this.handleSettingsClose, onSave: this.handleSettingsSave }))));
2799
+ : (h("p", { class: "text-gray-500 text-center" }, t.mapDraw.noPolygonSelected))))), h("div", { key: '1155d23559182bc9571bdeeba276896dae44d8e6', class: "w-full" }, h("solar-system-form", { key: 'dd918fdc47abf838cbb1d12932ec837bf357515f', systemConfigs: this.roofPolygonsSolarPanels, roofPolygons: this.roofPolygons, obstructionPolygons: this.obstructionPolygons })), this.showSettings && (h("settings-modal", { key: 'cedf9b3c329cf19870631da50950254de778977d', settings: state.settings, onClose: this.handleSettingsClose, onSave: this.handleSettingsSave }))));
2772
2800
  }
2773
2801
  static get watchers() { return {
2774
2802
  "rgbTiff": ["drawMap"],