plate-map 3.0.0 → 3.0.2

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ All notable changes to plate-map are recorded here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [3.0.2] - 2026-11-30
8
+
9
+ ### Fixed
10
+ - Clicking a widget button no longer submits a surrounding `<form>`. All
11
+ buttons the widget creates (Clear, Copy, Paste, Undo, Redo, the color-group
12
+ buttons, Export CSV, Copy To Clipboard, and the multiplex "Manage…" dialog's
13
+ buttons) are now `type="button"`. Before this, a page that placed the widget
14
+ inside a form, such as an edit page, was submitted and navigated away when
15
+ any of them was clicked.
16
+
17
+ ## [3.0.1] - 2026-10-06
18
+
19
+ ### Fixed
20
+ - The jspm CDN (ga.jspm.io) failed to build 3.0.0 ("build failed"), so it
21
+ couldn't be pinned from jspm. The Node version check in `devEngines` (Node
22
+ 24.11 or newer) now warns instead of failing `npm install` in the package's
23
+ own folder, which is the likely cause. No code changes.
24
+
7
25
  ## [3.0.0] - 2026-10-06
8
26
 
9
27
  > **Why 3.0.0?** The major version bump is driven by browser support. This
package/README.md CHANGED
@@ -487,7 +487,7 @@ options for subfield id `raw_value` will be `["unit1", "unit2"]` , which is used
487
487
  # How to contribute
488
488
 
489
489
  ## Requirements
490
- Building requires _Node_ 24.11 or newer. `.nvmrc` names the version CI uses (`nvm use` picks it up).
490
+ Building requires _Node_ 24.11 or newer (npm warns on older versions). `.nvmrc` names the version CI uses (`nvm use` picks it up).
491
491
 
492
492
  If this is your first time, run `npm ci` in this directory.
493
493
 
@@ -582,6 +582,19 @@ npm run serve.prod
582
582
  `dist/` is committed. CI (`.github/workflows/build.yml`) fails a pull request if the committed `dist/` doesn't match a
583
583
  fresh build, so run `npm run build.dist` and commit `dist/` together with any change to `src/`.
584
584
 
