!function(){"use strict";angular.module("app.ps",[]).factory("ps",["csInterface","tk","$q",function(csInterface,tk,$q){function script(e){return $q(function(t,n){csInterface.evalScript(e,t)})}function evalScript(e,t){t=t||angular.noop,csInterface.evalScript(e,t)}function openWeb(e){csInterface.openURLInDefaultBrowser(e)}function runFilter(){console.log(tk.params),script("selectLayer()").then(script("RunTonalRangeSelector("+JSON.stringify(tk.params)+")")).then(console.log(tk.params)).then(script("selectMask(true)"))}function hasLayersError(){return eval(script("hasLayerError()").then(function(e){var t=JSON.parse(e);return t.hasLayerMask&&t.layerID==tk.mergedLayerID?!1:!0}))}function tryRunFilter(){hasLayersError().then(function(e){e?reset(!0):runFilter()})}function cleanLayer(){evalScript("cleanLayer("+tk.mergedLayerID+")",function(e){tk.isInitialized=!1})}function reset(e){tk.isInitialized&&(cleanLayer(),tk.applyPreset("Zero")),document.getElementById("Luminosity").checked=!1,document.getElementById("R").checked=!1,document.getElementById("G").checked=!1,document.getElementById("B").checked=!1,document.getElementById("Saturation").checked=!1;var t="Your last Infinity Mask session just auto-canceled.\\n\\nPossible causes include changing layers, documents, or history states during the Infinity Mask session.\\n\\nTo avoid auto-cancellation in the future, ALWAYS finish the Infinity Mask session by doing one of the following:\\n     1 - Click an output button to use the mask, or\\n     2 - Close the session using the 'Cancel' button";e&&evalScript('alert("'+t+'")')}return{evalScript:evalScript,script:script,hasLayersError:hasLayersError,tryRunFilter:tryRunFilter,runFilter:runFilter,cleanLayer:cleanLayer,openWeb:openWeb,reset:reset}}])}();