585
+ ## Tests
586
+ The tests run the widget in a real browser (Chromium) with [Playwright](https://playwright.dev/). They load the
587
+ built `dist/` files, the same files published to npm.
588
+
589
+ - `npm test` rebuilds `dist/` and runs every test.
590
+ - `npm run test:e2e` runs the tests against the current `dist/` without rebuilding.
591
+ - The first time on a new machine, install the browser: `npx playwright install chromium`.
592
+
593
+ Tests live in `test/e2e/`. `test/e2e/fixture.html` is the page they open: it loads the dependencies and `dist/`, and
594
+ places widgets inside a `<form>`. `test/e2e/server.js` serves the repository to it. CI
595
+ (`.github/workflows/test.yml`) runs the tests on every pull request and on every push to `master`. If a test fails,
596
+ its screenshot and trace are saved in `test-results/`.
597
+
585
598
  ## Releasing
586
599
  Releases are published to npm by GitHub Actions (`.github/workflows/release.yml`) when a version tag is pushed. No npm
587
600
  login is needed: the package trusts this repository's workflow (npm trusted publishing), and each release carries a
@@ -594,8 +607,10 @@ provenance record linking it to the commit it was built from.
594
607
  4. Push the branch only (`git push -u origin <branch>`), open a pull request, and **merge it with a merge commit**.
595
608
  Don't squash or rebase: the tag must stay on a commit that ends up in `master`.
596
609
  5. Push the tag: `git push origin vX.Y.Z`. The release workflow checks that the tag matches `package.json` and that
597
- `dist/` is up to date, then publishes.
598
- 6. Check the new version on [npm](https://www.npmjs.com/package/plate-map).
610
+ `dist/` is up to date, publishes, and creates the GitHub Release with that version's `CHANGELOG.md` section as
611
+ its notes.
612
+ 6. Check the new version on [npm](https://www.npmjs.com/package/plate-map) and under
613
+ [Releases](https://github.com/nebiolabs/plate-map/releases).
599
614
 
600
615
  Choose the version with [semantic versioning](https://semver.org/): patch for fixes, minor for backwards-compatible
601
616
  features, major for breaking changes, including dropping supported browsers.
@@ -523,7 +523,7 @@ var plateMapWidget = plateMapWidget || {};
523
523
  let modelTile = this.allTiles[singleStack[0]];
524
524
  let row = this._createElement("<tr></tr>");
525
525
  let plateIdDiv = this._createElement("<td></td>").addClass("plate-setup-bottom-id");
526
- let numberText = this._createElement("<button/>");
526
+ let numberText = this._createElement("<button type='button'/>");
527
527
  numberText.addClass("plate-setup-color-text");
528
528
  numberText.text(color);
529
529
  plateIdDiv.append(numberText);
@@ -668,7 +668,7 @@ var plateMapWidget = plateMapWidget || {};
668
668
  let buttonContainer = $("<div>").addClass("plate-setup-overlay-bottom-button-container");
669
669
 
670
670
  // create export csv option
671
- let exportButton = $("<button/>").addClass("plate-setup-button");
671
+ let exportButton = $("<button type='button'/>").addClass("plate-setup-button");
672
672
  exportButton.text("Export CSV");
673
673
  buttonContainer.append(exportButton);
674
674
  exportButton.click(function () {
@@ -685,7 +685,7 @@ var plateMapWidget = plateMapWidget || {};
685
685
  }
686
686
 
687
687
  // creat clipboard option, CLipboard is an external js file located in vendor/asset/javascripts
688
- let clipboardButton = $("<button/>").addClass("plate-setup-button");
688
+ let clipboardButton = $("<button type='button'/>").addClass("plate-setup-button");
689
689
  clipboardButton.text("Copy To Clipboard");
690
690
  buttonContainer.append(clipboardButton);
691
691
  let clipboard = new ClipboardJS(clipboardButton.get(0), {
@@ -2022,7 +2022,7 @@ var plateMapWidget = plateMapWidget || {};
2022
2022
  table.find('th').addClass("plate-popout-th");
2023
2023
  table.find('tr').addClass("plate-popout-tr");
2024
2024
  if (!that.readOnly) {
2025
- let deleteCheckedButton = $("<button class='multiple-field-manage-delete-button'>Delete Checked Items</button>");
2025
+ let deleteCheckedButton = $("<button type='button' class='multiple-field-manage-delete-button'>Delete Checked Items</button>");
2026
2026
  buttonRow.append(deleteCheckedButton);
2027
2027
  deleteCheckedButton.click(function () {
2028
2028
  table.find("input:checked").each(function () {
@@ -2039,7 +2039,7 @@ var plateMapWidget = plateMapWidget || {};
2039
2039
  } else {
2040
2040
  $("<p/>").text("No " + field.name + " in the selected wells").appendTo(tableArea);
2041
2041
  }
2042
- let cancelButton = $("<button>Cancel</button>");
2042
+ let cancelButton = $("<button type='button'>Cancel</button>");
2043
2043
  buttonRow.append(cancelButton);
2044
2044
  cancelButton.click(killDialog);
2045
2045
  dialogDiv.show();
@@ -2077,7 +2077,7 @@ var plateMapWidget = plateMapWidget || {};
2077
2077
  },
2078
2078
  _createDeleteButton: function (field) {
2079
2079
  let that = this;
2080
- let deleteButton = $("<button/>").addClass("plate-setup-remove-all-button");
2080
+ let deleteButton = $("<button type='button'/>").addClass("plate-setup-remove-all-button");
2081
2081
  deleteButton.id = field.id + "Delete";
2082
2082
  deleteButton.text("Manage " + field.name + "...");
2083
2083
  let buttonContainer = that._createElement("<div></div>").addClass("plate-setup-remove-all-button-container");
@@ -2423,31 +2423,31 @@ var plateMapWidget = plateMapWidget || {};
2423
2423
  this.overLayContainer.append(this.overLayTextContainer);
2424
2424
  this.overLayButtonContainer = this._createElement("<div></div>").addClass("plate-setup-overlay-button-container");
2425
2425
  this.overLayContainer.append(this.overLayButtonContainer);
2426
- this.clearCriteriaButton = this._createElement("<button />").addClass("plate-setup-button");
2426
+ this.clearCriteriaButton = this._createElement("<button type='button' />").addClass("plate-setup-button");
2427
2427
  this.clearCriteriaButton.text("Clear");
2428
2428
  this.overLayButtonContainer.append(this.clearCriteriaButton);
2429
2429
  this.clearCriteriaButton.click(function () {
2430
2430
  that.clearCriteria();
2431
2431
  });
2432
- this.copyCriteriaButton = this._createElement("<button />").addClass("plate-setup-button");
2432
+ this.copyCriteriaButton = this._createElement("<button type='button' />").addClass("plate-setup-button");
2433
2433
  this.copyCriteriaButton.text("Copy");
2434
2434
  this.overLayButtonContainer.append(this.copyCriteriaButton);
2435
2435
  this.copyCriteriaButton.click(function () {
2436
2436
  that.copyCriteria();
2437
2437
  });
2438
- this.pasteCriteriaButton = this._createElement("<button />").addClass("plate-setup-button");
2438
+ this.pasteCriteriaButton = this._createElement("<button type='button' />").addClass("plate-setup-button");
2439
2439
  this.pasteCriteriaButton.text("Paste");
2440
2440
  this.overLayButtonContainer.append(this.pasteCriteriaButton);
2441
2441
  this.pasteCriteriaButton.click(function () {
2442
2442
  that.pasteCriteria();
2443
2443
  });
2444
- this.undoButton = this._createElement("<button />").addClass("plate-setup-button");
2444
+ this.undoButton = this._createElement("<button type='button' />").addClass("plate-setup-button");
2445
2445
  this.undoButton.text("Undo");
2446
2446
  this.overLayButtonContainer.append(this.undoButton);
2447
2447
  this.undoButton.click(function () {
2448
2448
  that.undo();
2449
2449
  });
2450
- this.redoButton = this._createElement("<button />").addClass("plate-setup-button");
2450
+ this.redoButton = this._createElement("<button type='button' />").addClass("plate-setup-button");
2451
2451
  this.redoButton.text("Redo");
2452
2452
  this.overLayButtonContainer.append(this.redoButton);
2453
2453
  this.redoButton.click(function () {
@@ -1 +1 @@
1
- var plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.addDataOnChange=function(){return{_addAllData:function(t){if(this.selectedIndices){let i=this.selectedIndices.length;this.selectedIndices.forEach((function(l){let n;l in this.engine.derivative?n=this.engine.derivative[l]:(n=e.extend(!0,{},this.defaultWell),this.engine.derivative[l]=n),n=this.processWellData(t,n,i),this.engine.wellEmpty(n)&&(this.disableAddDeleteWell?this.engine.derivative.hasOwnProperty(l)&&(n=e.extend(!0,{},this.emptyWellWithDefaultVal),this.engine.derivative[l]=n):delete this.engine.derivative[l])}),this)}this.decideSelectedFields(),this._colorMixer(),this.derivativeChange(),this.addToUndoRedo()},processWellData:function(e,t,i){for(let l in e){if(!e.hasOwnProperty(l))continue;let n=e[l];if(null!=n){if(n.multi){let e=t[l];n=this._getMultiData(e,n,l,i)}n=JSON.parse(JSON.stringify(n))}else n=null;t[l]=n}return t},_getMultiData:function(e,t,i,l){let n=t.added,a=t.removed;if(e=e||[],n)if(n.value){const t=n.id.toString(),l="[ALL]"===t;let a=!l;e=e.map((function(e){if(l||e[i].toString()===t){a=!1;for(let t in n.value)t!==i&&(e[t]=n.value[t]);return e}return e})),a&&e.push(n.value)}else e.indexOf(n)<0&&e.push(n);let s=function(e,t){let i=[];for(let l in e)e.hasOwnProperty(l)&&parseInt(l)!==parseInt(t)&&i.push(e[l]);return i};if(a){let t;if(a.value){for(let l in e){e[l][i].toString()===a.id.toString()&&(t=l)}e=s(e,t)}else e&&(t=e.indexOf(a),t>=0&&(e=s(e,t)))}return e&&0===e.length&&(e=null),e},_colorMixer:function(){this.engine.searchAndStack(),this.engine.applyColors()},derivativeChange:function(){this._trigger("updateWells",null,this)},createState:function(){return{derivative:e.extend(!0,{},this.engine.derivative),checkboxes:this.getCheckboxes(),selectedIndices:this.selectedIndices.slice(),requiredField:this.requiredField}},getPlate:function(){let t={},i=this.engine.derivative;for(let l in i){if(!i.hasOwnProperty(l))continue;let n=this.indexToAddress(l),a=i[l];t[n]=e.extend(!0,{},a)}return{wells:t,checkboxes:this.getCheckboxes(),selectedAddresses:this.getSelectedAddresses(),requiredField:this.requiredField}}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).addDataToFields=function(){return{_addDataToTabFields:function(e){for(let t=0;t<this.fieldList.length;t++){let i=this.fieldList[t],l=e[i.id];void 0===l&&(l=null),i.setValue(l)}}}};plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.addTabData=function(){return{fieldList:[],fieldMap:{},autoId:1,_addTabData:function(){let e=this.options.attributes.tabs,t=this;this.requiredField=[];let i=[];e.forEach((function(e,l){if(e.fields){let a=e.fields,s=[];for(var n=0;n<a.length;n++){let e,d=a[n];d.id||(d.id="Auto"+t.autoId++,console.log("Field autoassigned id "+d.id)),d.type||(d.type="text",console.log("Field "+d.id+" autoassigned type "+d.type)),"multiplex"===d.type?(e=t._makeMultiplexField(d,l,s),t.defaultWell[e.id]=[],i.push(e)):(e=t._makeRegularField(d,l,s,!0),"multiselect"===d.type?(t.defaultWell[e.id]=[],i.push(e)):t.defaultWell[e.id]=null)}t.allDataTabs[l].fields=s}else console.log("unknown format in field initialization")})),t.multipleFieldList=i},_makeSubField:function(t,i,l,n){let a=this;i.id||(i.id="Auto"+a.autoId++,console.log("Field autoassigned id "+i.id)),i.type||(i.type="text",console.log("Field "+i.id+" autoassigned type "+i.type));let s=a._createElement("<div></div>").addClass("plate-setup-tab-default-field"),d=a._createElement("<div></div>").addClass("plate-setup-tab-field-left-side"),o=a._createElement("<div></div>").addClass("plate-setup-tab-field-right-side"),r=a._createElement("<div></div>").addClass("plate-setup-tab-name").text(i.name),u=a._createElement("<div></div>").addClass("plate-setup-tab-field-container");e(o).append(r),e(o).append(u),e(s).append(d),e(s).append(o),e(a.allDataTabs[l]).append(s);let c={id:i.id,full_id:t.id+"_"+i.id,name:i.name,root:s,data:i,required:i.required||!1};return n.push(c),a.fieldMap[c.full_id]=c,c},_makeRegularField:function(e,t,i,l){let n=this,a=n._createElement("<div></div>").addClass("plate-setup-tab-default-field"),s=n._createElement("<div></div>").addClass("plate-setup-tab-field-left-side"),d=n._createElement("<div></div>").addClass("plate-setup-tab-field-right-side "),o=n._createElement("<div></div>").addClass("plate-setup-tab-name").text(e.name),r=n._createElement("<div></div>").addClass("plate-setup-tab-field-container");d.append(o),d.append(r),a.append(s),a.append(d),n.allDataTabs[t].append(a);let u={id:e.id,full_id:e.id,name:e.name,root:a,data:e,required:e.required};return u.required&&n.requiredField.push(u.id),i.push(u),n.fieldList.push(u),n.fieldMap[u.full_id]=u,l&&n._addCheckBox(u),n._createField(u),u.onChange=function(){let e=u.getValue(),t={};t[u.id]=e,n._addAllData(t)},u},_makeMultiplexField:function(e,t,i){let l=this,n=l._createElement("<div></div>").addClass("plate-setup-tab-default-field"),a=l._createElement("<div></div>").addClass("plate-setup-tab-field-left-side"),s=l._createElement("<div></div>").addClass("plate-setup-tab-field-right-side "),d=l._createElement("<div></div>").addClass("plate-setup-tab-name").text(e.name),o=l._createElement("<div></div>").addClass("plate-setup-tab-field-container");s.append(d),s.append(o),n.append(a),n.append(s),l.allDataTabs[t].append(n);let r={id:e.id,full_id:e.id,name:e.name,root:n,data:e,required:e.required};i.push(r),l.fieldList.push(r),l.fieldMap[r.full_id]=r;let u=[],c=[];for(let n=0;n<e.multiplexFields.length;n++){let a=e.multiplexFields[n],s=l._makeSubField(r,a,t,i);u.push(s),a.required&&c.push(s.id)}return(r.required||c.length)&&this.requiredField.push({multiplexId:r.id,subFields:c}),r.subFieldList=u,l._createField(r),l._addCheckBox(r),u.forEach((function(e){e.mainMultiplexField=r,l._createField(e),l._addCheckBox(e),e.onChange=function(){let t=e.getValue(),i=e.mainMultiplexField,l=i.singleSelectValue(),n={};n[i.id]=l,n[e.id]=t;let a={id:l,value:n};r._changeMultiFieldValue(a,null);let s=i.detailData;null!==s&&(l=i.singleSelectValue(),s=s.map((function(n){return n[i.id]===l&&(n[e.id]=t),n}))),i.detailData=s}})),r}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.addWarningMsg=function(){return{fieldWarningMsg:function(t,i,l){let n="fieldWarning"+t.full_id,a=e("<span>").html(this._assets.warningImg).attr("id",n).addClass("plate-field-warning-image");if(l){if(t.root.find("#"+n).length<=0){t.root.find(".plate-setup-tab-name").text(" "+t.name),t.root.find(".plate-setup-tab-name").prepend(a);let l=e("<div/>").addClass("pop-out-text");l.text(i),t.root.find(".plate-setup-tab-name").append(l),e("#"+n).hover((function(){l[0].style.display="flex"}),(function(){l.hide()}))}}else t.root.find("#"+n).length>0&&(t.root.find(".plate-setup-tab-name").text(t.name),e("#"+n).remove())},removeWarningMsg:function(t,i,l){let n=this,a="fieldWarning"+t.full_id;if(l){let l=e("<span>").html(n._assets.warningImg).attr("id",a).addClass("plate-field-warning-image");t.root.find(".plate-setup-tab-name").append(l);let s=e("<div/>").addClass("pop-out-text");s.text(i),t.root.find(".plate-setup-tab-name").append(s),l.hover((function(){s[0].style.display="inline-block"}),(function(){s.hide()}))}else e("#"+a).remove()},applyFieldWarning:function(e){let t=this,i={};t.fieldList.forEach((function(e){i[e.id]=[]})),e.forEach((function(e){if(!t.engine.wellEmpty(e))for(let t in i)i.hasOwnProperty(t)&&(t in e?i[t].push(e[t]):i[t].push(null))}));for(let e=0;e<t.fieldList.length;e++){let l=t.fieldList[e];if(l.applyMultiplexSubFieldColor)l.applyMultiplexSubFieldColor(i[l.id]);else if(l.required){let e=!1;i[l.id].forEach((function(t){t instanceof Array?0===t.length&&(e=!0):null===t&&(e=!0)})),t.fieldWarningMsg(l,"required field",e)}}}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.bottomTable=function(){return{_bottomScreen:function(){this.bottomContainer=this._createElement("<div></div>").addClass("plate-setup-bottom-container"),this.bottomTableContainer=this._createElement("<div></div>").addClass("plate-setup-bottom-table-container"),this.bottomTable=this._createElement("<table></table>").addClass("plate-setup-bottom-table"),this.bottomTableHead=this._createElement("<thead></thead>"),this.bottomTableBody=this._createElement("<tbody></tbody>"),this.bottomTable.append(this.bottomTableHead),this.bottomTable.append(this.bottomTableBody),this.bottomTableContainer.append(this.bottomTable),this.bottomContainer.append(this.bottomTableContainer),this.container.append(this.bottomContainer)},addBottomTableHeadings:function(){let e=this._createElement("<tr></tr>"),t=this._createElement("<th></th>").text("Group");e.html(t),this.rowCounter=1;for(let t=0;t<this.globalSelectedAttributes.length;t++){let i=this.globalSelectedAttributes[t],l=this.fieldMap[i],n=this._createElement("<th></th>").text(l.name);e.append(n),this.rowCounter=this.rowCounter+1}this.bottomTableBody.empty(),this.bottomTableHead.empty(),this.bottomTableHead.append(e),this.adjustFieldWidth(e)},tileAttrText:function(e,t){let i=this.engine.derivative[e.index];return this.fieldMap[t].getText(i[t])},addBottomTableRow:function(e,t){let i=this,l=this.allTiles[t[0]],n=this._createElement("<tr></tr>"),a=this._createElement("<td></td>").addClass("plate-setup-bottom-id"),s=this._createElement("<button/>");s.addClass("plate-setup-color-text"),s.text(e),a.append(s),s.click((function(e){let l=t.map(e=>i.indexToAddress(e));e.ctrlKey&&i.getSelectedAddresses().forEach((function(e){l.indexOf(e)<0&&l.push(e)})),i.setSelectedAddresses(l)})),e>0&&(e=(e-1)%(this.colorPairs.length-1)+1);let d=this.colorPairs[e];a.css("background","linear-gradient(to right, "+d[0]+" , "+d[1]+")"),n.append(a);for(let e=0;e<this.globalSelectedAttributes.length;e++){let t=this.globalSelectedAttributes[e],i=this.tileAttrText(l,t),a=this._createElement("<td></td>").text(i);n.append(a)}this.bottomTableBody.append(n),this.adjustFieldWidth(n)},bottomForFirstTime:function(){this.addBottomTableHeadings();let e=this._createElement("<tr></tr>"),t=this.colorPairs[0],i=this._createElement("<td></td>");i.css("background","-webkit-linear-gradient(left, "+t[0]+" , "+t[1]+")"),e.append(i),this.bottomTableBody.append(e),this.createExportButton()},adjustFieldWidth:function(e){let t=this.rowCounter;150*t>1024&&e.css("width",152*t+"px")},downloadCSV:function(e,t){let i,l;i=new Blob([e],{type:"text/csv"}),l=document.createElement("a"),l.download=t,l.href=window.URL.createObjectURL(i),l.style.display="none",document.body.appendChild(l),l.click()},exportData:function(e){let t=[],i=document.querySelectorAll("table tr"),l={},n=this.engine.stackUpWithColor;for(let e in n)n.hasOwnProperty(e)&&(l[e]=n[e].map(e=>this.indexToAddress(e)));for(let n=0;n<i.length;n++){let a=[],s=i[n].querySelectorAll("td, th");for(let t=0;t<s.length;t++){let i="";if(s[t].innerText&&(i="csv"===e?'"'+s[t].innerText.replace(/"/g,'""')+'"':s[t].innerText),a.push(i),0===n&&0===t&&("csv"===e?a.push('"Location"'):"clipboard"===e&&a.push("Location")),0!==n&&0===t){let i="";l[parseInt(s[t].innerText)]&&("csv"===e?i='"'+l[parseInt(s[t].innerText)].join(",")+'"':"clipboard"===e&&(i=l[parseInt(s[t].innerText)].join(","))),a.push(i)}}"csv"===e?t.push(a.join(",")):"clipboard"===e&&t.push(a.join("\t"))}if("csv"===e)this.downloadCSV(t.join("\n"),"table.csv");else if("clipboard"===e)return t.join("\n")},createExportButton:function(){let t=this,i=e("<div>").addClass("plate-setup-bottom-control-container"),l=e("<div>").addClass("plate-setup-overlay-text-container");l.text("Color groups"),i.append(l);let n=e("<div>").addClass("plate-setup-overlay-bottom-button-container"),a=e("<button/>").addClass("plate-setup-button");function s(){a.text("Export CSV"),a[0].classList.remove("plate-setup-clicked-button"),a.addClass("plate-setup-button")}a.text("Export CSV"),n.append(a),a.click((function(){t.exportData("csv"),a.text("Exported"),a[0].classList.remove("plate-setup-button"),a.addClass("plate-setup-clicked-button"),setTimeout(s,3e3)}));let d=e("<button/>").addClass("plate-setup-button");d.text("Copy To Clipboard"),n.append(d);let o=new ClipboardJS(d.get(0),{text:function(){return t.exportData("clipboard")}});function r(){d.text("Copy To Clipboard"),d[0].classList.remove("plate-setup-clicked-button"),d.addClass("plate-setup-button")}o.on("success",(function(){d.text("Copied as tab-delimited format"),d[0].classList.remove("plate-setup-button"),d.addClass("plate-setup-clicked-button"),setTimeout(r,3e3)})),o.on("error",(function(){d.text("Failed to copy table to clipboard: browser may be incompatible"),setTimeout(r,3e3)})),i.append(n),this.bottomContainer.prepend(i)}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.checkBox=function(){return{globalSelectedAttributes:[],globalSelectedMultiplexSubfield:[],allCheckboxes:[],_addCheckBox:function(t){let i=e("<span>").html(this._assets.dontImg).addClass("plate-setup-tab-check-box bg-light").data("clicked",!1),l=t.full_id;i.data("linkedFieldId",l),t.root.find(".plate-setup-tab-field-left-side").empty().append(i),this._applyCheckboxHandler(i),t.checkbox=i,this.allCheckboxes.push(l)},_applyCheckboxHandler:function(t){let i=this;t.click((function(){let t=e(this),l={};l[t.data("linkedFieldId")]=!t.data("clicked"),i.changeCheckboxes(l)}))},getCheckboxes:function(){return this.allCheckboxes.filter((function(e){let t=this.fieldMap[e];if(t.mainMultiplexField){return(this.globalSelectedMultiplexSubfield[t.mainMultiplexField.id]||[]).indexOf(t.id)}return this.globalSelectedAttributes.indexOf(t.id)>=0}),this)},changeSubFieldsCheckboxes:function(e,t){let i=this,l=[];return e.subFieldList.forEach((function(e){let n=e.checkbox,a=n.data("linkedFieldId"),s=n.data("clicked");a in t&&(s=Boolean(t[a])),n.data("clicked",s),s?(n.html(i._assets.doImg),l.push(e.id)):n.html(i._assets.dontImg)})),l},changeCheckboxes:function(e,t){let i=[],l={};for(let t=0;t<this.fieldList.length;t++){let n=this.fieldList[t];if(n.checkbox){n.subFieldList&&(l[n.id]=this.changeSubFieldsCheckboxes(n,e));let t=n.checkbox,a=t.data("linkedFieldId"),s=t.data("clicked");a in e&&(s=Boolean(e[a])),t.data("clicked",s),s?(i.push(a),t.html(this._assets.doImg)):t.html(this._assets.dontImg)}}this.globalSelectedMultiplexSubfield=l,this.globalSelectedAttributes=i,this._clearPresetSelection(),this._colorMixer(),t||this.addToUndoRedo()},setSubFieldCheckboxes:function(e,t){let i=this,l=[];return e.subFieldList.forEach((function(e){let n=e.checkbox,a=n.data("linkedFieldId"),s=t.indexOf(a)>=0;n.data("clicked",s),s?(n.html(i._assets.doImg),l.push(e.id)):n.html(i._assets.dontImg)})),l},setCheckboxes:function(e,t){e=e||[];let i=[],l={};for(let t=0;t<this.fieldList.length;t++){let n=this.fieldList[t];if(n.checkbox){n.subFieldList&&(l[n.id]=this.setSubFieldCheckboxes(n,e));let t=n.checkbox,a=t.data("linkedFieldId"),s=e.indexOf(a)>=0;t.data("clicked",s),s?(i.push(a),t.html(this._assets.doImg)):t.html(this._assets.dontImg)}}this.globalSelectedMultiplexSubfield=l,this.globalSelectedAttributes=i,this._clearPresetSelection(),this._colorMixer(),t||this.addToUndoRedo()}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).colorManager=function(){return{colorPairs:[["#e6e6e6","#808080"],["#66e8ff","#0082c8"],["#ff7fb1","#e6194b"],["#a2ffb1","#3cb44b"],["#f784ff","#911eb4"],["#ffe897","#f58231"],["#6666ff","#0000FF"],["#ffff7f","#ffe119"],["#acffff","#46f0f0"],["#ff98ff","#f032e6"],["#ffffa2","#d2f53c"],["#ffffff","#fabebe"],["#66e6e6","#008080"],["#ffffff","#e6beff"],["#ffd48e","#aa6e28"],["#e66666","#800000"],["#ffffff","#aaffc3"],["#e6e666","#808000"],["#ffffff","#ffd8b1"],["#66a9ef","#004389"],["#ff6672","#a7000c"],["#66db72","#00750c"],["#b866db","#520075"],["#ffa966","#b64300"],["#ffff66","#c0a200"],["#6dffff","#07b1b1"],["#ff66ff","#b100a7"],["#f9ff66","#93b600"],["#ffe5e5","#bb7f7f"],["#66a7a7","#004141"],["#ffe5ff","#a77fc0"],["#d19566","#6b2f00"],["#ffffef","#c0bb89"],["#d1ffea","#6bc084"],["#a7a766","#414100"],["#ffffd8","#c09972"],["#a5ffff","#3fc1ff"],["#ffbef0","#ff588a"],["#e1fff0","#7bf38a"],["#ffc3ff","#d05df3"],["#ffffd6","#ffc170"],["#a5a5ff","#3f3fff"],["#ffffbe","#ffff58"],["#ebffff","#85ffff"],["#ffd7ff","#ff71ff"],["#a5ffff","#3fbfbf"],["#ffffcd","#e9ad67"],["#ffa5a5","#bf3f3f"],["#ffffa5","#bfbf3f"]]}};plateMapWidget=plateMapWidget||{};!function(e){function t(t){t.params.args.originalEvent?t.params.args.originalEvent.stopPropagation():e(this).one("select2:opening",(function(e){e.preventDefault()}))}function i(e){e.on("select2:unselecting",t)}function l(e,t,i){e.empty();let l=e.data("select2").dataAdapter;l.addOptions(l.convertToOptions(t)),e.val(i)}plateMapWidget.createField=function(){return{_createField:function(e){switch(e.data.type){case"text":this._createTextField(e),this._handleFieldUnits(e);break;case"numeric":this._createNumericField(e),this._handleFieldUnits(e);break;case"select":this._createSelectField(e),this._handleFieldUnits(e);break;case"multiselect":this._createMultiSelectField(e);break;case"boolean":this._createBooleanField(e);break;case"multiplex":this._createMultiplexField(e)}},_handleFieldUnits:function(e){let t=e.data,i=t.units||[],l=t.defaultUnit||null;l?i.length?i.indexOf(l)<0&&(l=i[0]):i=[l]:i.length&&(l=i[0]),i.length&&(e.units=i,e.hasUnits=!0,e.defaultUnit=l,this._makeFieldUnits(e))},_makeFieldUnits:function(t){let i=t.full_id,n=t.units,a=t.defaultUnit,s=null;if(t.disabledRegular=t.disabled,t.parseRegularValue=t.parseValue,t.setRegularValue=t.setValue,t.getRegularValue=t.getValue,t.getRegularText=t.getText,n.length)if(1===n.length){let i=e("<div></div>").addClass("plate-setup-tab-unit");i.text(a),t.root.find(".plate-setup-tab-field-container").append(i)}else{s=this._createElement("<select/>").attr("id",i+"Units").addClass("plate-setup-tab-unit-select-field"),t.root.find(".plate-setup-tab-field-container").append(s);let e=null,l={data:n.map((function(t){return t===a&&(e=t),{id:t,text:t}})),allowClear:!1,minimumResultsForSearch:10};s.select2(l),s.val(e)}t.disabled=function(e){return e=t.disabledRegular(e),s&&s.prop("disabled",e),e},t.parseValue=function(i){let l;return e.isPlainObject(i)?(l=t.parseRegularValue(i.value),null===l?null:{value:l,unit:t.parseUnit(i.unit)}):(l=t.parseRegularValue(i),null===l?null:{value:l,unit:t.defaultUnit})},t.getValue=function(){let e=t.getRegularValue();if(null===e)return null;{let i={value:e,unit:t.getUnit()};if(t.data.hasMultiplexUnit){let e=t.data.unitMap;for(let t in e){if(!e.hasOwnProperty(t))continue;e[t].forEach((function(e){e.text===i.unit&&(i.unitTypeId=t,i.unitId=e.id)}))}}return i}},t.setValue=function(i){e.isPlainObject(i)?(t.setUnit(i.unit||t.defaultUnit),t.setRegularValue(i.value)):(t.setRegularValue(i),t.setUnit(t.defaultUnit))},t.setUnitOpts=function(e){t.units=e||null,t.defaultUnit=null;let i=[],n=null;t.units&&t.units.length&&(t.defaultUnit=t.units[0],i=t.units.map((function(e){let i={id:e,text:e};return e===t.defaultUnit&&(n=e),i}))),l(s,i,n)},t.parseUnit=function(e){if(null==e||""===e)return t.defaultUnit;for(let t=0;t<n.length;t++)if(e.toLowerCase()===n[t].toLowerCase())return n[t];throw"Invalid unit "+e+" for field "+i},t.getUnit=function(){return s?s.val():t.defaultUnit},t.setUnit=function(e){s&&(e=e||t.defaultUnit,s.val(e),s.trigger("change.select2"))},t.getText=function(e){if("object"==typeof e&&e){let t=e.value,i=e.unit;return null==t?"":(t=t.toString(),i||(i=a),i&&(t=t+" "+i),t)}return t.getRegularText(e)},t.parseText=function(e){let i=t.parseValue(e);return i&&"object"==typeof i?t.getRegularText(i.value)+i.unit:null!=i?t.getRegularText(i):null},s&&s.on("change",(function(){t.onChange()})),t.unitInput=s},_createTextField:function(e){let t=this._createElement("<input>").attr("id",e.full_id).addClass("plate-setup-tab-input");e.root.find(".plate-setup-tab-field-container").append(t),e.parseValue=function(e){return e=e?String(e):null},e.getValue=function(){return t.val().trim()||null},e.setValue=function(e){document.activeElement!==t[0]&&t.val(e)},e.getText=function(e){return null==e?"":e},e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t},e.parseText=e.parseValue,t.on("input",(function(){e.onChange()})),e.input=t},_createOpts:function(e){let t={allowClear:!0,placeholder:"select"},i=!1;if(e.options&&(t.data=e.options,i=!0),e.ajax&&(t.ajax=ajax,i=!0),!i)throw"Must specify data or ajax";return t},_createSelectField:function(e){let t=e.full_id,l=this._createElement("<select/>").attr("id",t).addClass("plate-setup-tab-select-field").addClass("plate-setup-tab-input");e.root.find(".plate-setup-tab-field-container").append(l);let n=this._createOpts(e.data),a={};n.data.forEach((function(e){a[String(e.id)]=e})),l.select2(n),i(l);let s=function(e){let i=e;if(""===i&&(i=null),null==i)return null;if(i=String(i),i in a)return a[i].id;throw"Invalid value "+e+" for select field "+t};e.parseValue=s,e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t},e.getValue=function(){return s(l.val())},e.setValue=function(e){l.val(e),l.trigger("change.select2")},e.getText=function(e){return null==e?"":a[String(e)].text},e.parseText=function(e){let i=e;if(""===i&&(i=null),null==i)return null;if(i=String(i),i in a)return a[i].text;throw"Invalid text value "+e+" for select field "+t},l.on("change",(function(){e.onChange()})),e.input=l},_createMultiSelectField:function(e){let t=e.full_id,l=this,n=this._createElement("<select/>").attr("id",t).addClass("plate-setup-tab-multiselect-field");n.attr("multiple","multiple"),e.root.find(".plate-setup-tab-field-container").append(n);let a=l._createOpts(e.data);a.multiple=!0;let s={};a.data.forEach((function(e){s[String(e.id)]=e})),n.select2(a),i(n),e.disabled=function(t){return t=e.isDisabled||t,n.prop("disabled",t),t},e._parseOne=function(e){if((e=String(e))in s)return s[e].id;throw"Invalid value "+e+" for multiselect field "+t},e._parseMany=function(t){return t=t&&t.length?t.map(e._parseOne,this):null},e.parseValue=function(t){return e._parseMany(t)},e.getValue=function(){return e._parseMany(n.val())},e.setValue=function(e){e=e||[],n.val(e),n.trigger("change.select2")},e.getText=function(e){return null==e?"":e.length>0?e.map(e=>s[String(e)].text).join("; "):""},e.multiOnChange=function(t,i){t&&(t=t.id),i&&(i=i.id);let n={};n[e.id]={multi:!0,added:t,removed:i},l._addAllData(n)},e.parseText=function(e){let i=e;return i=i&&i.length?i.map((function(e){if((e=String(e))in s)return s[e].text;throw"Invalid text value "+e+" for multiselect field "+t})):null,i},n.on("select2:select",(function(t){let i=e._parseOne(t.params.data.id);i={id:i},e.multiOnChange(i,null)})),n.on("select2:unselect",(function(t){let i=e._parseOne(t.params.data.id);i={id:i},e.multiOnChange(null,i)})),e.input=n,l._createDeleteButton(e)},_createNumericField:function(e){let t=e.full_id,i=e.data,l=this._createElement("<input>").addClass("plate-setup-tab-input").attr("placeholder",i.placeholder||"").attr("id",t).attr("inputmode","decimal"),n="",a=/^-?\d*\.?\d*$/;e.root.find(".plate-setup-tab-field-container").append(l),e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t};let s=function(e){if(null==e)return null;let i=String(e).trim();if(""===i)return null;if(i=Number(i),isNaN(i))throw"Invalid value "+e+" for numeric field "+t;return i};e.parseValue=s,e.getValue=function(){let e=l.val().trim();return""===e?null:(e=Number(e),isNaN(e)?null:e)},e.setValue=function(e){document.activeElement!==l[0]&&(l.val(e),n=l.val())};let d=function(e){return null==e?"":e=e.toString()};e.getText=d,e.parseText=function(e){return d(s(e))},l.on("input",(function(){let t=l.val();t.indexOf("−")>=0&&(t=t.replace(/−/g,"-"),l.val(t)),a.test(t.trim())?(n=t,e.onChange()):l.val(n)})),e.input=l},_createBooleanField:function(e){let t=e.full_id,l=this._createElement("<select/>").attr("id",t).addClass("plate-setup-tab-select-field");e.root.find(".plate-setup-tab-field-container").append(l);let n={data:[{id:"true",text:"true"},{id:"false",text:"false"}],placeholder:"select",allowClear:!0,minimumResultsForSearch:-1};l.select2(n),i(l),e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t},e.parseValue=function(e){if(null==e)return null;let i=String(e).trim().toLowerCase();if("true"===i)i=!0;else if("false"===i)i=!1;else{if(""!==i)throw"Invalid value "+e+" for boolean field "+t;i=null}return i},e.getValue=function(){switch(l.val()){case"true":return!0;case"false":return!1;default:return null}},e.setValue=function(e){e=1===e||!0===e||"true"===e?"true":0===e||!1===e||"false"===e?"false":null,l.val(e),l.trigger("change.select2")},e.getText=function(e){return null==e?"":e.toString()},e.parseText=e.parseValue,l.on("change",(function(){e.onChange()})),e.input=l},_createMultiplexField:function(e){let t=this;this._createMultiSelectField(e);let n=this._createElement("<div></div>").addClass("plate-setup-tab-name-singleSelect").text("Select to edit"),a=this._createElement("<div></div>").addClass("plate-setup-tab-field-container-singleSelect");e.root.find(".plate-setup-tab-field-right-side").append(n,a),e.singleSelect=this._createElement("<select/>").attr("id",e.full_id+"SingleSelect").addClass("plate-setup-tab-multiplex-single-select-field"),e.singleSelect.appendTo(a);e.singleSelect.select2({allowClear:!1,placeholder:"select",minimumResultsForSearch:10,data:[]}),i(e.singleSelect);let s=e.setValue;e.singleSelectValue=function(){let t=e.singleSelect.val();return""===t||null==t?null:"[ALL]"==t?t:e._parseOne(t)};let d=function(t,i){if(t=t||[],e.allSelectedMultipleVal){const i=Object.values(e.allSelectedMultipleVal).reduce((function(e,t){return e+t}),0);if(i){t=[{id:"[ALL]",text:`[${i} well ${e.data.name}]`,forAll:!0}].concat(t)}}i||(i=t.length?t[0].id:null),l(e.singleSelect,t,i),e.singleSelect.prop("disabled",0===t.length),e.singleSelect.trigger("change.select2")},o=function(){let i=e.singleSelectValue();e.updateSubFieldUnitOpts(i);let l=null;if("[ALL]"===i)l=e.allSelectedMultipleData;else{(e.detailData||[]).forEach((function(t){t[e.id]===i&&(l=t)}))}l?e.subFieldList.forEach((function(e){e.isDisabled=!1,e.setValue(l[e.id])})):e.subFieldList.forEach((function(e){e.isDisabled=!0,e.setValue(null)})),t.readOnlyHandler()};d([]),e.singleSelect.on("change.select2",o),e._changeMultiFieldValue=function(i,l){let n,a={};for(let t=0;t<e.subFieldList.length;t++){a[e.subFieldList[t].id]=null}i&&(i.value?n=i.value:(a[e.id]=i.id,n=a),i={id:i.id,value:n}),l&&(l.value?n=l.value:(a[e.id]=l.id,n=a),l={id:l.id,value:n});let s={};s[e.id]={multi:!0,added:i,removed:l},t._addAllData(s)},e.setValue=function(t){e.detailData=t;let i=null;t&&t.length&&(i=t.map(t=>t[e.id])),s(i);let l=e.input.select2("data")||[];d(l,e.singleSelectValue()),o()},e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),e.subFieldList.forEach((function(e){e.disabled(t)})),t?n.text("Select to inspect"):n.text("Select to edit"),t},e.parseValue=function(t){let i=t;return i=i&&i.length?i.map((function(t){let i={};i[e.id]=t[e.id];for(let l in t)t.hasOwnProperty(l)&&e.subFieldList.forEach((function(e){e.id===l&&(i[e.id]=e.parseValue(t[l]))}));return i})):null,i},e.updateSubFieldUnitOpts=function(t){let i;e.data.options.forEach((function(e){e.id===t&&(i=e)})),e.subFieldList.forEach((function(e){e.data.hasMultiplexUnit&&(i&&i.hasOwnProperty("unitOptions")?e.setUnitOpts(i.unitOptions[e.id]):e.setUnitOpts(null))}))},e.multiOnChange=function(t,i){e._changeMultiFieldValue(t,i);let l=e.getValue(),n=e.detailData,a=[],s=null;n&&(a=n.map(t=>t[e.id]));let r=[],u=[];if(l){l.forEach((function(t){if(n&&n.forEach((function(i){i[e.id]===t&&r.push(i)})),a.indexOf(t)<0){let i={};i[e.id]=t,e.updateSubFieldUnitOpts(t),e.subFieldList.forEach((function(l){if(l.hasUnits)if(l.data.hasMultiplexUnit)l.disabled(!1),e.data.options.forEach((function(e){if(e.id===t){let e={value:null,unit:l.units[0]};i[l.id]=l.parseValue(e)}}));else{l.data.units&&l.data.units.length>1&&l.disabled(!1);let e={value:null,unit:l.defaultUnit};i[l.id]=l.parseValue(e)}else i[l.id]=l.parseValue(null)})),r.push(i)}})),l.forEach((function(t){e.data.options.forEach((function(e){e.id===t&&u.push(e)}))}));let i=e.singleSelectValue();for(let e=0;e<l.length;e++){if(t&&t.id===l[e]){s=l[e];break}(0===e||l[e]===i)&&(s=l[e])}}e.detailData=r,d(u,s),o()},e.getText=function(i){if(null===i)return"";if(e.id in t.globalSelectedMultiplexSubfield){let l=t.globalSelectedMultiplexSubfield[e.id],n=[];for(let t in i){if(!i.hasOwnProperty(t))continue;let a=i[t],s=[];for(let t in e.data.options)if(e.data.options.hasOwnProperty(t)){let i=e.data.options[t];i.id===a[e.id]&&s.push(i.text)}e.subFieldList.forEach((function(e){if(l.indexOf(e.id)>=0){let t=e.getText(a[e.id]);s.push(e.name+": "+t)}})),n.push("{"+s.join(", ")+"}")}return n.join(";")}},e.parseText=function(t){if(null===t)return"";{let i=[];for(let l in t){if(!t.hasOwnProperty(l))continue;let n=t[l],a=[];for(let t in e.data.options)if(e.data.options.hasOwnProperty(t)){let i=e.data.options[t];i.id===n[e.id]&&a.push(i.text)}e.subFieldList.forEach((function(e){let t=e.getText(n[e.id]);t&&a.push(t)})),i.push(a)}return i}},e.checkMultiplexCompletion=function(t){let i=0,l=0,n=!1;function a(t){let i=0,l=0;for(let a in e.subFieldList){if(!e.subFieldList.hasOwnProperty(a))continue;let s=e.subFieldList[a],d=t[s.id];s.required&&(n=!0,i++,"object"==typeof d&&d?d.value&&l++:d&&l++)}return l/i}if(t)if(t.length>0){for(let e in t)if(t.hasOwnProperty(e)){i++,l+=a(t[e])}}else e.required&&(n=!0,i=1);else e.required&&(n=!0,i=1);return{include:n,completionPct:l/i}},e.applyMultiplexSubFieldColor=function(i){let l={};e.subFieldList.forEach((function(e){e.required&&(l[e.id]={field:e,warningStatus:[]})})),i.forEach((function(t){!function(t){for(let i in e.subFieldList){if(!e.subFieldList.hasOwnProperty(i))continue;let n=e.subFieldList[i];if(null===t)e.required&&n.required&&l[n.id].warningStatus.push(!0);else if("object"==typeof t)if(0===t.length)e.required&&n.required&&l[n.id].warningStatus.push(!0);else for(let e in t){if(!t.hasOwnProperty(e))continue;let i=t[e][n.id];n.required&&("object"==typeof i&&i?i.value?l[n.id].warningStatus.push(!1):l[n.id].warningStatus.push(!0):i?l[n.id].warningStatus.push(!1):l[n.id].warningStatus.push(!0))}}}(t)}));let n=[];for(let i in l){if(!l.hasOwnProperty(i))continue;let a=l[i].field;if(l[i].warningStatus.indexOf(!0)>=0){let i=a.name+" is a required subfield for "+e.name+", please make sure all "+e.name+" have "+a.name;e.required,t.fieldWarningMsg(a,i,!0),n.push(!0)}else t.fieldWarningMsg(a,"none",!1),n.push(!1)}let a,s=n.indexOf(!0)>=0;a=e.required?e.name+" is a required field, please also fix missing required subfield(s) below":e.name+" is not a required field, please fix missing required subfield(s) below or remove selected "+e.name,t.fieldWarningMsg(e,a,s)},e.parseMainFieldVal=function(t){let i=e.data.options;for(let e=0;e<i.length;e++){let l=i[e];if(l.id===t)return l.text}}},_deleteDialog:function(t){let i,l=this,n=t.allSelectedMultipleVal;i=n?Object.keys(n):[];let a=e("<div/>").addClass("plate-modal");function s(){a.hide(),a.remove()}this.container.append(a);let d=e("<div/>").addClass("plate-modal-content").css("width","550px").appendTo(a),o=e("<div/>").appendTo(d),r=e("<div/>").addClass("dialog-buttons").css("justify-content","flex-end").appendTo(d);if(i.length>0){e("<p/>").text(t.name+" in selected wells: choose items to delete and click the delete button below").appendTo(o);let i=l._deleteDialogTable(t,n);if(i.appendTo(o),i.addClass("plate-popout-table"),i.find("td").addClass("plate-popout-td"),i.find("th").addClass("plate-popout-th"),i.find("tr").addClass("plate-popout-tr"),!l.readOnly){let n=e("<button class='multiple-field-manage-delete-button'>Delete Checked Items</button>");r.append(n),n.click((function(){i.find("input:checked").each((function(){let e=this.value;t.multiOnChange(null,{id:e})})),l.decideSelectedFields(),s()}))}}else e("<p/>").text("No "+t.name+" in the selected wells").appendTo(o);let u=e("<button>Cancel</button>");r.append(u),u.click(s),a.show(),window.onclick=function(e){e.target===a[0]&&s()}},_deleteDialogTable:function(t,i){let l=this,n=[t.name,"Counts"];l.readOnly||n.push("Delete");let a=e("<table/>"),s=e("<thead/>").appendTo(a);e("<tr/>").appendTo(s).append(n.map((function(t){return e("<th/>").text(t)})));let d=e("<tbody/>").appendTo(a);return t.data.options.forEach((function(t){if(t.id in i){let n=e("<tr/>").appendTo(d),a=e("<input type='checkbox'>").prop("value",t.id);e("<td/>").text(t.text).appendTo(n),e("<td/>").text(i[t.id]).appendTo(n),l.readOnly||e("<td/>").append(a).appendTo(n)}})),a},_createDeleteButton:function(t){let i=this,l=e("<button/>").addClass("plate-setup-remove-all-button");l.id=t.id+"Delete",l.text("Manage "+t.name+"...");let n=i._createElement("<div></div>").addClass("plate-setup-remove-all-button-container");n.append(l),t.deleteButton=l,t.root.find(".plate-setup-tab-field-right-side").append(n),l.click((function(){i._deleteDialog(t)}))}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.engine=function(t){return{engine:{derivative:{},colorMap:new Map,stackUpWithColor:{},stackPointer:2,wellEmpty:function(e){for(let t in e){if(!e.hasOwnProperty(t))continue;let i=e[t];if(null!=i){if(!Array.isArray(i))return!1;if(i.length>0)return!1}}return!0},searchAndStack:function(){this.stackUpWithColor={},this.stackPointer=1;let i={};for(let l in this.derivative){if(!this.derivative.hasOwnProperty(l))continue;let n=this.derivative[l],a={};for(let e=0;e<t.globalSelectedAttributes.length;e++){let i=t.globalSelectedAttributes[e];if(i in t.globalSelectedMultiplexSubfield){let e=t.globalSelectedMultiplexSubfield[i],l=[];for(let t in n[i]){if(!n[i].hasOwnProperty(t))continue;let a=n[i][t],s={};s[i]=a[i],e.forEach((function(e){s[e]=a[e]})),l.push(s)}a[i]=l}else null!=n[i]&&(a[i]=n[i])}e.isEmptyObject(a)?i[l]=null:i[l]=JSON.stringify(a)}for(;!e.isEmptyObject(i);){let e=Object.keys(i).map(parseFloat);e.sort((function(e,t){return e-t}));let t=e[0],l=i[t],n=[];if(l){for(let t=0;t<e.length;t++){let a=e[t];l===i[a]&&(n.push(a),this.stackUpWithColor[this.stackPointer]=n,delete i[a])}n.length>0&&this.stackPointer++}else this.stackUpWithColor[0]?this.stackUpWithColor[0].push(t):this.stackUpWithColor[0]=[t],delete i[t]}},applyColors:function(){let e=0,i=0;t.addBottomTableHeadings();for(let e=0;e<t.allTiles.length;e++){let i=t.allTiles[e];t.setTileVisible(i,!1)}for(let l=0;l<this.stackPointer;l++){let n=this.stackUpWithColor[l];if(n){t.addBottomTableRow(l,n);for(let a=0;a<n.length;a++){e++;let n=this.stackUpWithColor[l][a],s=t.allTiles[n],d=this.derivative[n];this.colorMap.set(n,l),t.setTileColor(s,l);let o=this.checkCompletion(d,s);t.setTileComplete(s,1===o),i+=o}}}i=Math.floor(100*i/e),isNaN(i)?t.overLayTextContainer.text("Completion Percentage: 0%"):t.overLayTextContainer.text("Completion Percentage: "+i+"%"),t.selectObjectInBottomTab()},checkCompletion:function(e){let i=0,l=0;for(let n=0;n<t.fieldList.length;n++){let a=t.fieldList[n];if(a.checkMultiplexCompletion){let t=a.checkMultiplexCompletion(e[a.id]);t.include&&(l+=t.completionPct,i++)}else a.required&&(i++,null!==e[a.id]&&l++)}return i===l?1:l/i}}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).assets=function(){return{_assets:{doImg:"&#10003;",dontImg:"",warningImg:"&#9888;"}}};plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.interface=function(){return{_createInterface:function(){this.container=this._createElement("<div></div>").addClass("plate-setup-wrapper"),this.topSection=this._createElement("<div></div>").addClass("plate-setup-top-section"),this.topLeft=this._createElement("<div></div>").addClass("plate-setup-top-left"),this.topRight=this._createElement("<div></div>").addClass("plate-setup-top-right"),this.overLayContainer=this._createElement("<div></div>").addClass("plate-setup-overlay-container"),this.canvasContainer=this._createElement("<div></div>").addClass("plate-setup-canvas-container"),this._createOverLay(),e(this.topLeft).append(this.overLayContainer),e(this.topLeft).append(this.canvasContainer),e(this.topSection).append(this.topLeft),e(this.topSection).append(this.topRight),e(this.container).append(this.topSection),e(this.element).append(this.container),this._createSvg(),this._createTabAtRight(),this._createTabs(),this._placePresetTabs(),this._bottomScreen(),this.bottomForFirstTime();let t=this;this._setShortcuts(),e(document.body).keyup((function(e){t._handleShortcuts(e)})),this._configureUndoRedoArray()},_createElement:function(t){return e(t)},_setShortcuts:function(){let e=this;window.addEventListener("cut",(function(t){document.activeElement===document.body&&(e.copyCriteria(),e.clearCriteria(),t.preventDefault())})),window.addEventListener("copy",(function(t){document.activeElement===document.body&&(e.copyCriteria(),t.preventDefault())})),window.addEventListener("paste",(function(t){document.activeElement===document.body&&(e.pasteCriteria(),t.preventDefault())}))},_handleShortcuts:function(e){document.activeElement===document.body&&(46===e.keyCode?(this.clearCriteria(),e.preventDefault()):(e.ctrlKey||e.metaKey)&&(90===e.keyCode?(e.shiftKey?this.redo():this.undo(),e.preventDefault()):89===e.keyCode&&(this.redo(),e.preventDefault())))}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).loadPlate=function(){return{loadPlate:function(e){let t,i;if(e.hasOwnProperty("wells")){t={};for(let i in e.wells){let l=e.wells[i];t[this.addressToIndex(i)]=this.sanitizeWell(l)}}else t=this.engine.derivative;i=e.hasOwnProperty("checkboxes")?this.sanitizeCheckboxes(e.checkboxes):this.getCheckboxes();let l={derivative:t,checkboxes:i};this.setData(l)},sanitizeCheckboxes:function(e){return e=e||[],this.allCheckboxes.filter(t=>e.indexOf(t)>=0)},sanitizeAddresses:function(e){let t=(e=e||[]).map(e=>this.addressToIndex(e));return t.sort((e,t)=>e-t),t=t.filter((e,i)=>t.indexOf(e)===i),t},sanitizeWell:function(e){let t={};return this.fieldList.forEach((function(i){t[i.id]=i.parseValue(e[i.id])})),t},setData:function(e,t){this.engine.derivative=e.derivative,this.setCheckboxes(e.checkboxes,!0),this.setSelectedIndices(e.selectedIndices,!0),this.derivativeChange(),t||this.addToUndoRedo()}}};plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.overlay=function(){return{_createOverLay:function(){let e=this;this.overLayTextContainer=this._createElement("<div></div>").addClass("plate-setup-overlay-text-container"),this.overLayTextContainer.text("Completion Percentage:"),this.overLayContainer.append(this.overLayTextContainer),this.overLayButtonContainer=this._createElement("<div></div>").addClass("plate-setup-overlay-button-container"),this.overLayContainer.append(this.overLayButtonContainer),this.clearCriteriaButton=this._createElement("<button />").addClass("plate-setup-button"),this.clearCriteriaButton.text("Clear"),this.overLayButtonContainer.append(this.clearCriteriaButton),this.clearCriteriaButton.click((function(){e.clearCriteria()})),this.copyCriteriaButton=this._createElement("<button />").addClass("plate-setup-button"),this.copyCriteriaButton.text("Copy"),this.overLayButtonContainer.append(this.copyCriteriaButton),this.copyCriteriaButton.click((function(){e.copyCriteria()})),this.pasteCriteriaButton=this._createElement("<button />").addClass("plate-setup-button"),this.pasteCriteriaButton.text("Paste"),this.overLayButtonContainer.append(this.pasteCriteriaButton),this.pasteCriteriaButton.click((function(){e.pasteCriteria()})),this.undoButton=this._createElement("<button />").addClass("plate-setup-button"),this.undoButton.text("Undo"),this.overLayButtonContainer.append(this.undoButton),this.undoButton.click((function(){e.undo()})),this.redoButton=this._createElement("<button />").addClass("plate-setup-button"),this.redoButton.text("Redo"),this.overLayButtonContainer.append(this.redoButton),this.redoButton.click((function(){e.redo()}))},clearCriteria:function(){if(this.selectedIndices&&this.selectedIndices.length){let t,i=!1,l=this.selectedIndices;for(let n=0;n<l.length;n++){let a=l[n];a in this.engine.derivative&&(this.disableAddDeleteWell?this.engine.derivative.hasOwnProperty(a)&&(t=e.extend(!0,{},this.emptyWellWithDefaultVal),this.engine.derivative[a]=t):delete this.engine.derivative[a],i=!0)}i&&(this._colorMixer(),this.decideSelectedFields(),this.derivativeChange(),this.addToUndoRedo())}else alert("Please select any well")},copyCriteria:function(){if(this.selectedIndices&&this.selectedIndices.length){let e=this._getSelectedWells();this.commonData=this._getCommonData(e)}else alert("Please select any well.")},pasteCriteria:function(){this.commonData&&(this._addAllData(this.commonData),this.decideSelectedFields())}}}}(jQuery),$.widget("DNA.plateMap",{plateMapWidget:{},options:{value:0},addressToLoc:function(e){let t=/^([A-Z]+)(\d+)$/.exec(e.trim().toUpperCase());if(t){let e=t[1],i=parseInt(t[2])-1,l=0;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t)-65;t?(l+=1,l*=26,l+=i):l=i}return{r:l,c:i}}throw e+" not a proper plate address"},locToIndex:function(e,t){if(t||(t=this.dimensions),!(e.r>=0&&e.r<t.rows))throw"Row index "+(e.r+1)+" invalid";if(!(e.c>=0&&e.c<t.cols))throw"Column index "+(e.c+1)+" invalid";return e.r*t.cols+e.c},addressToIndex:function(e,t){let i=this.addressToLoc(e);return this.locToIndex(i,t)},_rowKey:function(e){let t=e%26,i=(e-t)/26,l=String.fromCharCode(65+t);return i>0&&(l=String.fromCharCode(64+i)+l),l},_colKey:function(e){return(e+1).toString(10)},indexToLoc:function(e,t){if(t||(t=this.dimensions),e>=t.rows*t.cols)throw"Index too high: "+e.toString(10);let i={};return i.c=e%t.cols,i.r=(e-i.c)/t.cols,i},locToAddress:function(e){return this._rowKey(e.r)+this._colKey(e.c)},indexToAddress:function(e,t){let i=this.indexToLoc(e,t);return this.locToAddress(i)},getDimensions:function(){return $.extend(!0,{},this.dimensions)},_create:function(){let e=parseInt(this.options.numRows||8),t=parseInt(this.options.numCols||12);this.dimensions={rows:e,cols:t},this.rowIndex=[];for(let t=0;t<e;t++)this.rowIndex.push(this._rowKey(t));this.target=this.element[0].id?"#"+this.element[0].id:"."+this.element[0].className,this.options.readOnly&&this.isReadOnly(!0);for(let e in plateMapWidget)plateMapWidget.hasOwnProperty(e)&&$.extend(this,new plateMapWidget[e](this));return this._createInterface(),this._trigger("created",null,this),this},_init:function(){},getTextDerivative:function(e){let t={},i=this.fieldMap;for(let l in e){if(!e.hasOwnProperty(l))continue;let n={},a={},s=e[l];for(let e in s)if(s.hasOwnProperty(e))if(e in i){let t=i[e],l=t.parseText(s[e]);a[t.name]=l,n[e]=l}else a[e]=s[e],n[e]=s[e];t[l]={textVal:n,textFieldVal:a}}return t},getWellsDifferences:function(e){let t=[];for(let i in e)e.hasOwnProperty(i)&&t.push(e[i]);let i={};if(t.length>1){let l=this._getCommonWell(t),n={};for(let e in t[0])t[0].hasOwnProperty(e)&&(n[e]=[]);for(let t in e){if(!e.hasOwnProperty(t))continue;let a={},s=e[t];for(let e in s){if(!s.hasOwnProperty(e))continue;let t=l[e],i=s[e];void 0===t&&(t=null),void 0===i&&(i=null);let d=null;if(Array.isArray(i)){t=t||[],d=[];for(let l=0;l<i.length;l++){let a=i[l];a&&"object"==typeof a?this.containsObject(a,t)||(d.push(a),this.containsObject(a,n[e])||n[e].push(a)):t.indexOf(a)<0&&(d.push(a),!n[e].indexOf(a)>=0&&n[e].push(a))}}else i&&"object"==typeof i?t&&"object"==typeof t?i.value!==t.value&&i.unit!==t.unit&&(d=i,this.containsObject(i,n[e])||n[e].push(i)):(d=i,this.containsObject(i,n[e])||n[e].push(i)):i!==t&&(d=i,!n[e].indexOf(i)>=0&&n[e].push(i));a[e]=d}i[t]=a}for(let e in n)if(n.hasOwnProperty(e)&&0===n[e].length)for(let t in i)i.hasOwnProperty(t)&&delete i[t][e];return i}if(t.length>0){let t={};for(let i in e){if(!e.hasOwnProperty(i))continue;let l={},n=e[i];for(let e in n){if(!n.hasOwnProperty(e))continue;let t=n[e];Array.isArray(t)?t.length>0&&(l[e]=t):t&&(l[e]=t)}t[i]=l}return t}},setFieldsDisabled:function(e){this.fieldList.forEach((function(t){t.disabled(e)}))},isReadOnly:function(e){this.readOnly=!!e,this.readOnlyHandler()},readOnlyHandler:function(){this.readOnly?(this.overLayButtonContainer.css("display","none"),$(".multiple-field-manage-delete-button").css("display","none"),this.setFieldsDisabled(!0)):(this.overLayButtonContainer.css("display","flex"),$(".multiple-field-manage-delete-button").css("display","none"),this.disableAddDeleteWell||this.setFieldsDisabled(!1))},disableAddDeleteWell:null,isDisableAddDeleteWell:function(e,t){if(e){let e=$.extend(!0,{},this.defaultWell);if(t)for(let i in t)t.hasOwnProperty(i)&&(i in e?e[i]=t[i]:console.log("No field for key: "+key+", please contact support"));this.disableAddDeleteWell=!0,this.addressAllowToEdit=this.getWellSetAddressWithData(),this.actionPointer=0,this.undoRedoArray=[this.createState()],this.emptyWellWithDefaultVal=e}else this.disableAddDeleteWell=!1,this.emptyWellWithDefaultVal=null;this.readOnlyHandler()},selectObjectInBottomTab:function(){let e=[],t=this.selectedIndices;for(let i=0;i<t.length;i++){let l=t[i];if(this.engine.derivative[l]){let t=this.engine.colorMap.get(l);e.indexOf(t)<0&&e.push(t)}}let i=document.querySelectorAll("table.plate-setup-bottom-table tr");for(let t=1;t<i.length;t++){let l=i[t],n=l.children[0],a=e.indexOf(Number(n.querySelector("button").innerHTML))>=0;l.classList.toggle("selected",a)}},getSelectedIndices:function(){return this.selectedIndices.slice()},getSelectedAddresses:function(){return this.selectedIndices.map((function(e){return this.allTiles[e].address}),this)},setSelectedAddresses:function(e,t){let i=this.sanitizeAddresses(e);this.setSelectedIndices(i,t)},setSelectedIndices:function(e,t){e&&0!==e.length||(e=[0]),this.setSelection(e),this.decideSelectedFields(),this._trigger("selectedWells",null,{selectedAddress:this.getSelectedAddresses()}),this.selectObjectInBottomTab(),t||this.addToUndoRedo()}});plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.preset=function(){return{presets:[],_placePresetTabs:function(){let t=this.options.attributes.presets;if(t&&t.length){this.wellAttrContainer=this._createElement("<div></div>").addClass("plate-setup-well-attr-container").text("Checkbox presets"),this.tabContainer.append(this.wellAttrContainer),this.presetTabContainer=this._createElement("<div></div>").addClass("plate-setup-preset-container"),this.tabContainer.append(this.presetTabContainer);for(let i=0;i<t.length;i++){let l=t[i],n=this._createElement("<div></div>").addClass("plate-setup-preset-tab-div").text(l.title),a=this._createElement("<div></div>").addClass("plate-setup-preset-tab").data("preset",l.fields).append(n);this.presetTabContainer.append(a);let s=this;a.click((function(){let t=e(this);s._selectPreset(t)})),this.presets.push(a)}}},_clearPresetSelection:function(){for(let e=0;e<this.presets.length;e++){this.presets[e].removeClass("plate-setup-preset-tab-selected").addClass("plate-setup-preset-tab")}},_selectPreset:function(e){this.setCheckboxes(e.data("preset")),e.removeClass("plate-setup-preset-tab").addClass("plate-setup-preset-tab-selected")}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.svgCreate=function(){return{baseSizes:{spacing:48,tile_radius:22,center_radius_complete:10,center_radius_incomplete:14,label_size:14,label_spacing:24,text_size:13,stroke:.5,gap:2},allTiles:[],_createSvg:function(){this.svg=new e(this.canvasContainer[0]),this.svg.attr("preserveAspectRatio","xMidYMin meet");let t=this.baseSizes.label_spacing;this.svg.viewbox(-t,-t,t+this.dimensions.cols*this.baseSizes.spacing,t+this.dimensions.rows*this.baseSizes.spacing),this.wellShadow=this.svg.gradient("radial",(function(e){e.at(.8,"rgba(0,0,0,0.1)"),e.at(1,"rgba(0,0,0,0.2)")})).from("50%","50%").to("50%","55%").radius("50%").attr("id","wellShadow"),this.wellColors=this.colorPairs.map((function(e,t){return this.svg.gradient("linear",(function(t){t.at(0,e[0]),t.at(1,e[1])})).from(0,0).to(0,1).id("wellColor"+t.toString())}),this),this._fixRowAndColumn(),this._putCircles(),this._svgEvents()},_fixRowAndColumn:function(){let e=this.dimensions.cols,t=this.dimensions.rows,i=this.svg.nested().attr({x:-this.baseSizes.label_spacing/2}).addClass("rowHead"),l=this.svg.nested().attr({y:-this.baseSizes.label_spacing/2}).addClass("colHead");for(let e=0;e<t;e++)i.plain(this._rowKey(e)).attr({y:this.baseSizes.spacing*(e+.5)});for(let t=0;t<e;t++)l.plain(this._colKey(t)).attr({x:this.baseSizes.spacing*(t+.5)})},_putCircles:function(){let e=this.dimensions.cols,t=this.dimensions.rows;this.allTiles=Array(e*t);for(let i=0;i<t;i++)for(let t=0;t<e;t++){let e=this._createTile(i,t);this.allTiles[e.index]=e}},_createTile:function(e,t){let i=this.svg.nested().move(this.baseSizes.spacing*t,this.baseSizes.spacing*e).addClass("tile"),l=this.baseSizes.spacing/2,n={tile:i};n.r=e,n.c=t,n.index=this.locToIndex(n),n.address=this.locToAddress(n),i.rect(this.baseSizes.spacing,this.baseSizes.spacing).addClass("highlight"),i.circle(2*this.baseSizes.tile_radius).center(l,l).addClass("well").fill(this.wellShadow);let a=i.group().addClass("fill");return n.circle=a.circle(2*this.baseSizes.tile_radius).center(l,l).addClass("circle").fill(this.wellColors[0]),a.circle(2*this.baseSizes.center_radius_complete).center(l,l).addClass("center"),a.circle(2*this.baseSizes.center_radius_incomplete).center(l,l).addClass("center_incomplete"),n.label=a.plain("0").attr({x:l,y:l}).addClass("label"),n},setTileComplete:function(e,t){t?e.tile.removeClass("incomplete"):e.tile.addClass("incomplete")},setTileVisible:function(e,t){t?e.tile.removeClass("empty"):e.tile.addClass("empty")},setTileColor:function(e,t){this.setTileVisible(e,!0),e.colorIndex=parseInt(t),e.label.plain(String(e.colorIndex)),t>0&&(t=(t-1)%(this.wellColors.length-1)+1),e.circle.fill(this.wellColors[t])}}}}(SVG);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.svgEvents=function(){return{colorToIndex:{},selectedIndices:[],_svgEvents:function(){let t,i=this;function l(e){let t=i.svg.node.getScreenCTM();return{x:(e.clientX-t.e)/t.a,y:(e.clientY-t.f)/t.d}}function n(e,t){return t-=1,e<0?0:e>=t?t:Math.trunc(e)}function a(e){let t=i.baseSizes.spacing,l=n(e.x/t,i.dimensions.cols);return{r:n(e.y/t,i.dimensions.rows),c:l}}function s(e,t){let l=a(e),n=a(t),s=i.baseSizes.spacing,d=Math.min(l.c,n.c)*s,o=Math.min(l.r,n.r)*s;return e.x<0&&(l.c=i.dimensions.cols-1),e.y<0&&(l.r=i.dimensions.rows-1),{x:d,y:o,width:(Math.max(l.c,n.c)+1)*s-d,height:(Math.max(l.r,n.r)+1)*s-o}}function d(e){if(t){!function(e,t,l){let n=a(e),s=a(t),d=!0;if(l){let e=i.locToIndex(n);d=i.selectedIndices.indexOf(e)<0}let o=Math.min(n.c,s.c),r=Math.min(n.r,s.r);e.x<0&&(n.c=i.dimensions.cols-1),e.y<0&&(n.r=i.dimensions.rows-1);let u=Math.max(n.c,s.c),c=Math.max(n.r,s.r),p=[];for(let e=r;e<=c;e++)for(let t=o;t<=u;t++){let l=i.locToIndex({r:e,c:t});p.push(l)}l&&(d?i.selectedIndices.forEach((function(e){p.indexOf(e)<0&&p.push(e)})):p=i.selectedIndices.filter(e=>p.indexOf(e)<0)),i.setSelectedIndices(p.sort((e,t)=>e-t))}(t.data("origin"),l(e),e.shiftKey),t.remove(),t=null}}this.svg.node.addEventListener("mousedown",(function(e){t&&t.remove();let n=l(e),a=s(n,n);t=i.svg.rect().attr(a).fill("rgba(0, 0, 1, 0.2)"),t.data("origin",n)})),this.svg.node.addEventListener("mousemove",(function(e){if(t){let i=l(e),n=s(t.data("origin"),i);t.attr(n)}})),this.svg.node.addEventListener("mouseleave",d),this.svg.node.addEventListener("mouseup",d),e(i.target).on("loadPlate",(function(e,t){i.loadPlate(JSON.parse(t))}))},setSelection:function(e){this.selectedIndices=e,this._setSelectedTiles(),document.activeElement.blur()},_setSelectedTiles:function(){let e=this.selectedIndices;this.allTiles.forEach((function(t){e.indexOf(t.index)>=0?t.tile.addClass("selected"):t.tile.removeClass("selected")}))},_getSelectedWells:function(){return this.selectedIndices.map((function(e){let t=this.engine.derivative[e];return t||(t=this.defaultWell),t}),this)},containsObject:function(e,t){function i(e,t){if(e===t)return!0;if("object"==typeof e&&null!=e&&"object"==typeof t&&null!=t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let l in e)if(e.hasOwnProperty(l)){if(!t.hasOwnProperty(l))return!1;if(!i(e[l],t[l]))return!1}return!0}return!1}if(t)for(let l=0;l<t.length;l++)if(i(e,t[l]))return!0;return!1},_buildCommonData:function(t,i,l){let n=t[l];void 0===n&&(n=null);let a=i[l];if(void 0===a&&(a=null),Array.isArray(n)){let i=[];if(!a)return void(t[l]=i);for(let t=0;t<n.length;t++){let s=n[t];if(s&&"object"==typeof s)for(let t=0;t<a.length;t++){let n=a[t];if(s[l]==n[l]){s=e.extend(!0,{},s);for(let e in s)this._buildCommonData(s,n,e);i.push(s)}}else e.inArray(s,a)>=0&&i.push(s)}t[l]=i}else a&&"object"==typeof a&&n&&"object"==typeof n?a.value===n.value&&a.unit===n.unit||delete t[l]:n!==a&&delete t[l]},_getCommonData:function(t){let i=null;for(let l=0;l<t.length;l++){let n=t[l];if(null!=n)if(null!=i)for(let e in i)i.hasOwnProperty(e)&&this._buildCommonData(i,n,e);else i=e.extend(!0,{},t[0])}return i||this.defaultWell},_getCommonWell:function(e){let t=this._getCommonData(e);return this.sanitizeWell(t)},_getAllMultipleVal:function(t){let i=this.multipleFieldList,l=this;i.forEach((function(i){if(t.length){let n={},a=null;t.forEach((function(t){if(null==t)return;let s=i.id,d=t[s];d&&d.length&&d.forEach((function(t){if("object"==typeof t){if(null==a)a=e.extend(!0,{},t);else for(let e in a)l._buildCommonData(a,t,e);t[s]in n?n[t[s]]++:n[t[s]]=1}else t in n?n[t]++:n[t]=1}))})),i.allSelectedMultipleData=a||{},i.allSelectedMultipleVal=n}else i.allSelectedMultipleData=null,i.allSelectedMultipleVal=null}))},decideSelectedFields:function(){let e=this._getSelectedWells();this._getAllMultipleVal(e),this.applyFieldWarning(e);let t=this._getCommonWell(e);this._addDataToTabFields(t)},getWellSetAddressWithData:function(){return Object.keys(this.engine.derivative).map(Number).sort((e,t)=>e-t).map(e=>this.indexToAddress(e))}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.tabs=function(){return{allTabs:[],defaultWell:{},allDataTabs:[],_createTabAtRight:function(){this.tabContainer=this._createElement("<div></div>").addClass("plate-setup-tab-container"),e(this.topRight).append(this.tabContainer)},_createTabs:function(){this.tabHead=this._createElement("<div></div>").addClass("plate-setup-tab-head"),e(this.tabContainer).append(this.tabHead);let t=this.options.attributes.tabs,i=this;t.forEach((function(t,l){i.allTabs[l]=i._createElement("<div></div>").addClass("plate-setup-tab"),e(i.allTabs[l]).data("index",l).text(t.name),e(i.allTabs[l]).click((function(){i._tabClickHandler(this)})),e(i.tabHead).append(i.allTabs[l])})),this.tabDataContainer=this._createElement("<div></div>").addClass("plate-setup-tab-data-container"),e(this.tabContainer).append(this.tabDataContainer),this._addDataTabs(t),e(this.allTabs[0]).click(),this._addTabData()},_tabClickHandler:function(t){if(this.selectedTab){e(this.selectedTab).removeClass("plate-setup-tab-selected").addClass("plate-setup-tab");let t=e(this.selectedTab).data("index");e(this.allDataTabs[t]).css("z-index",0),this.readOnlyHandler()}e(t).addClass("plate-setup-tab-selected"),this.selectedTab=t;let i=e(t).data("index");e(this.allDataTabs[i]).css("z-index",1e3)},_addDataTabs:function(t){this.allDataTabs=t.map((function(){return this._createElement("<div></div>").addClass("plate-setup-data-div").css("z-index",0)}),this),e(this.tabDataContainer).append(this.allDataTabs)}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.undoRedoManager=function(){return{undoRedoArray:[],actionPointer:null,addToUndoRedo:function(){let e=this.createState();if(null!=this.actionPointer){let e=this.actionPointer+1;e<this.undoRedoArray.length&&this.undoRedoArray.splice(e,this.undoRedoArray.length-e)}this.actionPointer=null,this.undoRedoArray.push(e)},_configureUndoRedoArray:function(){this.undoRedoArray=[],this.actionPointer=null,this.undoRedoArray.push(e.extend({},{checkboxes:[],derivative:{},selectedIndices:[0]}))},clearHistory:function(){this.undoRedoArray=this.undoRedoArray.slice(-1),this.actionPointer=null},undo:function(){return console.log("undo"),this.shiftUndoRedo(-1)},redo:function(){return console.log("redo"),this.shiftUndoRedo(1)},shiftUndoRedo:function(e){let t=this.actionPointer;return null==t&&(t=this.undoRedoArray.length-1),t+=e,this.setUndoRedo(t)},setUndoRedo:function(e){return!(e<0)&&(!(e>=this.undoRedoArray.length)&&(this.actionPointer=e,this.setData(this.undoRedoArray[e],!0),!0))}}}}(jQuery);//# sourceMappingURL=plate-map.min.js.map
1
+ var plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.addDataOnChange=function(){return{_addAllData:function(t){if(this.selectedIndices){let i=this.selectedIndices.length;this.selectedIndices.forEach((function(l){let n;l in this.engine.derivative?n=this.engine.derivative[l]:(n=e.extend(!0,{},this.defaultWell),this.engine.derivative[l]=n),n=this.processWellData(t,n,i),this.engine.wellEmpty(n)&&(this.disableAddDeleteWell?this.engine.derivative.hasOwnProperty(l)&&(n=e.extend(!0,{},this.emptyWellWithDefaultVal),this.engine.derivative[l]=n):delete this.engine.derivative[l])}),this)}this.decideSelectedFields(),this._colorMixer(),this.derivativeChange(),this.addToUndoRedo()},processWellData:function(e,t,i){for(let l in e){if(!e.hasOwnProperty(l))continue;let n=e[l];if(null!=n){if(n.multi){let e=t[l];n=this._getMultiData(e,n,l,i)}n=JSON.parse(JSON.stringify(n))}else n=null;t[l]=n}return t},_getMultiData:function(e,t,i,l){let n=t.added,a=t.removed;if(e=e||[],n)if(n.value){const t=n.id.toString(),l="[ALL]"===t;let a=!l;e=e.map((function(e){if(l||e[i].toString()===t){a=!1;for(let t in n.value)t!==i&&(e[t]=n.value[t]);return e}return e})),a&&e.push(n.value)}else e.indexOf(n)<0&&e.push(n);let s=function(e,t){let i=[];for(let l in e)e.hasOwnProperty(l)&&parseInt(l)!==parseInt(t)&&i.push(e[l]);return i};if(a){let t;if(a.value){for(let l in e){e[l][i].toString()===a.id.toString()&&(t=l)}e=s(e,t)}else e&&(t=e.indexOf(a),t>=0&&(e=s(e,t)))}return e&&0===e.length&&(e=null),e},_colorMixer:function(){this.engine.searchAndStack(),this.engine.applyColors()},derivativeChange:function(){this._trigger("updateWells",null,this)},createState:function(){return{derivative:e.extend(!0,{},this.engine.derivative),checkboxes:this.getCheckboxes(),selectedIndices:this.selectedIndices.slice(),requiredField:this.requiredField}},getPlate:function(){let t={},i=this.engine.derivative;for(let l in i){if(!i.hasOwnProperty(l))continue;let n=this.indexToAddress(l),a=i[l];t[n]=e.extend(!0,{},a)}return{wells:t,checkboxes:this.getCheckboxes(),selectedAddresses:this.getSelectedAddresses(),requiredField:this.requiredField}}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).addDataToFields=function(){return{_addDataToTabFields:function(e){for(let t=0;t<this.fieldList.length;t++){let i=this.fieldList[t],l=e[i.id];void 0===l&&(l=null),i.setValue(l)}}}};plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.addTabData=function(){return{fieldList:[],fieldMap:{},autoId:1,_addTabData:function(){let e=this.options.attributes.tabs,t=this;this.requiredField=[];let i=[];e.forEach((function(e,l){if(e.fields){let a=e.fields,s=[];for(var n=0;n<a.length;n++){let e,d=a[n];d.id||(d.id="Auto"+t.autoId++,console.log("Field autoassigned id "+d.id)),d.type||(d.type="text",console.log("Field "+d.id+" autoassigned type "+d.type)),"multiplex"===d.type?(e=t._makeMultiplexField(d,l,s),t.defaultWell[e.id]=[],i.push(e)):(e=t._makeRegularField(d,l,s,!0),"multiselect"===d.type?(t.defaultWell[e.id]=[],i.push(e)):t.defaultWell[e.id]=null)}t.allDataTabs[l].fields=s}else console.log("unknown format in field initialization")})),t.multipleFieldList=i},_makeSubField:function(t,i,l,n){let a=this;i.id||(i.id="Auto"+a.autoId++,console.log("Field autoassigned id "+i.id)),i.type||(i.type="text",console.log("Field "+i.id+" autoassigned type "+i.type));let s=a._createElement("<div></div>").addClass("plate-setup-tab-default-field"),d=a._createElement("<div></div>").addClass("plate-setup-tab-field-left-side"),o=a._createElement("<div></div>").addClass("plate-setup-tab-field-right-side"),r=a._createElement("<div></div>").addClass("plate-setup-tab-name").text(i.name),u=a._createElement("<div></div>").addClass("plate-setup-tab-field-container");e(o).append(r),e(o).append(u),e(s).append(d),e(s).append(o),e(a.allDataTabs[l]).append(s);let c={id:i.id,full_id:t.id+"_"+i.id,name:i.name,root:s,data:i,required:i.required||!1};return n.push(c),a.fieldMap[c.full_id]=c,c},_makeRegularField:function(e,t,i,l){let n=this,a=n._createElement("<div></div>").addClass("plate-setup-tab-default-field"),s=n._createElement("<div></div>").addClass("plate-setup-tab-field-left-side"),d=n._createElement("<div></div>").addClass("plate-setup-tab-field-right-side "),o=n._createElement("<div></div>").addClass("plate-setup-tab-name").text(e.name),r=n._createElement("<div></div>").addClass("plate-setup-tab-field-container");d.append(o),d.append(r),a.append(s),a.append(d),n.allDataTabs[t].append(a);let u={id:e.id,full_id:e.id,name:e.name,root:a,data:e,required:e.required};return u.required&&n.requiredField.push(u.id),i.push(u),n.fieldList.push(u),n.fieldMap[u.full_id]=u,l&&n._addCheckBox(u),n._createField(u),u.onChange=function(){let e=u.getValue(),t={};t[u.id]=e,n._addAllData(t)},u},_makeMultiplexField:function(e,t,i){let l=this,n=l._createElement("<div></div>").addClass("plate-setup-tab-default-field"),a=l._createElement("<div></div>").addClass("plate-setup-tab-field-left-side"),s=l._createElement("<div></div>").addClass("plate-setup-tab-field-right-side "),d=l._createElement("<div></div>").addClass("plate-setup-tab-name").text(e.name),o=l._createElement("<div></div>").addClass("plate-setup-tab-field-container");s.append(d),s.append(o),n.append(a),n.append(s),l.allDataTabs[t].append(n);let r={id:e.id,full_id:e.id,name:e.name,root:n,data:e,required:e.required};i.push(r),l.fieldList.push(r),l.fieldMap[r.full_id]=r;let u=[],c=[];for(let n=0;n<e.multiplexFields.length;n++){let a=e.multiplexFields[n],s=l._makeSubField(r,a,t,i);u.push(s),a.required&&c.push(s.id)}return(r.required||c.length)&&this.requiredField.push({multiplexId:r.id,subFields:c}),r.subFieldList=u,l._createField(r),l._addCheckBox(r),u.forEach((function(e){e.mainMultiplexField=r,l._createField(e),l._addCheckBox(e),e.onChange=function(){let t=e.getValue(),i=e.mainMultiplexField,l=i.singleSelectValue(),n={};n[i.id]=l,n[e.id]=t;let a={id:l,value:n};r._changeMultiFieldValue(a,null);let s=i.detailData;null!==s&&(l=i.singleSelectValue(),s=s.map((function(n){return n[i.id]===l&&(n[e.id]=t),n}))),i.detailData=s}})),r}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.addWarningMsg=function(){return{fieldWarningMsg:function(t,i,l){let n="fieldWarning"+t.full_id,a=e("<span>").html(this._assets.warningImg).attr("id",n).addClass("plate-field-warning-image");if(l){if(t.root.find("#"+n).length<=0){t.root.find(".plate-setup-tab-name").text(" "+t.name),t.root.find(".plate-setup-tab-name").prepend(a);let l=e("<div/>").addClass("pop-out-text");l.text(i),t.root.find(".plate-setup-tab-name").append(l),e("#"+n).hover((function(){l[0].style.display="flex"}),(function(){l.hide()}))}}else t.root.find("#"+n).length>0&&(t.root.find(".plate-setup-tab-name").text(t.name),e("#"+n).remove())},removeWarningMsg:function(t,i,l){let n=this,a="fieldWarning"+t.full_id;if(l){let l=e("<span>").html(n._assets.warningImg).attr("id",a).addClass("plate-field-warning-image");t.root.find(".plate-setup-tab-name").append(l);let s=e("<div/>").addClass("pop-out-text");s.text(i),t.root.find(".plate-setup-tab-name").append(s),l.hover((function(){s[0].style.display="inline-block"}),(function(){s.hide()}))}else e("#"+a).remove()},applyFieldWarning:function(e){let t=this,i={};t.fieldList.forEach((function(e){i[e.id]=[]})),e.forEach((function(e){if(!t.engine.wellEmpty(e))for(let t in i)i.hasOwnProperty(t)&&(t in e?i[t].push(e[t]):i[t].push(null))}));for(let e=0;e<t.fieldList.length;e++){let l=t.fieldList[e];if(l.applyMultiplexSubFieldColor)l.applyMultiplexSubFieldColor(i[l.id]);else if(l.required){let e=!1;i[l.id].forEach((function(t){t instanceof Array?0===t.length&&(e=!0):null===t&&(e=!0)})),t.fieldWarningMsg(l,"required field",e)}}}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.bottomTable=function(){return{_bottomScreen:function(){this.bottomContainer=this._createElement("<div></div>").addClass("plate-setup-bottom-container"),this.bottomTableContainer=this._createElement("<div></div>").addClass("plate-setup-bottom-table-container"),this.bottomTable=this._createElement("<table></table>").addClass("plate-setup-bottom-table"),this.bottomTableHead=this._createElement("<thead></thead>"),this.bottomTableBody=this._createElement("<tbody></tbody>"),this.bottomTable.append(this.bottomTableHead),this.bottomTable.append(this.bottomTableBody),this.bottomTableContainer.append(this.bottomTable),this.bottomContainer.append(this.bottomTableContainer),this.container.append(this.bottomContainer)},addBottomTableHeadings:function(){let e=this._createElement("<tr></tr>"),t=this._createElement("<th></th>").text("Group");e.html(t),this.rowCounter=1;for(let t=0;t<this.globalSelectedAttributes.length;t++){let i=this.globalSelectedAttributes[t],l=this.fieldMap[i],n=this._createElement("<th></th>").text(l.name);e.append(n),this.rowCounter=this.rowCounter+1}this.bottomTableBody.empty(),this.bottomTableHead.empty(),this.bottomTableHead.append(e),this.adjustFieldWidth(e)},tileAttrText:function(e,t){let i=this.engine.derivative[e.index];return this.fieldMap[t].getText(i[t])},addBottomTableRow:function(e,t){let i=this,l=this.allTiles[t[0]],n=this._createElement("<tr></tr>"),a=this._createElement("<td></td>").addClass("plate-setup-bottom-id"),s=this._createElement("<button type='button'/>");s.addClass("plate-setup-color-text"),s.text(e),a.append(s),s.click((function(e){let l=t.map(e=>i.indexToAddress(e));e.ctrlKey&&i.getSelectedAddresses().forEach((function(e){l.indexOf(e)<0&&l.push(e)})),i.setSelectedAddresses(l)})),e>0&&(e=(e-1)%(this.colorPairs.length-1)+1);let d=this.colorPairs[e];a.css("background","linear-gradient(to right, "+d[0]+" , "+d[1]+")"),n.append(a);for(let e=0;e<this.globalSelectedAttributes.length;e++){let t=this.globalSelectedAttributes[e],i=this.tileAttrText(l,t),a=this._createElement("<td></td>").text(i);n.append(a)}this.bottomTableBody.append(n),this.adjustFieldWidth(n)},bottomForFirstTime:function(){this.addBottomTableHeadings();let e=this._createElement("<tr></tr>"),t=this.colorPairs[0],i=this._createElement("<td></td>");i.css("background","-webkit-linear-gradient(left, "+t[0]+" , "+t[1]+")"),e.append(i),this.bottomTableBody.append(e),this.createExportButton()},adjustFieldWidth:function(e){let t=this.rowCounter;150*t>1024&&e.css("width",152*t+"px")},downloadCSV:function(e,t){let i,l;i=new Blob([e],{type:"text/csv"}),l=document.createElement("a"),l.download=t,l.href=window.URL.createObjectURL(i),l.style.display="none",document.body.appendChild(l),l.click()},exportData:function(e){let t=[],i=document.querySelectorAll("table tr"),l={},n=this.engine.stackUpWithColor;for(let e in n)n.hasOwnProperty(e)&&(l[e]=n[e].map(e=>this.indexToAddress(e)));for(let n=0;n<i.length;n++){let a=[],s=i[n].querySelectorAll("td, th");for(let t=0;t<s.length;t++){let i="";if(s[t].innerText&&(i="csv"===e?'"'+s[t].innerText.replace(/"/g,'""')+'"':s[t].innerText),a.push(i),0===n&&0===t&&("csv"===e?a.push('"Location"'):"clipboard"===e&&a.push("Location")),0!==n&&0===t){let i="";l[parseInt(s[t].innerText)]&&("csv"===e?i='"'+l[parseInt(s[t].innerText)].join(",")+'"':"clipboard"===e&&(i=l[parseInt(s[t].innerText)].join(","))),a.push(i)}}"csv"===e?t.push(a.join(",")):"clipboard"===e&&t.push(a.join("\t"))}if("csv"===e)this.downloadCSV(t.join("\n"),"table.csv");else if("clipboard"===e)return t.join("\n")},createExportButton:function(){let t=this,i=e("<div>").addClass("plate-setup-bottom-control-container"),l=e("<div>").addClass("plate-setup-overlay-text-container");l.text("Color groups"),i.append(l);let n=e("<div>").addClass("plate-setup-overlay-bottom-button-container"),a=e("<button type='button'/>").addClass("plate-setup-button");function s(){a.text("Export CSV"),a[0].classList.remove("plate-setup-clicked-button"),a.addClass("plate-setup-button")}a.text("Export CSV"),n.append(a),a.click((function(){t.exportData("csv"),a.text("Exported"),a[0].classList.remove("plate-setup-button"),a.addClass("plate-setup-clicked-button"),setTimeout(s,3e3)}));let d=e("<button type='button'/>").addClass("plate-setup-button");d.text("Copy To Clipboard"),n.append(d);let o=new ClipboardJS(d.get(0),{text:function(){return t.exportData("clipboard")}});function r(){d.text("Copy To Clipboard"),d[0].classList.remove("plate-setup-clicked-button"),d.addClass("plate-setup-button")}o.on("success",(function(){d.text("Copied as tab-delimited format"),d[0].classList.remove("plate-setup-button"),d.addClass("plate-setup-clicked-button"),setTimeout(r,3e3)})),o.on("error",(function(){d.text("Failed to copy table to clipboard: browser may be incompatible"),setTimeout(r,3e3)})),i.append(n),this.bottomContainer.prepend(i)}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.checkBox=function(){return{globalSelectedAttributes:[],globalSelectedMultiplexSubfield:[],allCheckboxes:[],_addCheckBox:function(t){let i=e("<span>").html(this._assets.dontImg).addClass("plate-setup-tab-check-box bg-light").data("clicked",!1),l=t.full_id;i.data("linkedFieldId",l),t.root.find(".plate-setup-tab-field-left-side").empty().append(i),this._applyCheckboxHandler(i),t.checkbox=i,this.allCheckboxes.push(l)},_applyCheckboxHandler:function(t){let i=this;t.click((function(){let t=e(this),l={};l[t.data("linkedFieldId")]=!t.data("clicked"),i.changeCheckboxes(l)}))},getCheckboxes:function(){return this.allCheckboxes.filter((function(e){let t=this.fieldMap[e];if(t.mainMultiplexField){return(this.globalSelectedMultiplexSubfield[t.mainMultiplexField.id]||[]).indexOf(t.id)}return this.globalSelectedAttributes.indexOf(t.id)>=0}),this)},changeSubFieldsCheckboxes:function(e,t){let i=this,l=[];return e.subFieldList.forEach((function(e){let n=e.checkbox,a=n.data("linkedFieldId"),s=n.data("clicked");a in t&&(s=Boolean(t[a])),n.data("clicked",s),s?(n.html(i._assets.doImg),l.push(e.id)):n.html(i._assets.dontImg)})),l},changeCheckboxes:function(e,t){let i=[],l={};for(let t=0;t<this.fieldList.length;t++){let n=this.fieldList[t];if(n.checkbox){n.subFieldList&&(l[n.id]=this.changeSubFieldsCheckboxes(n,e));let t=n.checkbox,a=t.data("linkedFieldId"),s=t.data("clicked");a in e&&(s=Boolean(e[a])),t.data("clicked",s),s?(i.push(a),t.html(this._assets.doImg)):t.html(this._assets.dontImg)}}this.globalSelectedMultiplexSubfield=l,this.globalSelectedAttributes=i,this._clearPresetSelection(),this._colorMixer(),t||this.addToUndoRedo()},setSubFieldCheckboxes:function(e,t){let i=this,l=[];return e.subFieldList.forEach((function(e){let n=e.checkbox,a=n.data("linkedFieldId"),s=t.indexOf(a)>=0;n.data("clicked",s),s?(n.html(i._assets.doImg),l.push(e.id)):n.html(i._assets.dontImg)})),l},setCheckboxes:function(e,t){e=e||[];let i=[],l={};for(let t=0;t<this.fieldList.length;t++){let n=this.fieldList[t];if(n.checkbox){n.subFieldList&&(l[n.id]=this.setSubFieldCheckboxes(n,e));let t=n.checkbox,a=t.data("linkedFieldId"),s=e.indexOf(a)>=0;t.data("clicked",s),s?(i.push(a),t.html(this._assets.doImg)):t.html(this._assets.dontImg)}}this.globalSelectedMultiplexSubfield=l,this.globalSelectedAttributes=i,this._clearPresetSelection(),this._colorMixer(),t||this.addToUndoRedo()}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).colorManager=function(){return{colorPairs:[["#e6e6e6","#808080"],["#66e8ff","#0082c8"],["#ff7fb1","#e6194b"],["#a2ffb1","#3cb44b"],["#f784ff","#911eb4"],["#ffe897","#f58231"],["#6666ff","#0000FF"],["#ffff7f","#ffe119"],["#acffff","#46f0f0"],["#ff98ff","#f032e6"],["#ffffa2","#d2f53c"],["#ffffff","#fabebe"],["#66e6e6","#008080"],["#ffffff","#e6beff"],["#ffd48e","#aa6e28"],["#e66666","#800000"],["#ffffff","#aaffc3"],["#e6e666","#808000"],["#ffffff","#ffd8b1"],["#66a9ef","#004389"],["#ff6672","#a7000c"],["#66db72","#00750c"],["#b866db","#520075"],["#ffa966","#b64300"],["#ffff66","#c0a200"],["#6dffff","#07b1b1"],["#ff66ff","#b100a7"],["#f9ff66","#93b600"],["#ffe5e5","#bb7f7f"],["#66a7a7","#004141"],["#ffe5ff","#a77fc0"],["#d19566","#6b2f00"],["#ffffef","#c0bb89"],["#d1ffea","#6bc084"],["#a7a766","#414100"],["#ffffd8","#c09972"],["#a5ffff","#3fc1ff"],["#ffbef0","#ff588a"],["#e1fff0","#7bf38a"],["#ffc3ff","#d05df3"],["#ffffd6","#ffc170"],["#a5a5ff","#3f3fff"],["#ffffbe","#ffff58"],["#ebffff","#85ffff"],["#ffd7ff","#ff71ff"],["#a5ffff","#3fbfbf"],["#ffffcd","#e9ad67"],["#ffa5a5","#bf3f3f"],["#ffffa5","#bfbf3f"]]}};plateMapWidget=plateMapWidget||{};!function(e){function t(t){t.params.args.originalEvent?t.params.args.originalEvent.stopPropagation():e(this).one("select2:opening",(function(e){e.preventDefault()}))}function i(e){e.on("select2:unselecting",t)}function l(e,t,i){e.empty();let l=e.data("select2").dataAdapter;l.addOptions(l.convertToOptions(t)),e.val(i)}plateMapWidget.createField=function(){return{_createField:function(e){switch(e.data.type){case"text":this._createTextField(e),this._handleFieldUnits(e);break;case"numeric":this._createNumericField(e),this._handleFieldUnits(e);break;case"select":this._createSelectField(e),this._handleFieldUnits(e);break;case"multiselect":this._createMultiSelectField(e);break;case"boolean":this._createBooleanField(e);break;case"multiplex":this._createMultiplexField(e)}},_handleFieldUnits:function(e){let t=e.data,i=t.units||[],l=t.defaultUnit||null;l?i.length?i.indexOf(l)<0&&(l=i[0]):i=[l]:i.length&&(l=i[0]),i.length&&(e.units=i,e.hasUnits=!0,e.defaultUnit=l,this._makeFieldUnits(e))},_makeFieldUnits:function(t){let i=t.full_id,n=t.units,a=t.defaultUnit,s=null;if(t.disabledRegular=t.disabled,t.parseRegularValue=t.parseValue,t.setRegularValue=t.setValue,t.getRegularValue=t.getValue,t.getRegularText=t.getText,n.length)if(1===n.length){let i=e("<div></div>").addClass("plate-setup-tab-unit");i.text(a),t.root.find(".plate-setup-tab-field-container").append(i)}else{s=this._createElement("<select/>").attr("id",i+"Units").addClass("plate-setup-tab-unit-select-field"),t.root.find(".plate-setup-tab-field-container").append(s);let e=null,l={data:n.map((function(t){return t===a&&(e=t),{id:t,text:t}})),allowClear:!1,minimumResultsForSearch:10};s.select2(l),s.val(e)}t.disabled=function(e){return e=t.disabledRegular(e),s&&s.prop("disabled",e),e},t.parseValue=function(i){let l;return e.isPlainObject(i)?(l=t.parseRegularValue(i.value),null===l?null:{value:l,unit:t.parseUnit(i.unit)}):(l=t.parseRegularValue(i),null===l?null:{value:l,unit:t.defaultUnit})},t.getValue=function(){let e=t.getRegularValue();if(null===e)return null;{let i={value:e,unit:t.getUnit()};if(t.data.hasMultiplexUnit){let e=t.data.unitMap;for(let t in e){if(!e.hasOwnProperty(t))continue;e[t].forEach((function(e){e.text===i.unit&&(i.unitTypeId=t,i.unitId=e.id)}))}}return i}},t.setValue=function(i){e.isPlainObject(i)?(t.setUnit(i.unit||t.defaultUnit),t.setRegularValue(i.value)):(t.setRegularValue(i),t.setUnit(t.defaultUnit))},t.setUnitOpts=function(e){t.units=e||null,t.defaultUnit=null;let i=[],n=null;t.units&&t.units.length&&(t.defaultUnit=t.units[0],i=t.units.map((function(e){let i={id:e,text:e};return e===t.defaultUnit&&(n=e),i}))),l(s,i,n)},t.parseUnit=function(e){if(null==e||""===e)return t.defaultUnit;for(let t=0;t<n.length;t++)if(e.toLowerCase()===n[t].toLowerCase())return n[t];throw"Invalid unit "+e+" for field "+i},t.getUnit=function(){return s?s.val():t.defaultUnit},t.setUnit=function(e){s&&(e=e||t.defaultUnit,s.val(e),s.trigger("change.select2"))},t.getText=function(e){if("object"==typeof e&&e){let t=e.value,i=e.unit;return null==t?"":(t=t.toString(),i||(i=a),i&&(t=t+" "+i),t)}return t.getRegularText(e)},t.parseText=function(e){let i=t.parseValue(e);return i&&"object"==typeof i?t.getRegularText(i.value)+i.unit:null!=i?t.getRegularText(i):null},s&&s.on("change",(function(){t.onChange()})),t.unitInput=s},_createTextField:function(e){let t=this._createElement("<input>").attr("id",e.full_id).addClass("plate-setup-tab-input");e.root.find(".plate-setup-tab-field-container").append(t),e.parseValue=function(e){return e=e?String(e):null},e.getValue=function(){return t.val().trim()||null},e.setValue=function(e){document.activeElement!==t[0]&&t.val(e)},e.getText=function(e){return null==e?"":e},e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t},e.parseText=e.parseValue,t.on("input",(function(){e.onChange()})),e.input=t},_createOpts:function(e){let t={allowClear:!0,placeholder:"select"},i=!1;if(e.options&&(t.data=e.options,i=!0),e.ajax&&(t.ajax=ajax,i=!0),!i)throw"Must specify data or ajax";return t},_createSelectField:function(e){let t=e.full_id,l=this._createElement("<select/>").attr("id",t).addClass("plate-setup-tab-select-field").addClass("plate-setup-tab-input");e.root.find(".plate-setup-tab-field-container").append(l);let n=this._createOpts(e.data),a={};n.data.forEach((function(e){a[String(e.id)]=e})),l.select2(n),i(l);let s=function(e){let i=e;if(""===i&&(i=null),null==i)return null;if(i=String(i),i in a)return a[i].id;throw"Invalid value "+e+" for select field "+t};e.parseValue=s,e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t},e.getValue=function(){return s(l.val())},e.setValue=function(e){l.val(e),l.trigger("change.select2")},e.getText=function(e){return null==e?"":a[String(e)].text},e.parseText=function(e){let i=e;if(""===i&&(i=null),null==i)return null;if(i=String(i),i in a)return a[i].text;throw"Invalid text value "+e+" for select field "+t},l.on("change",(function(){e.onChange()})),e.input=l},_createMultiSelectField:function(e){let t=e.full_id,l=this,n=this._createElement("<select/>").attr("id",t).addClass("plate-setup-tab-multiselect-field");n.attr("multiple","multiple"),e.root.find(".plate-setup-tab-field-container").append(n);let a=l._createOpts(e.data);a.multiple=!0;let s={};a.data.forEach((function(e){s[String(e.id)]=e})),n.select2(a),i(n),e.disabled=function(t){return t=e.isDisabled||t,n.prop("disabled",t),t},e._parseOne=function(e){if((e=String(e))in s)return s[e].id;throw"Invalid value "+e+" for multiselect field "+t},e._parseMany=function(t){return t=t&&t.length?t.map(e._parseOne,this):null},e.parseValue=function(t){return e._parseMany(t)},e.getValue=function(){return e._parseMany(n.val())},e.setValue=function(e){e=e||[],n.val(e),n.trigger("change.select2")},e.getText=function(e){return null==e?"":e.length>0?e.map(e=>s[String(e)].text).join("; "):""},e.multiOnChange=function(t,i){t&&(t=t.id),i&&(i=i.id);let n={};n[e.id]={multi:!0,added:t,removed:i},l._addAllData(n)},e.parseText=function(e){let i=e;return i=i&&i.length?i.map((function(e){if((e=String(e))in s)return s[e].text;throw"Invalid text value "+e+" for multiselect field "+t})):null,i},n.on("select2:select",(function(t){let i=e._parseOne(t.params.data.id);i={id:i},e.multiOnChange(i,null)})),n.on("select2:unselect",(function(t){let i=e._parseOne(t.params.data.id);i={id:i},e.multiOnChange(null,i)})),e.input=n,l._createDeleteButton(e)},_createNumericField:function(e){let t=e.full_id,i=e.data,l=this._createElement("<input>").addClass("plate-setup-tab-input").attr("placeholder",i.placeholder||"").attr("id",t).attr("inputmode","decimal"),n="",a=/^-?\d*\.?\d*$/;e.root.find(".plate-setup-tab-field-container").append(l),e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t};let s=function(e){if(null==e)return null;let i=String(e).trim();if(""===i)return null;if(i=Number(i),isNaN(i))throw"Invalid value "+e+" for numeric field "+t;return i};e.parseValue=s,e.getValue=function(){let e=l.val().trim();return""===e?null:(e=Number(e),isNaN(e)?null:e)},e.setValue=function(e){document.activeElement!==l[0]&&(l.val(e),n=l.val())};let d=function(e){return null==e?"":e=e.toString()};e.getText=d,e.parseText=function(e){return d(s(e))},l.on("input",(function(){let t=l.val();t.indexOf("−")>=0&&(t=t.replace(/−/g,"-"),l.val(t)),a.test(t.trim())?(n=t,e.onChange()):l.val(n)})),e.input=l},_createBooleanField:function(e){let t=e.full_id,l=this._createElement("<select/>").attr("id",t).addClass("plate-setup-tab-select-field");e.root.find(".plate-setup-tab-field-container").append(l);let n={data:[{id:"true",text:"true"},{id:"false",text:"false"}],placeholder:"select",allowClear:!0,minimumResultsForSearch:-1};l.select2(n),i(l),e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),t},e.parseValue=function(e){if(null==e)return null;let i=String(e).trim().toLowerCase();if("true"===i)i=!0;else if("false"===i)i=!1;else{if(""!==i)throw"Invalid value "+e+" for boolean field "+t;i=null}return i},e.getValue=function(){switch(l.val()){case"true":return!0;case"false":return!1;default:return null}},e.setValue=function(e){e=1===e||!0===e||"true"===e?"true":0===e||!1===e||"false"===e?"false":null,l.val(e),l.trigger("change.select2")},e.getText=function(e){return null==e?"":e.toString()},e.parseText=e.parseValue,l.on("change",(function(){e.onChange()})),e.input=l},_createMultiplexField:function(e){let t=this;this._createMultiSelectField(e);let n=this._createElement("<div></div>").addClass("plate-setup-tab-name-singleSelect").text("Select to edit"),a=this._createElement("<div></div>").addClass("plate-setup-tab-field-container-singleSelect");e.root.find(".plate-setup-tab-field-right-side").append(n,a),e.singleSelect=this._createElement("<select/>").attr("id",e.full_id+"SingleSelect").addClass("plate-setup-tab-multiplex-single-select-field"),e.singleSelect.appendTo(a);e.singleSelect.select2({allowClear:!1,placeholder:"select",minimumResultsForSearch:10,data:[]}),i(e.singleSelect);let s=e.setValue;e.singleSelectValue=function(){let t=e.singleSelect.val();return""===t||null==t?null:"[ALL]"==t?t:e._parseOne(t)};let d=function(t,i){if(t=t||[],e.allSelectedMultipleVal){const i=Object.values(e.allSelectedMultipleVal).reduce((function(e,t){return e+t}),0);if(i){t=[{id:"[ALL]",text:`[${i} well ${e.data.name}]`,forAll:!0}].concat(t)}}i||(i=t.length?t[0].id:null),l(e.singleSelect,t,i),e.singleSelect.prop("disabled",0===t.length),e.singleSelect.trigger("change.select2")},o=function(){let i=e.singleSelectValue();e.updateSubFieldUnitOpts(i);let l=null;if("[ALL]"===i)l=e.allSelectedMultipleData;else{(e.detailData||[]).forEach((function(t){t[e.id]===i&&(l=t)}))}l?e.subFieldList.forEach((function(e){e.isDisabled=!1,e.setValue(l[e.id])})):e.subFieldList.forEach((function(e){e.isDisabled=!0,e.setValue(null)})),t.readOnlyHandler()};d([]),e.singleSelect.on("change.select2",o),e._changeMultiFieldValue=function(i,l){let n,a={};for(let t=0;t<e.subFieldList.length;t++){a[e.subFieldList[t].id]=null}i&&(i.value?n=i.value:(a[e.id]=i.id,n=a),i={id:i.id,value:n}),l&&(l.value?n=l.value:(a[e.id]=l.id,n=a),l={id:l.id,value:n});let s={};s[e.id]={multi:!0,added:i,removed:l},t._addAllData(s)},e.setValue=function(t){e.detailData=t;let i=null;t&&t.length&&(i=t.map(t=>t[e.id])),s(i);let l=e.input.select2("data")||[];d(l,e.singleSelectValue()),o()},e.disabled=function(t){return t=e.isDisabled||t,e.input.prop("disabled",t),e.subFieldList.forEach((function(e){e.disabled(t)})),t?n.text("Select to inspect"):n.text("Select to edit"),t},e.parseValue=function(t){let i=t;return i=i&&i.length?i.map((function(t){let i={};i[e.id]=t[e.id];for(let l in t)t.hasOwnProperty(l)&&e.subFieldList.forEach((function(e){e.id===l&&(i[e.id]=e.parseValue(t[l]))}));return i})):null,i},e.updateSubFieldUnitOpts=function(t){let i;e.data.options.forEach((function(e){e.id===t&&(i=e)})),e.subFieldList.forEach((function(e){e.data.hasMultiplexUnit&&(i&&i.hasOwnProperty("unitOptions")?e.setUnitOpts(i.unitOptions[e.id]):e.setUnitOpts(null))}))},e.multiOnChange=function(t,i){e._changeMultiFieldValue(t,i);let l=e.getValue(),n=e.detailData,a=[],s=null;n&&(a=n.map(t=>t[e.id]));let r=[],u=[];if(l){l.forEach((function(t){if(n&&n.forEach((function(i){i[e.id]===t&&r.push(i)})),a.indexOf(t)<0){let i={};i[e.id]=t,e.updateSubFieldUnitOpts(t),e.subFieldList.forEach((function(l){if(l.hasUnits)if(l.data.hasMultiplexUnit)l.disabled(!1),e.data.options.forEach((function(e){if(e.id===t){let e={value:null,unit:l.units[0]};i[l.id]=l.parseValue(e)}}));else{l.data.units&&l.data.units.length>1&&l.disabled(!1);let e={value:null,unit:l.defaultUnit};i[l.id]=l.parseValue(e)}else i[l.id]=l.parseValue(null)})),r.push(i)}})),l.forEach((function(t){e.data.options.forEach((function(e){e.id===t&&u.push(e)}))}));let i=e.singleSelectValue();for(let e=0;e<l.length;e++){if(t&&t.id===l[e]){s=l[e];break}(0===e||l[e]===i)&&(s=l[e])}}e.detailData=r,d(u,s),o()},e.getText=function(i){if(null===i)return"";if(e.id in t.globalSelectedMultiplexSubfield){let l=t.globalSelectedMultiplexSubfield[e.id],n=[];for(let t in i){if(!i.hasOwnProperty(t))continue;let a=i[t],s=[];for(let t in e.data.options)if(e.data.options.hasOwnProperty(t)){let i=e.data.options[t];i.id===a[e.id]&&s.push(i.text)}e.subFieldList.forEach((function(e){if(l.indexOf(e.id)>=0){let t=e.getText(a[e.id]);s.push(e.name+": "+t)}})),n.push("{"+s.join(", ")+"}")}return n.join(";")}},e.parseText=function(t){if(null===t)return"";{let i=[];for(let l in t){if(!t.hasOwnProperty(l))continue;let n=t[l],a=[];for(let t in e.data.options)if(e.data.options.hasOwnProperty(t)){let i=e.data.options[t];i.id===n[e.id]&&a.push(i.text)}e.subFieldList.forEach((function(e){let t=e.getText(n[e.id]);t&&a.push(t)})),i.push(a)}return i}},e.checkMultiplexCompletion=function(t){let i=0,l=0,n=!1;function a(t){let i=0,l=0;for(let a in e.subFieldList){if(!e.subFieldList.hasOwnProperty(a))continue;let s=e.subFieldList[a],d=t[s.id];s.required&&(n=!0,i++,"object"==typeof d&&d?d.value&&l++:d&&l++)}return l/i}if(t)if(t.length>0){for(let e in t)if(t.hasOwnProperty(e)){i++,l+=a(t[e])}}else e.required&&(n=!0,i=1);else e.required&&(n=!0,i=1);return{include:n,completionPct:l/i}},e.applyMultiplexSubFieldColor=function(i){let l={};e.subFieldList.forEach((function(e){e.required&&(l[e.id]={field:e,warningStatus:[]})})),i.forEach((function(t){!function(t){for(let i in e.subFieldList){if(!e.subFieldList.hasOwnProperty(i))continue;let n=e.subFieldList[i];if(null===t)e.required&&n.required&&l[n.id].warningStatus.push(!0);else if("object"==typeof t)if(0===t.length)e.required&&n.required&&l[n.id].warningStatus.push(!0);else for(let e in t){if(!t.hasOwnProperty(e))continue;let i=t[e][n.id];n.required&&("object"==typeof i&&i?i.value?l[n.id].warningStatus.push(!1):l[n.id].warningStatus.push(!0):i?l[n.id].warningStatus.push(!1):l[n.id].warningStatus.push(!0))}}}(t)}));let n=[];for(let i in l){if(!l.hasOwnProperty(i))continue;let a=l[i].field;if(l[i].warningStatus.indexOf(!0)>=0){let i=a.name+" is a required subfield for "+e.name+", please make sure all "+e.name+" have "+a.name;e.required,t.fieldWarningMsg(a,i,!0),n.push(!0)}else t.fieldWarningMsg(a,"none",!1),n.push(!1)}let a,s=n.indexOf(!0)>=0;a=e.required?e.name+" is a required field, please also fix missing required subfield(s) below":e.name+" is not a required field, please fix missing required subfield(s) below or remove selected "+e.name,t.fieldWarningMsg(e,a,s)},e.parseMainFieldVal=function(t){let i=e.data.options;for(let e=0;e<i.length;e++){let l=i[e];if(l.id===t)return l.text}}},_deleteDialog:function(t){let i,l=this,n=t.allSelectedMultipleVal;i=n?Object.keys(n):[];let a=e("<div/>").addClass("plate-modal");function s(){a.hide(),a.remove()}this.container.append(a);let d=e("<div/>").addClass("plate-modal-content").css("width","550px").appendTo(a),o=e("<div/>").appendTo(d),r=e("<div/>").addClass("dialog-buttons").css("justify-content","flex-end").appendTo(d);if(i.length>0){e("<p/>").text(t.name+" in selected wells: choose items to delete and click the delete button below").appendTo(o);let i=l._deleteDialogTable(t,n);if(i.appendTo(o),i.addClass("plate-popout-table"),i.find("td").addClass("plate-popout-td"),i.find("th").addClass("plate-popout-th"),i.find("tr").addClass("plate-popout-tr"),!l.readOnly){let n=e("<button type='button' class='multiple-field-manage-delete-button'>Delete Checked Items</button>");r.append(n),n.click((function(){i.find("input:checked").each((function(){let e=this.value;t.multiOnChange(null,{id:e})})),l.decideSelectedFields(),s()}))}}else e("<p/>").text("No "+t.name+" in the selected wells").appendTo(o);let u=e("<button type='button'>Cancel</button>");r.append(u),u.click(s),a.show(),window.onclick=function(e){e.target===a[0]&&s()}},_deleteDialogTable:function(t,i){let l=this,n=[t.name,"Counts"];l.readOnly||n.push("Delete");let a=e("<table/>"),s=e("<thead/>").appendTo(a);e("<tr/>").appendTo(s).append(n.map((function(t){return e("<th/>").text(t)})));let d=e("<tbody/>").appendTo(a);return t.data.options.forEach((function(t){if(t.id in i){let n=e("<tr/>").appendTo(d),a=e("<input type='checkbox'>").prop("value",t.id);e("<td/>").text(t.text).appendTo(n),e("<td/>").text(i[t.id]).appendTo(n),l.readOnly||e("<td/>").append(a).appendTo(n)}})),a},_createDeleteButton:function(t){let i=this,l=e("<button type='button'/>").addClass("plate-setup-remove-all-button");l.id=t.id+"Delete",l.text("Manage "+t.name+"...");let n=i._createElement("<div></div>").addClass("plate-setup-remove-all-button-container");n.append(l),t.deleteButton=l,t.root.find(".plate-setup-tab-field-right-side").append(n),l.click((function(){i._deleteDialog(t)}))}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.engine=function(t){return{engine:{derivative:{},colorMap:new Map,stackUpWithColor:{},stackPointer:2,wellEmpty:function(e){for(let t in e){if(!e.hasOwnProperty(t))continue;let i=e[t];if(null!=i){if(!Array.isArray(i))return!1;if(i.length>0)return!1}}return!0},searchAndStack:function(){this.stackUpWithColor={},this.stackPointer=1;let i={};for(let l in this.derivative){if(!this.derivative.hasOwnProperty(l))continue;let n=this.derivative[l],a={};for(let e=0;e<t.globalSelectedAttributes.length;e++){let i=t.globalSelectedAttributes[e];if(i in t.globalSelectedMultiplexSubfield){let e=t.globalSelectedMultiplexSubfield[i],l=[];for(let t in n[i]){if(!n[i].hasOwnProperty(t))continue;let a=n[i][t],s={};s[i]=a[i],e.forEach((function(e){s[e]=a[e]})),l.push(s)}a[i]=l}else null!=n[i]&&(a[i]=n[i])}e.isEmptyObject(a)?i[l]=null:i[l]=JSON.stringify(a)}for(;!e.isEmptyObject(i);){let e=Object.keys(i).map(parseFloat);e.sort((function(e,t){return e-t}));let t=e[0],l=i[t],n=[];if(l){for(let t=0;t<e.length;t++){let a=e[t];l===i[a]&&(n.push(a),this.stackUpWithColor[this.stackPointer]=n,delete i[a])}n.length>0&&this.stackPointer++}else this.stackUpWithColor[0]?this.stackUpWithColor[0].push(t):this.stackUpWithColor[0]=[t],delete i[t]}},applyColors:function(){let e=0,i=0;t.addBottomTableHeadings();for(let e=0;e<t.allTiles.length;e++){let i=t.allTiles[e];t.setTileVisible(i,!1)}for(let l=0;l<this.stackPointer;l++){let n=this.stackUpWithColor[l];if(n){t.addBottomTableRow(l,n);for(let a=0;a<n.length;a++){e++;let n=this.stackUpWithColor[l][a],s=t.allTiles[n],d=this.derivative[n];this.colorMap.set(n,l),t.setTileColor(s,l);let o=this.checkCompletion(d,s);t.setTileComplete(s,1===o),i+=o}}}i=Math.floor(100*i/e),isNaN(i)?t.overLayTextContainer.text("Completion Percentage: 0%"):t.overLayTextContainer.text("Completion Percentage: "+i+"%"),t.selectObjectInBottomTab()},checkCompletion:function(e){let i=0,l=0;for(let n=0;n<t.fieldList.length;n++){let a=t.fieldList[n];if(a.checkMultiplexCompletion){let t=a.checkMultiplexCompletion(e[a.id]);t.include&&(l+=t.completionPct,i++)}else a.required&&(i++,null!==e[a.id]&&l++)}return i===l?1:l/i}}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).assets=function(){return{_assets:{doImg:"&#10003;",dontImg:"",warningImg:"&#9888;"}}};plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.interface=function(){return{_createInterface:function(){this.container=this._createElement("<div></div>").addClass("plate-setup-wrapper"),this.topSection=this._createElement("<div></div>").addClass("plate-setup-top-section"),this.topLeft=this._createElement("<div></div>").addClass("plate-setup-top-left"),this.topRight=this._createElement("<div></div>").addClass("plate-setup-top-right"),this.overLayContainer=this._createElement("<div></div>").addClass("plate-setup-overlay-container"),this.canvasContainer=this._createElement("<div></div>").addClass("plate-setup-canvas-container"),this._createOverLay(),e(this.topLeft).append(this.overLayContainer),e(this.topLeft).append(this.canvasContainer),e(this.topSection).append(this.topLeft),e(this.topSection).append(this.topRight),e(this.container).append(this.topSection),e(this.element).append(this.container),this._createSvg(),this._createTabAtRight(),this._createTabs(),this._placePresetTabs(),this._bottomScreen(),this.bottomForFirstTime();let t=this;this._setShortcuts(),e(document.body).keyup((function(e){t._handleShortcuts(e)})),this._configureUndoRedoArray()},_createElement:function(t){return e(t)},_setShortcuts:function(){let e=this;window.addEventListener("cut",(function(t){document.activeElement===document.body&&(e.copyCriteria(),e.clearCriteria(),t.preventDefault())})),window.addEventListener("copy",(function(t){document.activeElement===document.body&&(e.copyCriteria(),t.preventDefault())})),window.addEventListener("paste",(function(t){document.activeElement===document.body&&(e.pasteCriteria(),t.preventDefault())}))},_handleShortcuts:function(e){document.activeElement===document.body&&(46===e.keyCode?(this.clearCriteria(),e.preventDefault()):(e.ctrlKey||e.metaKey)&&(90===e.keyCode?(e.shiftKey?this.redo():this.undo(),e.preventDefault()):89===e.keyCode&&(this.redo(),e.preventDefault())))}}}}(jQuery),(plateMapWidget=plateMapWidget||{}).loadPlate=function(){return{loadPlate:function(e){let t,i;if(e.hasOwnProperty("wells")){t={};for(let i in e.wells){let l=e.wells[i];t[this.addressToIndex(i)]=this.sanitizeWell(l)}}else t=this.engine.derivative;i=e.hasOwnProperty("checkboxes")?this.sanitizeCheckboxes(e.checkboxes):this.getCheckboxes();let l={derivative:t,checkboxes:i};this.setData(l)},sanitizeCheckboxes:function(e){return e=e||[],this.allCheckboxes.filter(t=>e.indexOf(t)>=0)},sanitizeAddresses:function(e){let t=(e=e||[]).map(e=>this.addressToIndex(e));return t.sort((e,t)=>e-t),t=t.filter((e,i)=>t.indexOf(e)===i),t},sanitizeWell:function(e){let t={};return this.fieldList.forEach((function(i){t[i.id]=i.parseValue(e[i.id])})),t},setData:function(e,t){this.engine.derivative=e.derivative,this.setCheckboxes(e.checkboxes,!0),this.setSelectedIndices(e.selectedIndices,!0),this.derivativeChange(),t||this.addToUndoRedo()}}};plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.overlay=function(){return{_createOverLay:function(){let e=this;this.overLayTextContainer=this._createElement("<div></div>").addClass("plate-setup-overlay-text-container"),this.overLayTextContainer.text("Completion Percentage:"),this.overLayContainer.append(this.overLayTextContainer),this.overLayButtonContainer=this._createElement("<div></div>").addClass("plate-setup-overlay-button-container"),this.overLayContainer.append(this.overLayButtonContainer),this.clearCriteriaButton=this._createElement("<button type='button' />").addClass("plate-setup-button"),this.clearCriteriaButton.text("Clear"),this.overLayButtonContainer.append(this.clearCriteriaButton),this.clearCriteriaButton.click((function(){e.clearCriteria()})),this.copyCriteriaButton=this._createElement("<button type='button' />").addClass("plate-setup-button"),this.copyCriteriaButton.text("Copy"),this.overLayButtonContainer.append(this.copyCriteriaButton),this.copyCriteriaButton.click((function(){e.copyCriteria()})),this.pasteCriteriaButton=this._createElement("<button type='button' />").addClass("plate-setup-button"),this.pasteCriteriaButton.text("Paste"),this.overLayButtonContainer.append(this.pasteCriteriaButton),this.pasteCriteriaButton.click((function(){e.pasteCriteria()})),this.undoButton=this._createElement("<button type='button' />").addClass("plate-setup-button"),this.undoButton.text("Undo"),this.overLayButtonContainer.append(this.undoButton),this.undoButton.click((function(){e.undo()})),this.redoButton=this._createElement("<button type='button' />").addClass("plate-setup-button"),this.redoButton.text("Redo"),this.overLayButtonContainer.append(this.redoButton),this.redoButton.click((function(){e.redo()}))},clearCriteria:function(){if(this.selectedIndices&&this.selectedIndices.length){let t,i=!1,l=this.selectedIndices;for(let n=0;n<l.length;n++){let a=l[n];a in this.engine.derivative&&(this.disableAddDeleteWell?this.engine.derivative.hasOwnProperty(a)&&(t=e.extend(!0,{},this.emptyWellWithDefaultVal),this.engine.derivative[a]=t):delete this.engine.derivative[a],i=!0)}i&&(this._colorMixer(),this.decideSelectedFields(),this.derivativeChange(),this.addToUndoRedo())}else alert("Please select any well")},copyCriteria:function(){if(this.selectedIndices&&this.selectedIndices.length){let e=this._getSelectedWells();this.commonData=this._getCommonData(e)}else alert("Please select any well.")},pasteCriteria:function(){this.commonData&&(this._addAllData(this.commonData),this.decideSelectedFields())}}}}(jQuery),$.widget("DNA.plateMap",{plateMapWidget:{},options:{value:0},addressToLoc:function(e){let t=/^([A-Z]+)(\d+)$/.exec(e.trim().toUpperCase());if(t){let e=t[1],i=parseInt(t[2])-1,l=0;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t)-65;t?(l+=1,l*=26,l+=i):l=i}return{r:l,c:i}}throw e+" not a proper plate address"},locToIndex:function(e,t){if(t||(t=this.dimensions),!(e.r>=0&&e.r<t.rows))throw"Row index "+(e.r+1)+" invalid";if(!(e.c>=0&&e.c<t.cols))throw"Column index "+(e.c+1)+" invalid";return e.r*t.cols+e.c},addressToIndex:function(e,t){let i=this.addressToLoc(e);return this.locToIndex(i,t)},_rowKey:function(e){let t=e%26,i=(e-t)/26,l=String.fromCharCode(65+t);return i>0&&(l=String.fromCharCode(64+i)+l),l},_colKey:function(e){return(e+1).toString(10)},indexToLoc:function(e,t){if(t||(t=this.dimensions),e>=t.rows*t.cols)throw"Index too high: "+e.toString(10);let i={};return i.c=e%t.cols,i.r=(e-i.c)/t.cols,i},locToAddress:function(e){return this._rowKey(e.r)+this._colKey(e.c)},indexToAddress:function(e,t){let i=this.indexToLoc(e,t);return this.locToAddress(i)},getDimensions:function(){return $.extend(!0,{},this.dimensions)},_create:function(){let e=parseInt(this.options.numRows||8),t=parseInt(this.options.numCols||12);this.dimensions={rows:e,cols:t},this.rowIndex=[];for(let t=0;t<e;t++)this.rowIndex.push(this._rowKey(t));this.target=this.element[0].id?"#"+this.element[0].id:"."+this.element[0].className,this.options.readOnly&&this.isReadOnly(!0);for(let e in plateMapWidget)plateMapWidget.hasOwnProperty(e)&&$.extend(this,new plateMapWidget[e](this));return this._createInterface(),this._trigger("created",null,this),this},_init:function(){},getTextDerivative:function(e){let t={},i=this.fieldMap;for(let l in e){if(!e.hasOwnProperty(l))continue;let n={},a={},s=e[l];for(let e in s)if(s.hasOwnProperty(e))if(e in i){let t=i[e],l=t.parseText(s[e]);a[t.name]=l,n[e]=l}else a[e]=s[e],n[e]=s[e];t[l]={textVal:n,textFieldVal:a}}return t},getWellsDifferences:function(e){let t=[];for(let i in e)e.hasOwnProperty(i)&&t.push(e[i]);let i={};if(t.length>1){let l=this._getCommonWell(t),n={};for(let e in t[0])t[0].hasOwnProperty(e)&&(n[e]=[]);for(let t in e){if(!e.hasOwnProperty(t))continue;let a={},s=e[t];for(let e in s){if(!s.hasOwnProperty(e))continue;let t=l[e],i=s[e];void 0===t&&(t=null),void 0===i&&(i=null);let d=null;if(Array.isArray(i)){t=t||[],d=[];for(let l=0;l<i.length;l++){let a=i[l];a&&"object"==typeof a?this.containsObject(a,t)||(d.push(a),this.containsObject(a,n[e])||n[e].push(a)):t.indexOf(a)<0&&(d.push(a),!n[e].indexOf(a)>=0&&n[e].push(a))}}else i&&"object"==typeof i?t&&"object"==typeof t?i.value!==t.value&&i.unit!==t.unit&&(d=i,this.containsObject(i,n[e])||n[e].push(i)):(d=i,this.containsObject(i,n[e])||n[e].push(i)):i!==t&&(d=i,!n[e].indexOf(i)>=0&&n[e].push(i));a[e]=d}i[t]=a}for(let e in n)if(n.hasOwnProperty(e)&&0===n[e].length)for(let t in i)i.hasOwnProperty(t)&&delete i[t][e];return i}if(t.length>0){let t={};for(let i in e){if(!e.hasOwnProperty(i))continue;let l={},n=e[i];for(let e in n){if(!n.hasOwnProperty(e))continue;let t=n[e];Array.isArray(t)?t.length>0&&(l[e]=t):t&&(l[e]=t)}t[i]=l}return t}},setFieldsDisabled:function(e){this.fieldList.forEach((function(t){t.disabled(e)}))},isReadOnly:function(e){this.readOnly=!!e,this.readOnlyHandler()},readOnlyHandler:function(){this.readOnly?(this.overLayButtonContainer.css("display","none"),$(".multiple-field-manage-delete-button").css("display","none"),this.setFieldsDisabled(!0)):(this.overLayButtonContainer.css("display","flex"),$(".multiple-field-manage-delete-button").css("display","none"),this.disableAddDeleteWell||this.setFieldsDisabled(!1))},disableAddDeleteWell:null,isDisableAddDeleteWell:function(e,t){if(e){let e=$.extend(!0,{},this.defaultWell);if(t)for(let i in t)t.hasOwnProperty(i)&&(i in e?e[i]=t[i]:console.log("No field for key: "+key+", please contact support"));this.disableAddDeleteWell=!0,this.addressAllowToEdit=this.getWellSetAddressWithData(),this.actionPointer=0,this.undoRedoArray=[this.createState()],this.emptyWellWithDefaultVal=e}else this.disableAddDeleteWell=!1,this.emptyWellWithDefaultVal=null;this.readOnlyHandler()},selectObjectInBottomTab:function(){let e=[],t=this.selectedIndices;for(let i=0;i<t.length;i++){let l=t[i];if(this.engine.derivative[l]){let t=this.engine.colorMap.get(l);e.indexOf(t)<0&&e.push(t)}}let i=document.querySelectorAll("table.plate-setup-bottom-table tr");for(let t=1;t<i.length;t++){let l=i[t],n=l.children[0],a=e.indexOf(Number(n.querySelector("button").innerHTML))>=0;l.classList.toggle("selected",a)}},getSelectedIndices:function(){return this.selectedIndices.slice()},getSelectedAddresses:function(){return this.selectedIndices.map((function(e){return this.allTiles[e].address}),this)},setSelectedAddresses:function(e,t){let i=this.sanitizeAddresses(e);this.setSelectedIndices(i,t)},setSelectedIndices:function(e,t){e&&0!==e.length||(e=[0]),this.setSelection(e),this.decideSelectedFields(),this._trigger("selectedWells",null,{selectedAddress:this.getSelectedAddresses()}),this.selectObjectInBottomTab(),t||this.addToUndoRedo()}});plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.preset=function(){return{presets:[],_placePresetTabs:function(){let t=this.options.attributes.presets;if(t&&t.length){this.wellAttrContainer=this._createElement("<div></div>").addClass("plate-setup-well-attr-container").text("Checkbox presets"),this.tabContainer.append(this.wellAttrContainer),this.presetTabContainer=this._createElement("<div></div>").addClass("plate-setup-preset-container"),this.tabContainer.append(this.presetTabContainer);for(let i=0;i<t.length;i++){let l=t[i],n=this._createElement("<div></div>").addClass("plate-setup-preset-tab-div").text(l.title),a=this._createElement("<div></div>").addClass("plate-setup-preset-tab").data("preset",l.fields).append(n);this.presetTabContainer.append(a);let s=this;a.click((function(){let t=e(this);s._selectPreset(t)})),this.presets.push(a)}}},_clearPresetSelection:function(){for(let e=0;e<this.presets.length;e++){this.presets[e].removeClass("plate-setup-preset-tab-selected").addClass("plate-setup-preset-tab")}},_selectPreset:function(e){this.setCheckboxes(e.data("preset")),e.removeClass("plate-setup-preset-tab").addClass("plate-setup-preset-tab-selected")}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.svgCreate=function(){return{baseSizes:{spacing:48,tile_radius:22,center_radius_complete:10,center_radius_incomplete:14,label_size:14,label_spacing:24,text_size:13,stroke:.5,gap:2},allTiles:[],_createSvg:function(){this.svg=new e(this.canvasContainer[0]),this.svg.attr("preserveAspectRatio","xMidYMin meet");let t=this.baseSizes.label_spacing;this.svg.viewbox(-t,-t,t+this.dimensions.cols*this.baseSizes.spacing,t+this.dimensions.rows*this.baseSizes.spacing),this.wellShadow=this.svg.gradient("radial",(function(e){e.at(.8,"rgba(0,0,0,0.1)"),e.at(1,"rgba(0,0,0,0.2)")})).from("50%","50%").to("50%","55%").radius("50%").attr("id","wellShadow"),this.wellColors=this.colorPairs.map((function(e,t){return this.svg.gradient("linear",(function(t){t.at(0,e[0]),t.at(1,e[1])})).from(0,0).to(0,1).id("wellColor"+t.toString())}),this),this._fixRowAndColumn(),this._putCircles(),this._svgEvents()},_fixRowAndColumn:function(){let e=this.dimensions.cols,t=this.dimensions.rows,i=this.svg.nested().attr({x:-this.baseSizes.label_spacing/2}).addClass("rowHead"),l=this.svg.nested().attr({y:-this.baseSizes.label_spacing/2}).addClass("colHead");for(let e=0;e<t;e++)i.plain(this._rowKey(e)).attr({y:this.baseSizes.spacing*(e+.5)});for(let t=0;t<e;t++)l.plain(this._colKey(t)).attr({x:this.baseSizes.spacing*(t+.5)})},_putCircles:function(){let e=this.dimensions.cols,t=this.dimensions.rows;this.allTiles=Array(e*t);for(let i=0;i<t;i++)for(let t=0;t<e;t++){let e=this._createTile(i,t);this.allTiles[e.index]=e}},_createTile:function(e,t){let i=this.svg.nested().move(this.baseSizes.spacing*t,this.baseSizes.spacing*e).addClass("tile"),l=this.baseSizes.spacing/2,n={tile:i};n.r=e,n.c=t,n.index=this.locToIndex(n),n.address=this.locToAddress(n),i.rect(this.baseSizes.spacing,this.baseSizes.spacing).addClass("highlight"),i.circle(2*this.baseSizes.tile_radius).center(l,l).addClass("well").fill(this.wellShadow);let a=i.group().addClass("fill");return n.circle=a.circle(2*this.baseSizes.tile_radius).center(l,l).addClass("circle").fill(this.wellColors[0]),a.circle(2*this.baseSizes.center_radius_complete).center(l,l).addClass("center"),a.circle(2*this.baseSizes.center_radius_incomplete).center(l,l).addClass("center_incomplete"),n.label=a.plain("0").attr({x:l,y:l}).addClass("label"),n},setTileComplete:function(e,t){t?e.tile.removeClass("incomplete"):e.tile.addClass("incomplete")},setTileVisible:function(e,t){t?e.tile.removeClass("empty"):e.tile.addClass("empty")},setTileColor:function(e,t){this.setTileVisible(e,!0),e.colorIndex=parseInt(t),e.label.plain(String(e.colorIndex)),t>0&&(t=(t-1)%(this.wellColors.length-1)+1),e.circle.fill(this.wellColors[t])}}}}(SVG);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.svgEvents=function(){return{colorToIndex:{},selectedIndices:[],_svgEvents:function(){let t,i=this;function l(e){let t=i.svg.node.getScreenCTM();return{x:(e.clientX-t.e)/t.a,y:(e.clientY-t.f)/t.d}}function n(e,t){return t-=1,e<0?0:e>=t?t:Math.trunc(e)}function a(e){let t=i.baseSizes.spacing,l=n(e.x/t,i.dimensions.cols);return{r:n(e.y/t,i.dimensions.rows),c:l}}function s(e,t){let l=a(e),n=a(t),s=i.baseSizes.spacing,d=Math.min(l.c,n.c)*s,o=Math.min(l.r,n.r)*s;return e.x<0&&(l.c=i.dimensions.cols-1),e.y<0&&(l.r=i.dimensions.rows-1),{x:d,y:o,width:(Math.max(l.c,n.c)+1)*s-d,height:(Math.max(l.r,n.r)+1)*s-o}}function d(e){if(t){!function(e,t,l){let n=a(e),s=a(t),d=!0;if(l){let e=i.locToIndex(n);d=i.selectedIndices.indexOf(e)<0}let o=Math.min(n.c,s.c),r=Math.min(n.r,s.r);e.x<0&&(n.c=i.dimensions.cols-1),e.y<0&&(n.r=i.dimensions.rows-1);let u=Math.max(n.c,s.c),c=Math.max(n.r,s.r),p=[];for(let e=r;e<=c;e++)for(let t=o;t<=u;t++){let l=i.locToIndex({r:e,c:t});p.push(l)}l&&(d?i.selectedIndices.forEach((function(e){p.indexOf(e)<0&&p.push(e)})):p=i.selectedIndices.filter(e=>p.indexOf(e)<0)),i.setSelectedIndices(p.sort((e,t)=>e-t))}(t.data("origin"),l(e),e.shiftKey),t.remove(),t=null}}this.svg.node.addEventListener("mousedown",(function(e){t&&t.remove();let n=l(e),a=s(n,n);t=i.svg.rect().attr(a).fill("rgba(0, 0, 1, 0.2)"),t.data("origin",n)})),this.svg.node.addEventListener("mousemove",(function(e){if(t){let i=l(e),n=s(t.data("origin"),i);t.attr(n)}})),this.svg.node.addEventListener("mouseleave",d),this.svg.node.addEventListener("mouseup",d),e(i.target).on("loadPlate",(function(e,t){i.loadPlate(JSON.parse(t))}))},setSelection:function(e){this.selectedIndices=e,this._setSelectedTiles(),document.activeElement.blur()},_setSelectedTiles:function(){let e=this.selectedIndices;this.allTiles.forEach((function(t){e.indexOf(t.index)>=0?t.tile.addClass("selected"):t.tile.removeClass("selected")}))},_getSelectedWells:function(){return this.selectedIndices.map((function(e){let t=this.engine.derivative[e];return t||(t=this.defaultWell),t}),this)},containsObject:function(e,t){function i(e,t){if(e===t)return!0;if("object"==typeof e&&null!=e&&"object"==typeof t&&null!=t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let l in e)if(e.hasOwnProperty(l)){if(!t.hasOwnProperty(l))return!1;if(!i(e[l],t[l]))return!1}return!0}return!1}if(t)for(let l=0;l<t.length;l++)if(i(e,t[l]))return!0;return!1},_buildCommonData:function(t,i,l){let n=t[l];void 0===n&&(n=null);let a=i[l];if(void 0===a&&(a=null),Array.isArray(n)){let i=[];if(!a)return void(t[l]=i);for(let t=0;t<n.length;t++){let s=n[t];if(s&&"object"==typeof s)for(let t=0;t<a.length;t++){let n=a[t];if(s[l]==n[l]){s=e.extend(!0,{},s);for(let e in s)this._buildCommonData(s,n,e);i.push(s)}}else e.inArray(s,a)>=0&&i.push(s)}t[l]=i}else a&&"object"==typeof a&&n&&"object"==typeof n?a.value===n.value&&a.unit===n.unit||delete t[l]:n!==a&&delete t[l]},_getCommonData:function(t){let i=null;for(let l=0;l<t.length;l++){let n=t[l];if(null!=n)if(null!=i)for(let e in i)i.hasOwnProperty(e)&&this._buildCommonData(i,n,e);else i=e.extend(!0,{},t[0])}return i||this.defaultWell},_getCommonWell:function(e){let t=this._getCommonData(e);return this.sanitizeWell(t)},_getAllMultipleVal:function(t){let i=this.multipleFieldList,l=this;i.forEach((function(i){if(t.length){let n={},a=null;t.forEach((function(t){if(null==t)return;let s=i.id,d=t[s];d&&d.length&&d.forEach((function(t){if("object"==typeof t){if(null==a)a=e.extend(!0,{},t);else for(let e in a)l._buildCommonData(a,t,e);t[s]in n?n[t[s]]++:n[t[s]]=1}else t in n?n[t]++:n[t]=1}))})),i.allSelectedMultipleData=a||{},i.allSelectedMultipleVal=n}else i.allSelectedMultipleData=null,i.allSelectedMultipleVal=null}))},decideSelectedFields:function(){let e=this._getSelectedWells();this._getAllMultipleVal(e),this.applyFieldWarning(e);let t=this._getCommonWell(e);this._addDataToTabFields(t)},getWellSetAddressWithData:function(){return Object.keys(this.engine.derivative).map(Number).sort((e,t)=>e-t).map(e=>this.indexToAddress(e))}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.tabs=function(){return{allTabs:[],defaultWell:{},allDataTabs:[],_createTabAtRight:function(){this.tabContainer=this._createElement("<div></div>").addClass("plate-setup-tab-container"),e(this.topRight).append(this.tabContainer)},_createTabs:function(){this.tabHead=this._createElement("<div></div>").addClass("plate-setup-tab-head"),e(this.tabContainer).append(this.tabHead);let t=this.options.attributes.tabs,i=this;t.forEach((function(t,l){i.allTabs[l]=i._createElement("<div></div>").addClass("plate-setup-tab"),e(i.allTabs[l]).data("index",l).text(t.name),e(i.allTabs[l]).click((function(){i._tabClickHandler(this)})),e(i.tabHead).append(i.allTabs[l])})),this.tabDataContainer=this._createElement("<div></div>").addClass("plate-setup-tab-data-container"),e(this.tabContainer).append(this.tabDataContainer),this._addDataTabs(t),e(this.allTabs[0]).click(),this._addTabData()},_tabClickHandler:function(t){if(this.selectedTab){e(this.selectedTab).removeClass("plate-setup-tab-selected").addClass("plate-setup-tab");let t=e(this.selectedTab).data("index");e(this.allDataTabs[t]).css("z-index",0),this.readOnlyHandler()}e(t).addClass("plate-setup-tab-selected"),this.selectedTab=t;let i=e(t).data("index");e(this.allDataTabs[i]).css("z-index",1e3)},_addDataTabs:function(t){this.allDataTabs=t.map((function(){return this._createElement("<div></div>").addClass("plate-setup-data-div").css("z-index",0)}),this),e(this.tabDataContainer).append(this.allDataTabs)}}}}(jQuery);plateMapWidget=plateMapWidget||{};!function(e){plateMapWidget.undoRedoManager=function(){return{undoRedoArray:[],actionPointer:null,addToUndoRedo:function(){let e=this.createState();if(null!=this.actionPointer){let e=this.actionPointer+1;e<this.undoRedoArray.length&&this.undoRedoArray.splice(e,this.undoRedoArray.length-e)}this.actionPointer=null,this.undoRedoArray.push(e)},_configureUndoRedoArray:function(){this.undoRedoArray=[],this.actionPointer=null,this.undoRedoArray.push(e.extend({},{checkboxes:[],derivative:{},selectedIndices:[0]}))},clearHistory:function(){this.undoRedoArray=this.undoRedoArray.slice(-1),this.actionPointer=null},undo:function(){return console.log("undo"),this.shiftUndoRedo(-1)},redo:function(){return console.log("redo"),this.shiftUndoRedo(1)},shiftUndoRedo:function(e){let t=this.actionPointer;return null==t&&(t=this.undoRedoArray.length-1),t+=e,this.setUndoRedo(t)},setUndoRedo:function(e){return!(e<0)&&(!(e>=this.undoRedoArray.length)&&(this.actionPointer=e,this.setData(this.undoRedoArray[e],!0),!0))}}}}(jQuery);//# sourceMappingURL=plate-map.min.js.map